Code Monkey home page Code Monkey logo

eslint-find-rules's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

eslint-find-rules's Issues

Handle typescript-eslint configuration

When it runs in a project containing only ".ts" files (so not any ".js" file) this error occurs:
image

It seems that the issue come from this line :

const files = glob.sync('**/*.js', {dot: true, matchBase: true});

It could be nice to have a way to configure the glob pattern or maybe just the extension part (see --ext option in eslint cli https://eslint.org/docs/user-guide/command-line-interface#options)

Thanks!

Scoped plugin error

When using @typescript-eslint/eslint-plugin I'm getting the error:

Error: Cannot find module 'eslint-plugin-@typescript-eslint'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at /Users/chris/github/eslint-config/node_modules/eslint-find-rules/dist/lib/rule-finder.js:68:26
    at Array.forEach (<anonymous>)
    at _getPluginRules (/Users/chris/github/eslint-config/node_modules/eslint-find-rules/dist/lib/rule-finder.js:66:13)
    at new RuleFinder (/Users/chris/github/eslint-config/node_modules/eslint-find-rules/dist/lib/rule-finder.js:104:21)
    at module.exports (/Users/chris/github/eslint-config/node_modules/eslint-find-rules/dist/lib/rule-finder.js:151:10)
    at Object.<anonymous> (/Users/chris/github/eslint-config/node_modules/eslint-find-rules/dist/bin/find.js:33:18)

Links in output

Atom's linter-eslint project holds a list of plugin and plugin rules documentation location pair (see https://github.com/AtomLinter/linter-eslint/blob/master/lib/helpers.js#L72-L104). Basically: "For eslint plugin X, the documentation for every rule is in https://github.com/Gillespie59/eslint-plugin-X/blob/master/docs/' + ruleName + '.md'.

What do use it for, is at the location where errors are shown, to have a clickable link that opens the browser with the documentation page of that link, which allows you to easily read more about the rule and/or the problem it points out. (in the following screenshot, no-undef is clickable)
image

A while ago, I thought about moving this project to its own repo (that I discussed in one of the points here), and the creators thought it could be a good idea.

I now thought that this could be pretty useful here. Behind an option, there could be new list formatted like this:

accessor-pairs http://eslint.org/docs/rules/accessor-pairs
array-bracket-spacing http://eslint.org/docs/rules/array-bracket-spacing
array-callback-return http://eslint.org/docs/rules/array-callback-return

import/order https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md

which would be clickable in the terminal (hopefully in most terminals, otherwise it's copy-pastable, which is still nice), and allow you to quickly find out about a rule.

Right now, I'm wondering whether you'd be interested by this functionality. And if so, I'll be more interested in working on the new repository the plugins (and maybe even integrate it here) :)
What do you think?

FYI: Currently, as that "list" works, every link for an unknown plugin will redirect to a page to help register it.

Changelog?

I'd love to know what changes between versions without having to read the commit log :-)

A way to not list core rules

Hi all!

I'm updating a eslint config package we use at my company (https://github.com/CoorpAcademy/eslint-plugin-coorpacademy, if you need to know. It's a eslint-plugin rather thant eslint-config because it allows us to bring external dependencies with it), and I'm using this tool to find what rules are new and missing in my config files.

We have a core config, which configures all core ESLint rules, and I can use eslint-find-rules --unused ./config/core.js to get the list of missing rules, works great here πŸ‘, it even includes the missing rules in the plugins I declared in the file.

We also have multiple configs for certain cases, to activate on each project depending on the needs, mostly focused on the libraries we use, for instance mocha and AVA. For those plugins, I'd like to get the list of missing rules, but only for the plugins that I declared in that configuration, and not the core rules, as I have defined them in another file anyway.

When doing eslint-find-rules --plugin ./config/ava.js, it prints all rules, but not the unused ones.
When doing eslint-find-rules --unused ./config/ava.js, it prints all missing rules, but also the core ESLint rules.
When doing eslint-find-rules --unused --plugin ./config/ava.js, it prints all rules, and the plugin rules twice.

Having the core rules listed causes two problems for me:

  • It's hard to find whether or not I actually have missing rules in the big blob of text
  • The command exits with an error code, meaning I can't chain commands like eslint-find-rules --unused ./config/ava.js && eslint-find-rules --unused ./config/mocha.js && ...

In short, what I'd like to have is a mean to not list core rules. Maybe something like --no-core?

Thanks a lot for the tool by the way :)

