Closed flisboac closed 4 years ago
this is working as it should, if you want to use modules you have to instruct eslint to let you: try adding
"parserOptions": {
"sourceType": "module",
}
Its also good to set ecmaVersion
(same as tsconfig) in parserOptions
you can find more info at https://eslint.org/docs/user-guide/configuring#specifying-parser-options and https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#configuration
@armano2 - our parser doesn't actually respect this parserOption - typescript has its own logic for determining this.
could you please run your lint run with the --debug
flag?
after reviewing your source code there is issue in name of your eslint config.
it has not standard name .eslint.js
(eslint is unable to locate it),
in case when you want to use js file it should be .eslintrc.js
or you should provide config as console argument.
eslint . --ext .js,.jsx,.ts,.tsx -c .eslint.js
#or
eslint . --ext .js,.jsx,.ts,.tsx --config .eslint.js
^ @bradzacher you are correct, parser itself does not use this field but its used in rules and scope analysis (i'm keep forgetting about this)
after reviewing your source code there is issue in name of your eslint config. it has not standard name
.eslint.js
(eslint is unable to locate it), in case when you want to use js file it should be.eslintrc.js
or you should provide config as console argument.eslint . --ext .js,.jsx,.ts,.tsx -c .eslint.js #or eslint . --ext .js,.jsx,.ts,.tsx --config .eslint.js
^ @bradzacher you are correct, parser itself does not use this field but its used in rules and scope analysis (i'm keep forgetting about this)
Oh god, such a stupid mistake. I'm sorry!
@armano2 @bradzacher thank you very much!
What code were you trying to parse?
I'm trying to use
typescript-eslint
, and I followed the Getting Started page. Unfortunately, I'm having problems to make the parser identify very basic TypeScript/JS keywords, likeexport
.Please see https://github.com/flisboac/ts-promise-scheduler for the project in question. The error is:
My
.eslint.js
is configured as such:And here are the first lines of the affected file
What did you expect to happen?
To accept
export
as a keyword, as per named/defaultexport
in TypeScript and the ES6+ standards, in the context of exporting declarations.What actually happened?
export
seems to be identified as a reserved name, regardless of context. Parsing fails.Versions
Disclaimer:I'm using
yarn
.@typescript-eslint/parser
2.16.0
TypeScript
3.7.4
ESLint
6.8.0
node
12.13.0
npm
6.12.0
yarn
1.21.1
Output of
yarn versions`:Output of
yarn list
: