eslint-find-rules
Advanced tools
Comparing version 1.11.1 to 1.12.0
{ | ||
"name": "eslint-find-rules", | ||
"version": "1.11.1", | ||
"version": "1.12.0", | ||
"description": "Find built-in ESLint rules you don't have in your custom config.", | ||
@@ -5,0 +5,0 @@ "main": "src/lib/rule-finder.js", |
@@ -11,2 +11,3 @@ #!/usr/bin/env node | ||
n: ['no-error'], | ||
nc: ['no-core'], | ||
verbose: ['verbose', 'v'], | ||
@@ -26,3 +27,3 @@ } | ||
var ruleFinder = getRuleFinder(specifiedFile) | ||
var ruleFinder = getRuleFinder(specifiedFile, argv.core === false) | ||
@@ -29,0 +30,0 @@ if (!argv.c && !argv.p && !argv.a && !argv.u) { |
@@ -87,3 +87,7 @@ var path = require('path') | ||
function RuleFinder(specifiedFile) { | ||
function _isNotCore(rule) { | ||
return rule.indexOf('/') !== '-1' | ||
} | ||
function RuleFinder(specifiedFile, noCore) { | ||
var configFile = _getConfigFile(specifiedFile) | ||
@@ -93,4 +97,7 @@ var config = _getConfig(configFile) | ||
var pluginRules = _getPluginRules(config) | ||
var allRules = _getAllAvailableRules(pluginRules) | ||
var unusedRules = difference(allRules, currentRules) | ||
var allRules = noCore ? pluginRules : _getAllAvailableRules(pluginRules) | ||
if (noCore) { | ||
currentRules = currentRules.filter(_isNotCore) | ||
} | ||
var unusedRules = difference(allRules, currentRules) // eslint-disable-line vars-on-top | ||
@@ -123,4 +130,4 @@ // get all the current rules instead of referring the extended files or documentation | ||
module.exports = function getRuleFinder(specifiedFile) { | ||
return new RuleFinder(specifiedFile) | ||
module.exports = function getRuleFinder(specifiedFile, noCore) { | ||
return new RuleFinder(specifiedFile, noCore) | ||
} |
@@ -86,2 +86,11 @@ var path = require('path') | ||
it('no specifiedFile - all available rules without core', function() { | ||
var ruleFinder | ||
process.cwd = function() { | ||
return noSpecifiedFile | ||
} | ||
ruleFinder = getRuleFinder(null, true) | ||
assert.deepEqual(ruleFinder.getAllAvailableRules(), []) | ||
}) | ||
it('specifiedFile (relative path) is passed to the constructor', function() { | ||
@@ -140,3 +149,17 @@ var ruleFinder = getRuleFinder(specifiedFileRelative) | ||
it('specifiedFile (absolut path) is passed to the constructor', function() { | ||
it('specifiedFile (relative path) - all available rules without core', function() { | ||
var ruleFinder = getRuleFinder(specifiedFileRelative, true) | ||
assert.deepEqual( | ||
ruleFinder.getAllAvailableRules(), | ||
[ | ||
'plugin/bar-rule', | ||
'plugin/baz-rule', | ||
'plugin/foo-rule', | ||
'scoped-plugin/bar-rule', | ||
'scoped-plugin/foo-rule', | ||
] | ||
) | ||
}) | ||
it('specifiedFile (absolute path) is passed to the constructor', function() { | ||
var ruleFinder = getRuleFinder(specifiedFileAbsolute) | ||
@@ -152,3 +175,3 @@ assert.deepEqual(ruleFinder.getUnusedRules(), [ | ||
it('specifiedFile (absolut path) - current rules', function() { | ||
it('specifiedFile (absolute path) - current rules', function() { | ||
var ruleFinder = getRuleFinder(specifiedFileAbsolute) | ||
@@ -158,3 +181,3 @@ assert.deepEqual(ruleFinder.getCurrentRules(), ['bar-rule', 'foo-rule', 'scoped-plugin/foo-rule']) | ||
it('specifiedFile (absolut path) - current rule config', function() { | ||
it('specifiedFile (absolute path) - current rule config', function() { | ||
var ruleFinder = getRuleFinder(specifiedFileAbsolute) | ||
@@ -168,3 +191,3 @@ assert.deepEqual(ruleFinder.getCurrentRulesDetailed(), { | ||
it('specifiedFile (absolut path) - plugin rules', function() { | ||
it('specifiedFile (absolute path) - plugin rules', function() { | ||
var ruleFinder = getRuleFinder(specifiedFileAbsolute) | ||
@@ -180,3 +203,3 @@ assert.deepEqual(ruleFinder.getPluginRules(), [ | ||
it('specifiedFile (absolut path) - all available rules', function() { | ||
it('specifiedFile (absolute path) - all available rules', function() { | ||
var ruleFinder = getRuleFinder(specifiedFileAbsolute) | ||
@@ -183,0 +206,0 @@ assert.deepEqual( |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43729
913