auto-merge and semantic release

@sarbbottam: Please don't approve it via GitHub means, otherwise, the PR will get merged

@ljharb: @sarbbottam i'd strongly caution against automerging on PR approval; i don't even think semantic-release is a safe idea.

@sarbbottam:@ljharb I guess I was wrong about auto-merging. It is not enabled. I had to merge #199 by myself.

I'd strongly caution against auto-merging on PR approval;

Agreed

semantic-release

Yea, it could be problematic sometimes, but has its benefits too. I am a bit biased but would be OK to let it go, if we all think so.

@ta2edchimp: So, is it safe to approve the requested changes? (I never worked with the review feature before ...)

Re: auto merge on review approval

Can we assure this is not activated?

Re: semantic release

Besides "spamming" with updates when lots of PRs would get merged within a short period of time, I see no problem in having automatic releases for this tool. But this is something we should discuss / evaluate in a separate issue.

add `--options` to find unused options

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.

Release?

I would be better to release this package asap, if we consider its current state is good enough for MVP

Then we have to put a deprecation notice to eslint-find-new-rules and point it to this one.

Other wise we may end up addressing the same issues, in both the repo.

Moved from my user?

Did we discuss this? It's no big deal, but it was just a bit surprising and probably unnecessary....

Error after update to latest version

/home/travis/build/itgalaxy/eslint-plugin-itgalaxy/node_modules/define-property/index.js:14
     throw new TypeError('expected an object or function.');
     ^
 
 TypeError: expected an object or function.
     at defineProperty (/home/travis/build/itgalaxy/eslint-plugin-itgalaxy/node_modules/define-property/index.js:14:11)
     at Object.<anonymous> (/home/travis/build/itgalaxy/eslint-plugin-itgalaxy/node_modules/window-size/index.js:125:1)
     at Module._compile (module.js:571:32)
     at Object.Module._extensions..js (module.js:580:10)
     at Module.load (module.js:488:32)
     at tryModuleLoad (module.js:447:12)
     at Function.Module._load (module.js:439:3)
     at Module.require (module.js:498:17)
     at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/travis/build/itgalaxy/eslint-plugin-itgalaxy/node_modules/eslint-find-rules/dist/lib/cli-util.js:5:12)

--no-error still outputs errors

This works for me as an npm script:

    "efr": "eslint-find-rules --unused ~/.eslintrc -n"

This does not work. It outputs errors despite the --no-error flag.

    "efr": "eslint-find-rules --unused ~/.eslintrc --noerror"

I don't understand why it outputs errors anyway though.

Feature: Verbose output

Add a --verbose option. When used, print for example when there's no rule unconfigured (atm. this has no output at all).

We could easily make use npm-log for this.

Don't require to specify deprecated rules

Currently the command eslint-find-rules -u ends with an error if you don't specify deprecated rules. Ideally that wouldn't be required; currently I just put them in a separate section and disable but that means my config will be broken as soon as those rules are removed which doesn't seem necessary.

I'm not sure if ESLint returns enough data to make it possible; if not we could make it happen upstream first.

Update information

README.md

  • badges
  • description
  • acknowledgement to the original module
  • add gitter room link

Repo

  • change the repo's description
    • will be updated once #11 is merged

Colorized output

... what do you think about the idea of colorising the verbose diff output? In case it's a lot, printed on screen, I think it would definitely help getting the major differences at first glance ...
~ @ta2edchimp

'extends: eslint:recommended' causes *all* rules to be considered used

Take the following minimal .eslintrc.yaml:

extends: eslint:recommended

When I run eslint-find-rules -c .eslintrc.yaml it dumps a list of every eslint rule, which is extremely unhelpful.

