sarbbottam / eslint-find-rules

Find built-in ESLint rules you don't have in your custom config
http://npm.im/eslint-find-rules
MIT License
206 stars 36 forks source link

Can't show only unused plugin rules + duplicated output #291

Closed alexilyaev closed 6 years ago

alexilyaev commented 6 years ago

Using this:

eslint-find-rules -u -p .eslintrc --no-core

Results in this:

plugin rules

jest/consistent-test-it            jest/lowercase-name                jest/no-disabled-tests             jest/no-focused-tests
jest/no-hooks                      jest/no-identical-title            jest/no-jest-import                jest/no-large-snapshots
jest/no-test-prefixes              jest/prefer-expect-assertions      jest/prefer-to-be-null             jest/prefer-to-be-undefined
jest/prefer-to-have-length         jest/valid-describe                jest/valid-expect                  jest/valid-expect-in-promise
lodash/callback-binding            lodash/chain-style                 lodash/chaining                    lodash/collection-method-value
lodash/collection-return           lodash/consistent-compose          lodash/identity-shorthand          lodash/import-scope
lodash/matches-prop-shorthand      lodash/matches-shorthand           lodash/no-commit                   lodash/no-double-unwrap
lodash/no-extra-args               lodash/no-unbound-this             lodash/path-style                  lodash/prefer-compact
lodash/prefer-constant             lodash/prefer-filter               lodash/prefer-flat-map             lodash/prefer-get
lodash/prefer-includes             lodash/prefer-invoke-map           lodash/prefer-is-nil               lodash/prefer-lodash-chain
lodash/prefer-lodash-method        lodash/prefer-lodash-typecheck     lodash/prefer-map                  lodash/prefer-matches
lodash/prefer-noop                 lodash/prefer-over-quantifier      lodash/prefer-reject               lodash/prefer-some
lodash/prefer-startswith           lodash/prefer-thru                 lodash/prefer-times                lodash/prefer-wrapper-method
lodash/preferred-alias             lodash/prop-shorthand              lodash/unwrap                      promise/always-return
promise/avoid-new                  promise/catch-or-return            promise/no-callback-in-promise     promise/no-native
promise/no-nesting                 promise/no-new-statics             promise/no-promise-in-callback     promise/no-return-in-finally
promise/no-return-wrap             promise/param-names                promise/prefer-await-to-callbacks  promise/prefer-await-to-then
promise/valid-params

plugin rules

jest/consistent-test-it            jest/lowercase-name                jest/no-disabled-tests             jest/no-focused-tests
jest/no-hooks                      jest/no-identical-title            jest/no-jest-import                jest/no-large-snapshots
jest/no-test-prefixes              jest/prefer-expect-assertions      jest/prefer-to-be-null             jest/prefer-to-be-undefined
jest/prefer-to-have-length         jest/valid-describe                jest/valid-expect                  jest/valid-expect-in-promise
lodash/callback-binding            lodash/chain-style                 lodash/chaining                    lodash/collection-method-value
lodash/collection-return           lodash/consistent-compose          lodash/identity-shorthand          lodash/import-scope
lodash/matches-prop-shorthand      lodash/matches-shorthand           lodash/no-commit                   lodash/no-double-unwrap
lodash/no-extra-args               lodash/no-unbound-this             lodash/path-style                  lodash/prefer-compact
lodash/prefer-constant             lodash/prefer-filter               lodash/prefer-flat-map             lodash/prefer-get
lodash/prefer-includes             lodash/prefer-invoke-map           lodash/prefer-is-nil               lodash/prefer-lodash-chain
lodash/prefer-lodash-method        lodash/prefer-lodash-typecheck     lodash/prefer-map                  lodash/prefer-matches
lodash/prefer-noop                 lodash/prefer-over-quantifier      lodash/prefer-reject               lodash/prefer-some
lodash/prefer-startswith           lodash/prefer-thru                 lodash/prefer-times                lodash/prefer-wrapper-method
lodash/preferred-alias             lodash/prop-shorthand              lodash/unwrap                      promise/always-return
promise/avoid-new                  promise/catch-or-return            promise/no-callback-in-promise     promise/no-native
promise/no-nesting                 promise/no-new-statics             promise/no-promise-in-callback     promise/no-return-in-finally
promise/no-return-wrap             promise/param-names                promise/prefer-await-to-callbacks  promise/prefer-await-to-then
promise/valid-params

unused rules

jest/lowercase-name                jest/no-hooks                      jest/no-jest-import                jest/no-test-prefixes
promise/no-new-statics             promise/prefer-await-to-callbacks  promise/prefer-await-to-then       promise/valid-params

Reproduce

ta2edchimp commented 6 years ago

Thanks for bringing this to our attention!

As for the duplicated output regarding the plugin rules, this is an issue pretty easy to fix. I'll see if I can get a bugfix PR up tomorrow.
(The statement to actually print out the collected output should move out of its current location, because it gets invoked multiple times in the loop.)

When you only want to print out rules that are "unused" and "plugin rules", shifting the query a little bit, to only show "unused" and "not core rules" should suffice:
e.g. eslint-find-rules --unused --no-core .eslintrc

alexilyaev commented 6 years ago

Oh, I see, it works, though it wasn't clear from the README.

At first I thought -u would only show the unused rules, but it makes sense to separate each flag to it's own output, gives more flexibility.

ta2edchimp commented 6 years ago

Yes, there's definitely room for improvement regarding the README's description.
I also hope to get the rework for the parameter parsing with yargs done soon, that should help with ambiguous sounding flags.