Skip to content

Fix: disallow extra properties in rule options - #265

Open
andreww2012 wants to merge 1 commit into
mozilla:mainfrom
andreww2012:fix/disallow-extra-properties-in-rule-options
Open

Fix: disallow extra properties in rule options#265
andreww2012 wants to merge 1 commit into
mozilla:mainfrom
andreww2012:fix/disallow-extra-properties-in-rule-options

Conversation

@andreww2012

Copy link
Copy Markdown

Plugin rules currently allow extra properties to be passed in options object in certain places, which should not be allowed. This makes it easier for typos in rule options to go unnoticed.

This PR simply disallows extra properties in rules' schemas which currently allow them.

@mozfreddyb

Copy link
Copy Markdown
Collaborator

Can you write tests that lead to failures when additional properties are supplied?

@andreww2012

Copy link
Copy Markdown
Author

I'm not sure how one would write such tests using RuleTester, but I think they aren't necessary, because this is the internal ESLint behavior that always throws an error if supplied options do not satisfy the rule's JSON schema, and I would imagine that was not expected to be tested by plugin authors. There exist a lot of ESLint plugins and I believe no ones is testing that behavior.

@mozfreddyb

Copy link
Copy Markdown
Collaborator

I'm not super enthusiastic about a pull request that is not testable. Can anyone else think of something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants