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 --options to find unused options #284

Open
ljharb opened this issue Aug 23, 2017 · 5 comments
Open

add --options to find unused options #284

ljharb opened this issue Aug 23, 2017 · 5 comments

Comments

@ljharb
Copy link
Collaborator

ljharb commented Aug 23, 2017

I'd like to run a command that ensures that for all rules I have defined, I've defined every possible compatible schema option.

For example, for the "indent" rule, http://eslint.org/docs/rules/indent points out that it can have an object option with 12 different options. I'd like a report, for that rule, of any of the 12 I've omitted in my config.

@ta2edchimp
Copy link
Collaborator

Uh, that's a nice idea 👍

The rules' meta property exposes all the required information about the schema of a rule:

eslint.linter.getRules().get('indent').meta.schema

@preco21
Copy link

preco21 commented Dec 12, 2019

Hi, I'm now analyzing the code for this feature, but I just stuck because I have no idea what is the proper way to display such unused options as an output. For example, you have only specified the first argument (off, error, ...) in a rule which can accept bunch of additional and also nested options.

In this case, what would be the best to show on the output? I guess only first level of the options would be sufficient for everyone:

NOTE: The user may need to provide a value to rest of the options to clear the output.

unused options (only first level of full options shown)

indent: [0] -> 'tab' | number, [1] -> {SwitchCase, FooBar, ...} // ['error', 'tab', {SwitchCase, ...}]
padding-line-between-statements: [] -> {blankLine, prev, next} // ['error', {blankLine,prev,next}, ...]

@ljharb
Copy link
Collaborator Author

ljharb commented Dec 12, 2019

Just the names of the options and the rule, and the link to the rule docs, would be sufficient for me.

@preco21
Copy link

preco21 commented Dec 12, 2019

Is there an example of what “names of the options and the rule” would look like?

For example: https://eslint.org/docs/rules/indent

In a rule like “indent”, it may not only accept an object as a options, but also accept primitive values like “tab” or 8 along with other options. What would be the best way to deal with this case? Since a primitive value cannot describe its name unlike a key of an object, I guess showing its value type would be okay.

And there may be nested options where some object can contain another object, what would be the output in this case?

@ljharb
Copy link
Collaborator Author

ljharb commented Dec 12, 2019

I’d be interested in the kinds of options unset, but not their potential values unless it’s an enum or a boolean. In the case of indent, the object option keys is what I’m most interested in.

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

No branches or pull requests

3 participants