Bug: `scope-manager` does not support the `ecmaVersion` option set to "latest."
Closed this issue ยท 6 comments
Which packages are affected?
-
espree
-
eslint-scope
-
eslint-visitor-keys
Environment
Node version:
npm version:
ESLint version:
Operating System:
What did you do?
Tried to set the ecmaVersion option to lastest
in the scope-manager
.
What did you expect to happen?
Since we selected the "latest" option, it should recognize the most recent ECMAScript version and support import declarations.
What actually happened?
Got the below error:
ImportDeclaration should appear when the mode is ES6 and in the module context.
js/packages/eslint-scope/lib/scope-manager.js
Line 243 in 91d51d3
The above condition becomes false when the
ecmaVersion
option is set to latest
.
Link to Minimal Reproducible Example
https://deploy-preview-31--eslint-code-explorer.netlify.app/
Participation
- I am willing to submit a pull request for this issue.
Additional comments
In Espree, the ecmaVersion
option can be set to "latest"
to support the most recent ECMAScript features.
js/packages/espree/lib/options.js
Line 50 in 91d51d3
Should we maintain consistent handling and options for ecmaVersion
in both Espree
and eslint-scope
?
This isn't actually a bug because "latest"
was never intended to work in eslint-scope
. In order to do that, we'd need to keep updating the package, which I don't think is worth the effort. espree
already exports latestEcmaVersion
that indicates which version "latest"
corresponds to. Can you use that?
This isn't actually a bug because
"latest"
was never intended to work ineslint-scope
. In order to do that, we'd need to keep updating the package, which I don't think is worth the effort.espree
already exportslatestEcmaVersion
that indicates which version"latest"
corresponds to. Can you use that?
Sure, I'll use espree
to determine the "latest" version. Should we update the eslint-scope
README file to recommend using espree
for obtaining the latest
version if the "latest" option is used for ecmaVersion
?
Another option is to use the latestEcmaVersion
exported by espree
directly within eslint-scope
to determine the latest version, rather than suggesting users utilize espree
separately. If we choose not to update the eslint-scope
package, we can ignore it.
Actually, we only care if it's greater than 5, we can do something like eslint did:
https://github.com/eslint/eslint/blob/8781e6f063e56438dc22346504ff637df3f84daf/lib/linter/linter.js#L919
We only care if it's greater than 5 right now. We don't know what scope changes might come in the future.
Sure, I'll use
espree
to determine the "latest" version. Should we update theeslint-scope
README file to recommend usingespree
for obtaining thelatest
version if the "latest" option is used forecmaVersion
?
I don't think that's necessary. This package is used mostly by us, and for anyone else who's using it, I assume they know what ecmaVersion
they want.
Another option is to use the
latestEcmaVersion
exported byespree
directly withineslint-scope
to determine the latest version, rather than suggesting users utilizeespree
separately. If we choose not to update theeslint-scope
package, we can ignore it.
That would require that eslint-scope
to have a dependency on Espree, which we don't want.
If there's no AI involved, we can close this issue.
Sounds good. And by AI, I think you mean action item rather than artificial intelligence. ๐