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

Validate against invalid rule schema defaults in RuleTester #11473

Closed
not-an-aardvark opened this issue Mar 4, 2019 · 2 comments
Closed

Validate against invalid rule schema defaults in RuleTester #11473

not-an-aardvark opened this issue Mar 4, 2019 · 2 comments

Comments

@not-an-aardvark
Copy link
Member

@not-an-aardvark not-an-aardvark commented Mar 4, 2019

The version of ESLint you are using.

v5.15.0

The problem you want to solve.

As of v5.14.0, we allow rule schemas to include the default keyword to specify default options. However, it's easy for a rule author to inadvertently use the default keyword in a place where the keyword is ignored, resulting in a buggy rule. (Also see: #11427)

Your take on the correct solution to problem.

When we validate rule schemas in RuleTester, we should use the new strictDefaults option in Ajv to raise an error if a rule schema has an invalid default keyword.

This is a breaking change for users who use RuleTester, because RuleTester would sometimes start reporting additional validation errors. However, rules themselves would still work as before, even if they contain invalid defaults. Additionally, the impact is expected to be very low since we only added support for the default keyword recently.

Are you willing to submit a pull request to implement this change?

Yes

@aladdin-add
Copy link
Member

@aladdin-add aladdin-add commented Mar 4, 2019

And, we can enable validateSchema: true in rule tester.

eslint/lib/util/ajv.js

Lines 18 to 25 in b00a5e9

const ajv = new Ajv({
meta: false,
useDefaults: true,
validateSchema: false,
missingRefs: "ignore",
verbose: true,
schemaId: "auto"
});

Loading

@ilyavolodin ilyavolodin moved this from Needs discussion to Accepted, ready to implement in v6.0.0 Mar 14, 2019
@not-an-aardvark
Copy link
Member Author

@not-an-aardvark not-an-aardvark commented Mar 15, 2019

This proposal was accepted in yesterday's TSC meeting.

Loading

@not-an-aardvark not-an-aardvark moved this from Accepted, ready to implement to Implemented, pending review in v6.0.0 Apr 7, 2019
v6.0.0 automation moved this from Implemented, pending review to Done Apr 9, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
v6.0.0
  
Done
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants