Skip to content
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

feat: support 'latest' as ecmaVersion #3710

Closed
wants to merge 4 commits into from

Conversation

fisker
Copy link
Contributor

@fisker fisker commented Aug 5, 2021

@typescript-eslint
Copy link
Contributor

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
Copy link

codecov bot commented Aug 5, 2021

Codecov Report

Merging #3710 (d93aec0) into master (fa35e22) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            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     
Flag Coverage Δ
unittest 92.67% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/scope-manager/src/analyze.ts 68.96% <100.00%> (+2.29%) ⬆️
packages/eslint-plugin/src/util/isTypeReadonly.ts 94.20% <0.00%> (-2.82%) ⬇️
packages/eslint-plugin/src/rules/dot-notation.ts 92.30% <0.00%> (ø)
...ackages/experimental-utils/src/ts-eslint/Linter.ts 100.00% <0.00%> (ø)
...t-plugin/src/rules/prefer-reduce-type-parameter.ts 100.00% <0.00%> (ø)

@fisker
Copy link
Contributor Author

fisker commented Aug 30, 2021

Any chance this can get merged?

Copy link
Member

@bradzacher bradzacher left a 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

packages/types/src/parser-options.ts Show resolved Hide resolved
@@ -26,7 +26,7 @@ interface ScopeManagerOptions {
globalReturn?: boolean;
sourceType?: 'module' | 'script';
impliedStrict?: boolean;
ecmaVersion?: number;
ecmaVersion?: number | 'latest';
Copy link
Member

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...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled latest in parser, used 1e8 like acorn and babel

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Aug 30, 2021
@fisker
Copy link
Contributor Author

fisker commented Aug 30, 2021

I don't use typescript, I'm not sure how to fix the type check, can some one help?

Copy link
Member

@bradzacher bradzacher left a 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ecmaVersion?: number;
ecmaVersion?: EcmaVersion;

packages/types/src/parser-options.ts Show resolved Hide resolved
Comment on lines +85 to +88
if (version === 'latest') {
return 'esnext';
}

Copy link
Member

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

@fisker
Copy link
Contributor Author

fisker commented Aug 30, 2021

I don't have the knowledge to fix it.

@fisker fisker closed this Aug 30, 2021
@fisker fisker deleted the ecmaversion-latest branch August 30, 2021 17:37
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting response Issues waiting for a reply from the OP or another party enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants