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

Breaking: stricter rule config validating (fixes #9505) #11742

Merged
merged 3 commits into from May 25, 2019

Conversation

aladdin-add
Copy link
Member

@aladdin-add aladdin-add commented May 19, 2019

todo:

  • migration guide need to be updated.

What is the purpose of this pull request? (put an "X" next to item)

[x] Add something to the core

What changes did you make? (Give an overview)
fixes #9505

Is there anything you'd like reviewers to focus on?

config before after
/*eslint-enable foo*/ no error linting error
/*eslint-disable(-line) foo*/ no error linting error
/*eslint foo: 0*/ no error linting error
{rules: {foo: 0}} no error no error
{rules: {foo: 1} linting warning linting error
  • please note getRule() will not return a stub rule if the rule cannot be loaded.

Previously, the ruleMapper.getRule() will return a stub rule, when the rule is not defined. it was really counter-intuitive and confusing.

After this change, it will return null in this case. As a result it will report a linting error, and has no effect to the final config:
image

@aladdin-add aladdin-add added enhancement This change enhances an existing feature of ESLint core Relates to ESLint's core APIs and features accepted There is consensus among the team that this change meets the criteria for inclusion breaking This change is backwards-incompatible labels May 19, 2019
Copy link
Member

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

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

Hi. Thank you for your contribution!

I have some suggestions.

lib/config/config-validator.js Outdated Show resolved Hide resolved
lib/linter.js Outdated Show resolved Hide resolved
lib/config/config-validator.js Outdated Show resolved Hide resolved
lib/linter.js Outdated Show resolved Hide resolved
tests/lib/config/config-validator.js Outdated Show resolved Hide resolved
@mysticatea mysticatea added this to Implemented, pending review in v6.0.0 May 20, 2019
Copy link
Member

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

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

Great. The direction looks good to me.

I have some suggestions.

(And I guess the "commit-message" check fails due to the length of the PR title.)

Thank you!

lib/linter.js Outdated Show resolved Hide resolved
lib/linter.js Outdated Show resolved Hide resolved
lib/linter.js Outdated Show resolved Hide resolved
@@ -1370,8 +1370,8 @@ describe("CLIEngine", () => {
assert.strictEqual(report.results.length, 1);
assert.strictEqual(report.results[0].messages.length, 1);
assert.strictEqual(report.results[0].messages[0].ruleId, "missing-rule");
assert.strictEqual(report.results[0].messages[0].severity, 1);
assert.strictEqual(report.results[0].messages[0].message, "Definition for rule 'missing-rule' was not found");
assert.strictEqual(report.results[0].messages[0].severity, 2);
Copy link
Member

Choose a reason for hiding this comment

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

I'm OK for this change, but we have to add it to the migration guide because it can newly fail CI builds.

@aladdin-add aladdin-add force-pushed the issue9505 branch 3 times, most recently from 6ef06fa to 98bda3c Compare May 22, 2019 11:43
@aladdin-add aladdin-add changed the title Breaking: throw an error if disables a non-existent rule in a configuration comment (fixes#9505) wip: Breaking: throw an error if disables a non-existent rule in a configuration comment (fixes#9505) May 22, 2019
@mysticatea mysticatea moved this from Implemented, pending review to Accepted, ready to implement in v6.0.0 May 24, 2019
@aladdin-add aladdin-add changed the title wip: Breaking: throw an error if disables a non-existent rule in a configuration comment (fixes#9505) Breaking: more stricter rule config validating (fixes#9505) May 24, 2019
@aladdin-add aladdin-add changed the title Breaking: more stricter rule config validating (fixes#9505) Breaking: stricter rule config validating (fixes#9505) May 24, 2019
@aladdin-add aladdin-add changed the title Breaking: stricter rule config validating (fixes#9505) Breaking: stricter rule config validating (fixes #9505) May 24, 2019
@aladdin-add
Copy link
Member Author

aladdin-add commented May 24, 2019

I think it's ready to be reviewed! 😄 ptal. @mysticatea

to fix issue eslint#9505, it made a refactor and introduced a few changes to make validating more consistent:
* will report a linting error when enable/disable a non-existent in inline comment.
* will throw an error, if config a non-existent rule to non-zero value.
* fixes problem loc in some cases
Copy link
Member

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

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

Looks very good to me. Thank you!

@aladdin-add
Copy link
Member Author

and please note: this PR will break npm run perf, and should be fixed by #11756

@mysticatea mysticatea moved this from Accepted, ready to implement to Implemented, pending review in v6.0.0 May 24, 2019
@ilyavolodin
Copy link
Member

@aladdin-add Could you also add information into migration guide please?

@ilyavolodin
Copy link
Member

@aladdin-add Since this is the last breaking issue left in this release, I'm going to merge it as is. Could you open a new PR with updated migration guide please? We will merge it with the next release.

@ilyavolodin ilyavolodin merged commit 2d32a9e into eslint:master May 25, 2019
v6.0.0 automation moved this from Implemented, pending review to Done May 25, 2019
aladdin-add added a commit that referenced this pull request May 26, 2019
it is no longer needed, as #11742 get merged. :)
@aladdin-add aladdin-add deleted the issue9505 branch May 31, 2019 13:46
@mysticatea
Copy link
Member

Well, we need to update our migration guide.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 22, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Nov 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion breaking This change is backwards-incompatible core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint
Projects
No open projects
v6.0.0
  
Done
Development

Successfully merging this pull request may close these issues.

should throw an error when disabling a non-existent rule
3 participants