├── .all-contributorsrc ├── .eslintignore ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── package.json ├── src ├── bin.js └── rule-finder.js └── test ├── fixtures ├── eslint.json ├── eslint.yml ├── eslintrc └── no-path │ ├── index.js │ └── package.json └── rule-finder.js /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "projectOwner": "kentcdodds", 3 | "projectName": "eslint-find-new-rules", 4 | "imageSize": 100, 5 | "contributors": [ 6 | { 7 | "login": "kentcdodds", 8 | "name": "Kent C. Dodds", 9 | "avatar_url": "https://avatars3.githubusercontent.com/u/1500684?v=3", 10 | "profile": "https://twitter.com/kentcdodds", 11 | "contributions": [ 12 | "code", "doc", "test", "review" 13 | ] 14 | }, 15 | { 16 | "login": "mgol", 17 | "name": "Michał Gołębiowski", 18 | "avatar_url": "https://avatars3.githubusercontent.com/u/1758366?v=3", 19 | "profile": "https://github.com/mgol", 20 | "contributions": [ 21 | "code" 22 | ] 23 | }, 24 | { 25 | "login": "sarbbottam", 26 | "name": "Sarbbottam Bandyopadhyay", 27 | "avatar_url": "https://avatars1.githubusercontent.com/u/949380?v=3", 28 | "profile": "https://twitter.com/sarbbottam", 29 | "contributions": [ 30 | "test", "review" 31 | ] 32 | }, 33 | { 34 | "login": "ta2edchimp", 35 | "name": "Andreas Windt", 36 | "avatar_url": "https://avatars1.githubusercontent.com/u/262436?v=3", 37 | "profile": "https://twitter.com/ta2edchimp", 38 | "contributions": [ 39 | "code", "doc", "test" 40 | ] 41 | }, 42 | { 43 | "login": "jfmengels", 44 | "name": "Jeroen Engels", 45 | "avatar_url": "https://avatars.githubusercontent.com/u/3869412?v=3", 46 | "profile": "https://github.com/jfmengels", 47 | "contributions": [ 48 | "doc" 49 | ] 50 | } 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | coverage/ 3 | .nyc_output/ 4 | 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .nyc_output/ 3 | coverage/ 4 | *.log 5 | dist/ 6 | .opt-in 7 | 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | cache: 4 | directories: 5 | - node_modules 6 | notifications: 7 | email: false 8 | node_js: 9 | - '4' 10 | - '0.10' 11 | before_install: 12 | - npm i -g npm@^3.0.0 13 | before_script: 14 | - npm prune 15 | script: 16 | - npm run validate 17 | after_success: 18 | - 'curl -Lo travis_after_all.py https://git.io/travis_after_all' 19 | - python travis_after_all.py 20 | - 'export $(cat .to_export_back) &> /dev/null' 21 | - npm run report-coverage 22 | - npm run semantic-release 23 | branches: 24 | only: 25 | - master 26 | 27 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | **Working on your first Pull Request?** You can learn how from this *free* series 4 | [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github) 5 | 6 | ## Steps 7 | 8 | 1. File an issue and discuss your proposed solution first 9 | 2. Fork and clone the repo 10 | 3. `$ npm install` to install dependencies 11 | 4. `$ npm run validate` to validate you've got it working 12 | 5. Create a branch for your PR 13 | 6. `$ npm run test -- --watch` to watch the file system as you make changes to things 14 | 7. Make your changes. Make sure to add yourself to the `.all-contributorsrc`! [More info](https://github.com/kentcdodds/all-contributors) 15 | 8. Run `npm run validate` to make sure things look good. 16 | 9. Commit your changes following [our standards](https://github.com/stevemao/conventional-changelog-angular/blob/master/convention.md) (optionally use `$ npm run commit` to craft a commit message and commit. If you're having trouble committing, try adding `--no-verify` to your `git commit` command and ask for help in the pull request :-) 17 | 10. Push your branch to your fork 18 | 11. Make a pull request to `master` on this repository 19 | 12. Get merged 20 | 13. Celebrate 🎉 21 | 22 | ## Committing and Pushing changes 23 | 24 | As stated earlier, please follow [this convention](https://github.com/stevemao/conventional-changelog-angular/blob/master/convention.md) for your commit messages. 25 | 26 | Once you are ready to commit the changes, please use the below commands 27 | 28 | 1. `git add ` 29 | 2. `$ npm run commit` 30 | 31 | ... and follow the instruction of the interactive prompt. 32 | 33 | ### Opt into run tests while committing 34 | 35 | `npm run commit` will not execute any `tests`, prior `commit`ing, however you can **opt into it**. 36 | 37 | In order to execute `tests` automatically before `commit`, create a file `.opt-in` in the root of the project with `pre-commit` as the content. 38 | 39 | Excute the following command in the root of the project to create the above stated file. 40 | 41 | `$ echo pre-commit > .opt-in` 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2016 Kent C. Dodds 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # eslint-find-new-rules 2 | 3 | ## Deprecation Notice 4 | 5 | **This module is deprecated in favor of [eslint-find-rules](https://www.npmjs.com/package/eslint-find-rules/)** 6 | 7 | --- 8 | 9 | Use this for your own [ESLint](http://eslint.org/) [shareable configuration](http://eslint.org/docs/developer-guide/shareable-configs) 10 | to identify built-in ESLint rules that you're not explicitly configuring. 11 | 12 | [![Build Status](https://img.shields.io/travis/kentcdodds/eslint-find-new-rules.svg?style=flat-square)](https://travis-ci.org/kentcdodds/eslint-find-new-rules) 13 | [![Code Coverage](https://img.shields.io/codecov/c/github/kentcdodds/eslint-find-new-rules.svg?style=flat-square)](https://codecov.io/github/kentcdodds/eslint-find-new-rules) 14 | [![version](https://img.shields.io/npm/v/eslint-find-new-rules.svg?style=flat-square)](http://npm.im/eslint-find-new-rules) 15 | [![downloads](https://img.shields.io/npm/dm/eslint-find-new-rules.svg?style=flat-square)](http://npm-stat.com/charts.html?package=eslint-find-new-rules&from=2015-08-01) 16 | [![MIT License](https://img.shields.io/npm/l/eslint-find-new-rules.svg?style=flat-square)](http://opensource.org/licenses/MIT) 17 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) 18 | [![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors) 19 | 20 | ## Installation 21 | 22 | Simply install locally as a development dependency to your project's package: 23 | 24 | ``` 25 | npm install --save-dev eslint-find-new-rules 26 | ``` 27 | 28 | ## Usage 29 | 30 | The intended usage is as an npm script: 31 | 32 | ```javascript 33 | { 34 | ... 35 | "scripts": { 36 | "find-new-rules": "eslint-find-new-rules path/to/eslint-config" 37 | } 38 | ... 39 | } 40 | ``` 41 | 42 | Then run it with: `$ npm run find-new-rules -s` (the `-s` is to silence npm output). 43 | 44 | ### Specify a file 45 | 46 | This is really handy in an actual config module (like [mine](https://github.com/kentcdodds/eslint-config-kentcdodds)) where you could also do: 47 | 48 | ``` 49 | eslint-find-new-rules ./index.js 50 | ``` 51 | 52 | This is resolved relative to the `process.cwd()` which, in the context of npm scripts is always the location of your `package.json`. 53 | 54 | You may specify any [config format supported by ESLint](http://eslint.org/docs/user-guide/configuring). 55 | 56 | ### Absolute Path 57 | 58 | You can also provide an absolute path: 59 | 60 | ``` 61 | eslint-find-new-rules ~/Developer/eslint-config-kentcdodds/index.js 62 | ``` 63 | 64 | **Please note** that any tested ESLint config file must reside below your project's root. 65 | 66 | ### Default to `main` 67 | 68 | It will also default to the `main` in your `package.json`, so you can omit the argument altogether: 69 | 70 | ``` 71 | eslint-find-new-rules 72 | ``` 73 | 74 | ### As a `require`d module 75 | 76 | ``` 77 | var getRuleFinder = require('./eslint-find-new-rules') 78 | var ruleFinder = getRuleFinder('path/to/eslint-config') 79 | 80 | // default to the `main` in your `package.json` 81 | // var ruleFinder = getRuleFinder() 82 | 83 | // get all the current, plugin, available and unused rules 84 | // without referring the extended files or documentation 85 | 86 | ruleFinder.getCurrentRules() 87 | 88 | ruleFinder.getPluginRules() 89 | 90 | ruleFinder.getAllAvailableRules() 91 | 92 | ruleFinder.getUnusedRules() 93 | ``` 94 | 95 | ## Contributors 96 | 97 | Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): 98 | 99 | 100 | | [![Kent C. Dodds](https://avatars3.githubusercontent.com/u/1500684?v=3&s=100)
Kent C. Dodds](https://twitter.com/kentcdodds)
[💻](https://github.com/kentcdodds/eslint-find-new-rules/commits?author=kentcdodds) [📖](https://github.com/kentcdodds/eslint-find-new-rules/commits?author=kentcdodds) [⚠️](https://github.com/kentcdodds/eslint-find-new-rules/commits?author=kentcdodds) 👀 | [![Michał Gołębiowski](https://avatars3.githubusercontent.com/u/1758366?v=3&s=100)
Michał Gołębiowski](https://github.com/mgol)
[💻](https://github.com/kentcdodds/eslint-find-new-rules/commits?author=mgol) | [![Sarbbottam Bandyopadhyay](https://avatars1.githubusercontent.com/u/949380?v=3&s=100)
Sarbbottam Bandyopadhyay](https://twitter.com/sarbbottam)
[⚠️](https://github.com/kentcdodds/eslint-find-new-rules/commits?author=sarbbottam) 👀 | [![Andreas Windt](https://avatars1.githubusercontent.com/u/262436?v=3&s=100)
Andreas Windt](https://twitter.com/ta2edchimp)
[💻](https://github.com/kentcdodds/eslint-find-new-rules/commits?author=ta2edchimp) [📖](https://github.com/kentcdodds/eslint-find-new-rules/commits?author=ta2edchimp) [⚠️](https://github.com/kentcdodds/eslint-find-new-rules/commits?author=ta2edchimp) | [![Jeroen Engels](https://avatars.githubusercontent.com/u/3869412?v=3&s=100)
Jeroen Engels](https://github.com/jfmengels)
[📖](https://github.com/kentcdodds/eslint-find-new-rules/commits?author=jfmengels) | 101 | | :---: | :---: | :---: | :---: | :---: | 102 | 103 | 104 | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. 105 | Contributions of any kind welcome! 106 | 107 | Special thanks to [@mgol](https://github.com/mgol) who created the original script. 108 | 109 | ## LICENSE 110 | 111 | MIT 112 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-find-new-rules", 3 | "version": "0.0.0-semantically-released", 4 | "description": "Find built-in ESLint rules you don't have in your custom config.", 5 | "main": "src/rule-finder.js", 6 | "scripts": { 7 | "cover": "nyc --reporter=lcov --reporter=text ava", 8 | "test": "ava", 9 | "lint": "eslint --ignore-pattern test/fixtures .", 10 | "check-kentcdodds": "./bin.js eslint-config-kentcdodds", 11 | "update-contributors": "all-contributors generate", 12 | "commit": "git-cz", 13 | "validate": "npm-run-all --parallel lint cover --sequential check-coverage", 14 | "semantic-release": "semantic-release pre && npm publish && semantic-release post", 15 | "check-coverage": "nyc check-coverage --statements 100 --branches 100 --functions 100 --lines 100", 16 | "report-coverage": "cat ./coverage/lcov.info | node_modules/.bin/codecov" 17 | }, 18 | "bin": { 19 | "eslint-find-new-rules": "src/bin.js" 20 | }, 21 | "keywords": [], 22 | "author": "Michał Gołębiowski ", 23 | "contributors": [ 24 | "Kent C. Dodds (http://kentcdodds.com/)" 25 | ], 26 | "license": "MIT", 27 | "dependencies": { 28 | "lodash.difference": "^4.2.0", 29 | "path-is-absolute": "1.0.0" 30 | }, 31 | "devDependencies": { 32 | "all-contributors-cli": "2.0.0-beta6", 33 | "ava": "0.13.0", 34 | "codecov": "1.0.1", 35 | "commitizen": "2.7.2", 36 | "cz-conventional-changelog": "1.1.5", 37 | "eslint": "2.4.0", 38 | "eslint-config-kentcdodds": "6.0.0", 39 | "ghooks": "1.0.3", 40 | "npm-run-all": "1.5.3", 41 | "nyc": "6.1.1", 42 | "opt-cli": "^1.1.1", 43 | "proxyquire": "1.7.4", 44 | "semantic-release": "4.3.5", 45 | "validate-commit-msg": "2.4.0" 46 | }, 47 | "peerDependencies": { 48 | "eslint": "^2.0.0" 49 | }, 50 | "eslintConfig": { 51 | "extends": "kentcdodds", 52 | "parserOptions": { 53 | "ecmaVersion": 5 54 | }, 55 | "rules": { 56 | "no-var": 0 57 | } 58 | }, 59 | "nyc": { 60 | "exclude": [ 61 | "test/**/*" 62 | ] 63 | }, 64 | "config": { 65 | "ghooks": { 66 | "commit-msg": "validate-commit-msg", 67 | "pre-commit": "opt --in pre-commit --exec \"npm run validate\"" 68 | }, 69 | "commitizen": { 70 | "path": "./node_modules/cz-conventional-changelog" 71 | } 72 | }, 73 | "repository": { 74 | "type": "git", 75 | "url": "https://github.com/kentcdodds/eslint-find-new-rules.git" 76 | }, 77 | "bugs": { 78 | "url": "https://github.com/kentcdodds/eslint-find-new-rules/issues" 79 | }, 80 | "homepage": "https://github.com/kentcdodds/eslint-find-new-rules#readme" 81 | } -------------------------------------------------------------------------------- /src/bin.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 'use strict' 4 | 5 | // Prints rules recognized by ESLint that don't appear in the given config 6 | // preset. It helps with upgrading the preset when new ESLint gets released. 7 | var getRuleFinder = require('./rule-finder') 8 | var specifiedFile = process.argv[2] 9 | var ruleFinder = getRuleFinder(specifiedFile) 10 | 11 | var newRules = ruleFinder.getUnusedRules() 12 | 13 | if (newRules.length) { 14 | console.log('New rules to add to the config: ' + newRules.join(', ') + '.') // eslint-disable-line no-console 15 | process.exit(1) 16 | } 17 | -------------------------------------------------------------------------------- /src/rule-finder.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var fs = require('fs') 3 | 4 | var eslint = require('eslint') 5 | var isAbsolute = require('path-is-absolute') 6 | var difference = require('lodash.difference') 7 | 8 | function _getConfigFile(specifiedFile) { 9 | if (specifiedFile) { 10 | if (isAbsolute(specifiedFile)) { 11 | return specifiedFile 12 | } else { 13 | return path.join(process.cwd(), specifiedFile) 14 | } 15 | } else { 16 | // this is not being called with an arg. Use the package.json `main` 17 | return require(path.join(process.cwd(), 'package.json')).main 18 | } 19 | } 20 | 21 | function _getConfig(configFile) { 22 | var cliEngine = new eslint.CLIEngine({ 23 | // ignore any config applicable depending on the location on the filesystem 24 | useEslintrc: false, 25 | // point to the particular config 26 | configFile: configFile, // eslint-disable-line object-shorthand 27 | }) 28 | return cliEngine.getConfigForFile() 29 | } 30 | 31 | function _getCurrentRules(config) { 32 | return Object.keys(config.rules) 33 | } 34 | 35 | function _getPluginRules(config) { 36 | var pluginRules = [] 37 | var plugins = config.plugins 38 | if (plugins) { 39 | plugins.forEach(function getPluginRule(plugin) { 40 | var pluginConfig = require('eslint-plugin-' + plugin) 41 | var rules = pluginConfig.rules 42 | pluginRules = pluginRules.concat( 43 | Object.keys(rules).map(function normalizePluginRule(rule) { 44 | return plugin + '/' + rule 45 | }) 46 | ) 47 | }) 48 | } 49 | return pluginRules 50 | } 51 | 52 | function _getAllAvailableRules(pluginRules) { 53 | var allRules = fs 54 | .readdirSync('./node_modules/eslint/lib/rules') 55 | .map(function removeJsFromFilename(filename) { 56 | return filename.replace(/\.js$/, '') 57 | }) 58 | 59 | allRules = allRules.concat(pluginRules) 60 | 61 | return allRules 62 | } 63 | 64 | function RuleFinder(specifiedFile) { 65 | var configFile = _getConfigFile(specifiedFile) 66 | var config = _getConfig(configFile) 67 | var currentRules = _getCurrentRules(config) 68 | var pluginRules = _getPluginRules(config) 69 | var allRules = _getAllAvailableRules(pluginRules) 70 | var unusedRules = difference(allRules, currentRules) 71 | 72 | // get all the current rules instead of referring the extended files or documentation 73 | this.getCurrentRules = function getCurrentRules() { 74 | return currentRules 75 | } 76 | 77 | // get all the plugin rules instead of referring the extended files or documentation 78 | this.getPluginRules = function getPluginRules() { 79 | return pluginRules 80 | } 81 | 82 | // get all the available rules instead of referring eslint and plugin packages or documentation 83 | this.getAllAvailableRules = function getAllAvailableRules() { 84 | return allRules 85 | } 86 | 87 | this.getUnusedRules = function getUnusedRules() { 88 | return unusedRules 89 | } 90 | 91 | } 92 | 93 | module.exports = function getRuleFinder(specifiedFile) { 94 | return new RuleFinder(specifiedFile) 95 | } 96 | -------------------------------------------------------------------------------- /test/fixtures/eslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./eslint.yml", 3 | "plugins": [ 4 | "react" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/eslint.yml: -------------------------------------------------------------------------------- 1 | extends: 2 | ./eslintrc 3 | rules: 4 | bar-rule: 5 | - 2 6 | -------------------------------------------------------------------------------- /test/fixtures/eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "foo-rule": [2] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/no-path/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | 'foo-rule': [2] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/no-path/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fake-project", 3 | "version": "0.0.0", 4 | "description": "Simulating a project's package.json.", 5 | "private": true, 6 | "main": "./index.js" 7 | } 8 | -------------------------------------------------------------------------------- /test/rule-finder.js: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | 3 | import test from 'ava' 4 | import proxyquire from 'proxyquire' 5 | 6 | const processCwd = process.cwd 7 | 8 | const getRuleFinder = proxyquire('../src/rule-finder', { 9 | fs: { 10 | readdirSync: () => ['foo-rule.js', 'bar-rule.js', 'baz-rule.js'], 11 | }, 12 | 'eslint-plugin-react': { 13 | rules: { 14 | 'foo-rule': true, 15 | 'bar-rule': true, 16 | 'baz-rule': true, 17 | }, 18 | '@noCallThru': true, 19 | '@global': true, 20 | }, 21 | }) 22 | 23 | const noSpecifiedFile = path.resolve(process.cwd(), './fixtures/no-path') 24 | const specifiedFileRelative = './fixtures/eslint.json' 25 | const specifiedFileAbsolute = path.join(process.cwd(), specifiedFileRelative) 26 | 27 | test.afterEach(() => { 28 | process.cwd = processCwd 29 | }) 30 | 31 | test('no specifiedFile is passed to the constructor', (t) => { 32 | process.cwd = () => noSpecifiedFile 33 | const ruleFinder = getRuleFinder() 34 | t.same(ruleFinder.getUnusedRules(), ['bar-rule', 'baz-rule']) 35 | }) 36 | 37 | test('no specifiedFile - curent rules', (t) => { 38 | process.cwd = () => noSpecifiedFile 39 | const ruleFinder = getRuleFinder() 40 | t.same(ruleFinder.getCurrentRules(), ['foo-rule']) 41 | }) 42 | 43 | test('no specifiedFile - plugin rules', (t) => { 44 | process.cwd = () => noSpecifiedFile 45 | const ruleFinder = getRuleFinder() 46 | t.same(ruleFinder.getPluginRules(), []) 47 | }) 48 | 49 | test('no specifiedFile - all available rules', (t) => { 50 | process.cwd = () => noSpecifiedFile 51 | const ruleFinder = getRuleFinder() 52 | t.same(ruleFinder.getAllAvailableRules(), ['foo-rule', 'bar-rule', 'baz-rule']) 53 | }) 54 | 55 | test('specifiedFile (relative path) is passed to the constructor', (t) => { 56 | const ruleFinder = getRuleFinder(specifiedFileRelative) 57 | t.same(ruleFinder.getUnusedRules(), ['baz-rule', 'react/foo-rule', 'react/bar-rule', 'react/baz-rule']) 58 | }) 59 | 60 | test('specifiedFile (relative path) - curent rules', (t) => { 61 | const ruleFinder = getRuleFinder(specifiedFileRelative) 62 | t.same(ruleFinder.getCurrentRules(), ['foo-rule', 'bar-rule']) 63 | }) 64 | 65 | test('specifiedFile (relative path) - plugin rules', (t) => { 66 | const ruleFinder = getRuleFinder(specifiedFileRelative) 67 | t.same(ruleFinder.getPluginRules(), ['react/foo-rule', 'react/bar-rule', 'react/baz-rule']) 68 | }) 69 | 70 | test('specifiedFile (relative path) - all available rules', (t) => { 71 | const ruleFinder = getRuleFinder(specifiedFileRelative) 72 | t.same( 73 | ruleFinder.getAllAvailableRules(), 74 | ['foo-rule', 'bar-rule', 'baz-rule', 'react/foo-rule', 'react/bar-rule', 'react/baz-rule'] 75 | ) 76 | }) 77 | 78 | test('specifiedFile (absolut path) is passed to the constructor', (t) => { 79 | const ruleFinder = getRuleFinder(specifiedFileAbsolute) 80 | t.same(ruleFinder.getUnusedRules(), ['baz-rule', 'react/foo-rule', 'react/bar-rule', 'react/baz-rule']) 81 | }) 82 | 83 | test('specifiedFile (absolut path) - curent rules', (t) => { 84 | const ruleFinder = getRuleFinder(specifiedFileAbsolute) 85 | t.same(ruleFinder.getCurrentRules(), ['foo-rule', 'bar-rule']) 86 | }) 87 | 88 | test('specifiedFile (absolut path) - plugin rules', (t) => { 89 | const ruleFinder = getRuleFinder(specifiedFileAbsolute) 90 | t.same(ruleFinder.getPluginRules(), ['react/foo-rule', 'react/bar-rule', 'react/baz-rule']) 91 | }) 92 | 93 | test('specifiedFile (absolut path) - all available rules', (t) => { 94 | const ruleFinder = getRuleFinder(specifiedFileAbsolute) 95 | t.same( 96 | ruleFinder.getAllAvailableRules(), 97 | ['foo-rule', 'bar-rule', 'baz-rule', 'react/foo-rule', 'react/bar-rule', 'react/baz-rule'] 98 | ) 99 | }) 100 | --------------------------------------------------------------------------------