-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: support 'latest'
as ecmaVersion
#3710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the PR, @fisker! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day. |
Codecov Report
@@ Coverage Diff @@
## master #3710 +/- ##
==========================================
- Coverage 92.68% 92.67% -0.02%
==========================================
Files 327 327
Lines 11352 11359 +7
Branches 3201 3205 +4
==========================================
+ Hits 10522 10527 +5
- Misses 369 370 +1
- Partials 461 462 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Any chance this can get merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! Two quikc comments
@@ -26,7 +26,7 @@ interface ScopeManagerOptions { | |||
globalReturn?: boolean; | |||
sourceType?: 'module' | 'script'; | |||
impliedStrict?: boolean; | |||
ecmaVersion?: number; | |||
ecmaVersion?: number | 'latest'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of letting this string trickle all the way down into here such that it needs to be handled differently - I think we should instead convert it to a number at the parser level.
This would be similar to what ESLint does for espree (they annoyingly do it within eslint itself...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't use typescript, I'm not sure how to fix the type check, can some one help? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests/eslint-scope/map-ecma-version.test.ts:47:23 - error TS2322: Type 'EcmaVersion' is not assignable to type 'number | undefined'.
Type '"latest"' is not assignable to type 'number | undefined'.
47 analyze(fakeNode, { ecmaVersion: ecmaVersion as EcmaVersion });
~~~~~~~~~~~
The types in the test are wrong.
You've retyped ecmaVersion
in the analyze
options to be a number
, but your test passes in a string
.
@@ -18,7 +18,7 @@ interface AnalyzeOptions { | |||
* Which ECMAScript version is considered. | |||
* Defaults to `2018`. | |||
*/ | |||
ecmaVersion?: EcmaVersion; | |||
ecmaVersion?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ecmaVersion?: number; | |
ecmaVersion?: EcmaVersion; |
if (version === 'latest') { | ||
return 'esnext'; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need/want this check any more
I don't have the knowledge to fix it. |
Ref eslint/eslint#14720