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
Update: re-enable experimentalObjectRestSpread (fixes #9990) #10230
Conversation
And it generates a deprecation warning to show that the option has been deprecated.
Thanks for working on this!
|
Thank you for the good suggestion! I moved the warning to Code which enables |
lib/linter.js
Outdated
@@ -996,13 +1006,15 @@ module.exports = class Linter { | |||
throw err; | |||
} | |||
|
|||
return applyDisableDirectives({ | |||
lintingProblems = applyDisableDirectives({ |
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.
Nitpick: Could this just be return applyDisableDirectives({ // ...
again since lintingProblems
is no longer being modified afterwards?
lib/linter.js
Outdated
parserOptions.ecmaFeatures && | ||
parserOptions.ecmaFeatures.experimentalObjectRestSpread && | ||
(!parserOptions.ecmaVersion || parserOptions.ecmaVersion < 9) | ||
) { |
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.
Nitpick: Could this logic be moved to the resolveParserOptions
function?
tests/lib/config.js
Outdated
let warning = null; | ||
|
||
function onWarning(w) { // eslint-disable-line require-jsdoc | ||
warning = w; |
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.
Should we do something like this instead?
function onWarning(w) {
if (w.code === 'ESLint') {
warning = w;
}
}
That way, the test won't break if a warning happens for an unrelated reason (e.g. a deprecation in a dependency).
lib/config/config-validator.js
Outdated
|
||
process.emitWarning( | ||
`${message} (found in "${rel}")`, | ||
{ code: "ESLint", type: "DeprecationWarning" } |
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 think the code
property of a warning is generally supposed to be unique for a given type of warning, so that tools can filter warnings reliably even if the message changes. Maybe it would be better to do something like { code: 'ESLINT_EXPERIMENTAL_OBJECT_REST_SPREAD' }
instead, to make sure it's distinguished from other warnings.
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 see. Today I leaned the meaning of the code
property.
However, I feel reluctant to make code
longer since the string will be printed for users. To be clear, Node.js prints this message such as:
(node:10736) [ESLint] DeprecationWarning: The 'parserOptions.ecmaFeatures.experimentalObjectRestSpread' option is deprecated. Use 'parserOptions.ecmaVersion' instead. (found in "tests\fixtures\config-file\experimental-object-rest-spread\extends\common.yml")
The first [ESLint]
is the code
.
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.
Maybe we could make it something like ESLINT_EORS
?
@not-an-aardvark Thank you for the review! Eventually, I followed your suggestion about the error code. EDIT: In the following screenshot, I think that this progress bar can surprise contributors. The |
This third parameter |
seems this should use tag |
What is the purpose of this pull request? (put an "X" next to item)
[X] Other, please explain: fixes #9990
What changes did you make? (Give an overview)
parserOptions.ecmaFeatures.experimentalObjectRestSpread
is given andparserOptions.ecmaVersion
is less than9
,linter
enablesparserOptions.ecmaVersion: 9
for backward compatibility.parserOptions.ecmaFeatures.experimentalObjectRestSpread
is given,linter
generates a deprecation warning to show the deprecation.Is there anything you'd like reviewers to focus on?
I make the deprecation warning is as a message with
severity: 1
. Should it be with another way?