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

Add a reference to context settings and options #1

Merged
merged 6 commits into from
Apr 14, 2018
Merged

Add a reference to context settings and options #1

merged 6 commits into from
Apr 14, 2018

Conversation

dwightjack
Copy link
Contributor

Hi great project!

I'm using this library's filterReports to modify a rule i eslint-plugin-vue but I'd like to be able to access rules' options and global settings.

For what I can understand reading the sourcecode, right now there's no way to access those property, so I extracted them from the context object and exposed them on the metadata object.

@dwightjack
Copy link
Contributor Author

As reference here is the implementation or the extended rule: https://github.com/dwightjack/eslint-plugin-vue-types/blob/develop/lib/rules/require-default-prop.js

Copy link
Owner

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request! Can you update the documentation in README.md to note these new properties?

@dwightjack
Copy link
Contributor Author

@not-an-aardvark Thanks for the review.

Added documentation and tests as well.

Copy link
Owner

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

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

Thanks, I left a few minor comments about the documentation.

README.md Outdated
(problem, metadata) => {
const firstToken = metadata.sourceCode.getFirstToken(problem.node);
const whitelist = settings.tokenWhitelist;
return whitelist.includes(value) === false
Copy link
Owner

Choose a reason for hiding this comment

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

Nitpick: Can you replace this with return !whitelist.includes(value)?

README.md Outdated

{
"settings": {
"tokenWhitelist": ["expect", "test"]
Copy link
Owner

Choose a reason for hiding this comment

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

I'm a bit confused about this example -- shouldn't tokenWhitelist be in the rule options rather than settings? It seems like the option is only applicable to this one rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ability to read settings for the configuration is provided to make it possibile to setup rules like eslint-plugin-import resolvers.

Maybe the example doesn't fit well and could be confusiong. Any hint on a better example?

Copy link
Owner

@not-an-aardvark not-an-aardvark Apr 9, 2018

Choose a reason for hiding this comment

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

To clarify, I agree that it's useful to have access to settings -- I just think this isn't a good example of the utility because this type of configuration would be better in options. (I was initially confused because I didn't see the similar options example above it.)

It's probably not really necessary to have separate examples for options and settings, so it might be simplest to just remove this example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I removed the example and merged the two text descriptions.

Copy link
Owner

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@not-an-aardvark not-an-aardvark merged commit e7312ba into not-an-aardvark:master Apr 14, 2018
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