UNPKG

6.71 kBMarkdownView Raw
1# eslint-find-rules
2
3[![Join the chat at https://gitter.im/sarbbottam/eslint-find-rules](https://badges.gitter.im/sarbbottam/eslint-find-rules.svg)](https://gitter.im/sarbbottam/eslint-find-rules?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
5Use this for your own [ESLint](http://eslint.org/) [shareable configuration](http://eslint.org/docs/developer-guide/shareable-configs)
6to list current configured rules, all-available rules, unused rules, and plugin rules.
7
8[![Build Status](https://img.shields.io/travis/sarbbottam/eslint-find-rules.svg?style=flat-square)](https://travis-ci.org/sarbbottam/eslint-find-rules)
9[![Code Coverage](https://img.shields.io/codecov/c/github/sarbbottam/eslint-find-rules.svg?style=flat-square)](https://codecov.io/github/sarbbottam/eslint-find-rules)
10[![version](https://img.shields.io/npm/v/eslint-find-rules.svg?style=flat-square)](http://npm.im/eslint-find-rules)
11[![downloads](https://img.shields.io/npm/dm/eslint-find-rules.svg?style=flat-square)](http://npm-stat.com/charts.html?package=eslint-find-rules&from=2015-08-01)
12[![MIT License](https://img.shields.io/npm/l/eslint-find-rules.svg?style=flat-square)](http://opensource.org/licenses/MIT)
13[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
14[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors)
15
16## Acknowledgment
17
18This module is an extended version of [eslint-find-new-rules](https://github.com/kentcdodds/eslint-find-new-rules)
19
20## Installation
21
22Simply install locally as a development dependency to your project's package:
23
24```
25npm install --save-dev eslint-find-rules
26```
27
28## Usage
29
30> It is expected to be used as `local` utility, as it needs `eslint` and the `eslint-plugins` being referred by the `eslint-config` file, to be installed.
31Using it as a `global` utility, will error out, if `eslint` and the `eslint-plugins` being referred by the `eslint-config` file, are not installed globally.
32
33The intended usage is as an npm script:
34
35```javascript
36{
37 ...
38 "scripts": {
39 "eslint-find-option-rules": "eslint-find-rules [option] <file> [flag]"
40 }
41 ...
42}
43```
44
45```
46available options are -c|--current, -a|--all-available, -p|--plugin, -u|--unused
47available flag is -n|--no-error
48```
49
50By default it will error out only for `-u|--unused`,
51however if you do not want the `process` to `exit` with a `non-zero` exit code, use the `-n|--no-error` along with `-u|--unused`
52
53Then run it with: `$ npm run eslint-find-option-rules -s` (the `-s` is to silence npm output).
54
55### Specify a file
56
57This is really handy in an actual config module (like [eslint-config-kentcdodds](https://github.com/kentcdodds/eslint-config-kentcdodds)) where you could also do:
58
59```
60// available options are -c|--current, -a|--all-available, -p|--plugin, -u|--unused
61eslint-find-rules --option ./index.js
62```
63
64This is resolved, relative to the `process.cwd()` which, in the context of `npm` scripts is always the location of your `package.json`.
65
66You may specify any [config format supported by ESLint](http://eslint.org/docs/user-guide/configuring).
67
68### Absolute Path
69
70You can also provide an absolute path:
71
72```
73eslint-find-rules --option ~/Developer/eslint-config-kentcdodds/index.js
74```
75
76**Please note** that any tested ESLint config file must reside below your project's root.
77
78### Default to `main`
79
80It will also default to the `main` in your `package.json`, so you can omit the `path/to/file` argument:
81
82```
83eslint-find-rules --option
84```
85
86### As a `require`d module
87
88```
89var getRuleFinder = require('./eslint-find-rules')
90var ruleFinder = getRuleFinder('path/to/eslint-config')
91
92// default to the `main` in your `package.json`
93// var ruleFinder = getRuleFinder()
94
95// get all the current, plugin, available and unused rules
96// without referring the extended files or documentation
97
98ruleFinder.getCurrentRules()
99
100ruleFinder.getCurrentRulesDetailed()
101
102ruleFinder.getPluginRules()
103
104ruleFinder.getAllAvailableRules()
105
106ruleFinder.getUnusedRules()
107```
108
109### Log the difference between two config files
110
111```javascript
112{
113 ...
114 "scripts": {
115 "eslint-diff-rules": "eslint-diff-rules <file1> <file2>"
116 }
117 ...
118}
119```
120
121## Contributors
122
123Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
124
125<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
126| [![Sarbbottam Bandyopadhyay](https://avatars1.githubusercontent.com/u/949380?v=3&s=100)<br /><sub>Sarbbottam Bandyopadhyay</sub>](https://twitter.com/sarbbottam)<br />[💻](https://github.com/sarbbottam/eslint-find-rules/commits?author=sarbbottam) [📖](https://github.com/sarbbottam/eslint-find-rules/commits?author=sarbbottam) [⚠️](https://github.com/sarbbottam/eslint-find-rules/commits?author=sarbbottam) 👀 | [![Andreas Windt](https://avatars1.githubusercontent.com/u/262436?v=3&s=100)<br /><sub>Andreas Windt</sub>](https://twitter.com/ta2edchimp)<br />[💻](https://github.com/sarbbottam/eslint-find-rules/commits?author=ta2edchimp) [📖](https://github.com/sarbbottam/eslint-find-rules/commits?author=ta2edchimp) [⚠️](https://github.com/sarbbottam/eslint-find-rules/commits?author=ta2edchimp) 👀 | [![Kent C. Dodds](https://avatars3.githubusercontent.com/u/1500684?v=3&s=100)<br /><sub>Kent C. Dodds</sub>](https://twitter.com/kentcdodds)<br />[💻](https://github.com/sarbbottam/eslint-find-rules/commits?author=kentcdodds) [📖](https://github.com/sarbbottam/eslint-find-rules/commits?author=kentcdodds) [⚠️](https://github.com/sarbbottam/eslint-find-rules/commits?author=kentcdodds) 👀 | [![Michał Gołębiowski](https://avatars3.githubusercontent.com/u/1758366?v=3&s=100)<br /><sub>Michał Gołębiowski</sub>](https://github.com/mgol)<br />[💻](https://github.com/sarbbottam/eslint-find-rules/commits?author=mgol) | [![Jeroen Engels](https://avatars.githubusercontent.com/u/3869412?v=3&s=100)<br /><sub>Jeroen Engels</sub>](https://github.com/jfmengels)<br />[📖](https://github.com/sarbbottam/eslint-find-rules/commits?author=jfmengels) | [![Dustin Specker](https://avatars2.githubusercontent.com/u/2449282?v=3&s=100)<br /><sub>Dustin Specker</sub>](https://github.com/dustinspecker)<br />[💻](https://github.com/sarbbottam/eslint-find-rules/commits?author=dustinspecker) |
127| :---: | :---: | :---: | :---: | :---: | :---: |
128<!-- ALL-CONTRIBUTORS-LIST:END -->
129
130This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification.
131Contributions of any kind welcome!
132
133Special thanks to [@mgol](https://github.com/mgol) who created the original script.
134
135## LICENSE
136
137MIT