eslint-plugin-indexof
Advanced tools
Comparing version 0.0.0 to 0.1.0
@@ -10,8 +10,2 @@ /** | ||
//------------------------------------------------------------------------------ | ||
// Requirements | ||
//------------------------------------------------------------------------------ | ||
var requireIndex = require("requireindex"); | ||
//------------------------------------------------------------------------------ | ||
// Plugin Definition | ||
@@ -22,5 +16,7 @@ //------------------------------------------------------------------------------ | ||
// import all rules in lib/rules | ||
module.exports.rules = requireIndex("./rules"); | ||
module.exports.rules = { | ||
"no-indexof": require("./rules/no-indexof.js") | ||
} | ||
@@ -18,5 +18,9 @@ /** | ||
function isMethodCall(node) { | ||
return !!node.callee.property; | ||
} | ||
return { | ||
CallExpression: function (node) { | ||
if(node.callee.property.name === 'indexOf'){ | ||
if(isMethodCall(node) && node.callee.property.name === 'indexOf'){ | ||
if(exceptOn.indexOf(node.callee.object.name) < 0) { | ||
@@ -23,0 +27,0 @@ context.report(node, "Unexpected indexOf"); |
{ | ||
"name": "eslint-plugin-indexof", | ||
"version": "0.0.0", | ||
"version": "0.1.0", | ||
"description": "Disallow using the method indexOf", | ||
@@ -10,3 +10,3 @@ "keywords": [ | ||
], | ||
"author": "Jordan Eldredge <jordan@jordaneldredge.com>", | ||
"author": "Jordan Eldredge", | ||
"main": "lib/index.js", | ||
@@ -13,0 +13,0 @@ "scripts": { |
@@ -26,3 +26,5 @@ /** | ||
"myArray.myMethod(x);", | ||
{ code: "_.indexOf(myArray, x);", options: [{'exceptOn': ['_']}] } | ||
{ code: "_.indexOf(myArray, x);", options: [{'exceptOn': ['_']}] }, | ||
"indexOf(x);", | ||
"anotherFunction(x);" | ||
], | ||
@@ -29,0 +31,0 @@ invalid: [ { |
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
94
5170