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

refactor(find): Use new eslint getRules() api #237

Merged
merged 1 commit into from
May 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@
"contributions": [
"code"
]
},
{
"login": "randycoulman",
"name": "Randy Coulman",
"avatar_url": "https://avatars1.githubusercontent.com/u/1406203?v=3",
"profile": "https://github.com/randycoulman",
"contributions": [
"code", "test"
]
}
]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"codecov": "1.0.1",
"commitizen": "2.8.6",
"cz-conventional-changelog": "1.2.0",
"eslint": "3.5.0",
"eslint": "3.12.0",
"ghooks": "1.3.2",
"mocha": "^3.0.1",
"npm-run-all": "3.1.0",
Expand All @@ -60,7 +60,7 @@
"xo": "^0.17.0"
},
"peerDependencies": {
"eslint": "^2.0.0 || ^3.0.0"
"eslint": "^3.12.0"
},
"nyc": {
"exclude": [
Expand Down
17 changes: 4 additions & 13 deletions src/lib/rule-finder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path');
const fs = require('fs');

const eslint = require('eslint');
const isAbsolute = require('path-is-absolute');
Expand Down Expand Up @@ -68,18 +67,10 @@ function _getPluginRules(config) {
}

function _getAllAvailableRules(pluginRules) {
const allRules = fs
.readdirSync('./node_modules/eslint/lib/rules');
let filteredAllRules = [];
allRules.forEach(filename => {
if (filename.slice(-3) === '.js') {
filteredAllRules.push(filename.replace(/\.js$/, ''));
}
});

filteredAllRules = filteredAllRules.concat(pluginRules);

return filteredAllRules;
return [
...eslint.linter.getRules().keys(),
...pluginRules
];
}

function _isNotCore(rule) {
Expand Down
11 changes: 8 additions & 3 deletions test/lib/rule-finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ const proxyquire = require('proxyquire');
const processCwd = process.cwd;

const getRuleFinder = proxyquire('../../src/lib/rule-finder', {
fs: {
readdirSync() {
return ['.eslintrc.yml', 'foo-rule.js', 'bar-rule.js', 'baz-rule.js'];
eslint: {
linter: {
getRules() {
return new Map()
.set('foo-rule', {})
.set('bar-rule', {})
.set('baz-rule', {});
}
}
},
'eslint-plugin-plugin': {
Expand Down