I think the problem here is that eslint:recommended is implemented by setting the value for non-recommended rules to off instead of leaving them out. The only workaround I can think of for this is to explicitly mask out eslint:recommended and then later fill them back in. However, this seems like a bit of a bodge; is there a better way to do this?

The alternative is to add a flag such as --off-is-unused to consider any rules which have been turned off to be unused. Of course, that would prevent rules from being removed from the list.

Add support to filter rules by ESLint rule meta category

For example, the ESLint getter-return rule shipped in ESLint 4.2

This rule is not included in the ESLint recommended config but is listed in the Possible Errors category: https://github.com/eslint/eslint/blob/master/lib/rules/getter-return.js#L49

Currently if I run eslint-find-rules --unused --no-error on my shared config this returns ~40 rules that I don't use and have no plans on using.

It'd be great if I could do eslint-find-rules --unused --no-error --category possible-errors, that would make it super easy to run after updating ESLint to determine if any new Possible Errors rules have shipped in ESLint.

Can't show only unused plugin rules + duplicated output

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

Unhelpful error messages?

npx eslint-find-rules help
npx: installed 71 in 13.549s
Cannot find module 'eslint'
npx eslint-find-rules -h
npx: installed 71 in 12.818s
Cannot find module 'eslint'
npx eslint-find-rules .
Cannot read config file: /Users/krainboltgreene/Code/unctionjs/selectValues
Error: EISDIR: illegal operation on a directory, read
npx eslint-find-rules --help
ESLint configuration in /Users/krainboltgreene/Code/unctionjs/selectValues/transpiled/index.js is invalid:
	- Unexpected top-level property "default".

Security warning for "mem"

WS-2018-0236 More information
moderate severity
Vulnerable versions: < 4.0.0
Patched version: 4.0.0
In nodejs-mem before version 4.0.0 there is a memory leak due to old results not being removed from the cache despite reaching maxAge. Exploitation of this can lead to exhaustion of memory and subsequent denial of service.

npm ls mem shows:

└─┬ [email protected]
  └─┬ [email protected]
    └─┬ [email protected]
      └── [email protected] 

Use chalk to underline urls

We now output urls in verbose mode, but it's not necessarily always very clear that they are urls (it's a big blob of text at first glance, especially when the terminal is not very big)

image

I just discovered Zeit's now, which outputs urls this way:
image
(it's even clearer when I hover the url in my terminal, but don't know how to make a screenshot of that on my computer)

and I found that this is the way it does that, using chalk.

I don't know what you think, but this looks to me like a nice addition to the tool :)

Breaking change in minor version

So, first, 93a68b6 is a breaking change, and should not have been released as a minor version.

Second, it is failing for me when run as a local utility. Using npm run-scripts, eslint-find-rules can be invoked directly, since npm puts it in the PATH - so your method of determining "is global" is flawed.

print as list

Please add option to print as a list - each rule in one line.

Exit status

Currently exit status is 0, the original module used process.exit(1), I removed that on purpose, I did not want the error to scroll past the viewport.

Should there be an option --exit=1 default to 0?
May be in CI environment exit status is 1?

Thoughts?

Report deprecated rules that are in use

In addition to #172, which would keep eslint-find-rules from reporting errors when deprecated rules are unused, it might also be nice to have a command-line option that shows deprecated rules that are still being used in a configuration.

How can I use this on my project, not on my shareable config?

My project has a non-shareable config. I was hoping for a workflow where I install this globally and do

$ eslint-find-rules .eslintrc.json

and it shows me which rules I haven't configured. However, this failed in two ways:

  • First, it wouldn't work until I also globally installed eslint. That's sad.
  • Second, even after I did that, it always output nothing. I tried deleting random rules from my config, and nothing happened.

Update: Contributors in package.json

While I think the author on a package's page in npmjs.org is determined by the user doing the initial publication, I wonder if we should update at least the contributors field in package.json.

Should the package name be `eslint-find-rules`

Should the package name be eslint-find-rules? Similar to its predecessor eslint-find-new-rules?

Not sure, but I guess
eslint-find-rules [option] <filename>
it sounds better than
eslint-rule-finder [option] <filename>

a verb seems better than a noun, in this case.

Thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.