eslint-plugin-ban
Advanced tools
Comparing version 1.5.3 to 1.6.0
@@ -125,2 +125,8 @@ /** | ||
const foundRule = banRulesWidthFunctionDefinitions.find((rule) => { | ||
//console.log(rule.name[0]); | ||
if (rule.name[1] && rule.name[1] === ALL_OBJECTS) { | ||
const isO = rule.name[0] === onObject; | ||
if (isO) return true; | ||
} | ||
const isForAllObject = rule.name[0] === ALL_OBJECTS; | ||
@@ -127,0 +133,0 @@ const isForCurrentObject = rule.name[0] === onObject; |
{ | ||
"name": "eslint-plugin-ban", | ||
"version": "1.5.3", | ||
"version": "1.6.0", | ||
"description": "Allows you to bannish some methods or functions.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -27,9 +27,6 @@ # eslint-plugin-ban [![Build Status](https://travis-ci.org/remithomas/eslint-plugin-ban.svg?branch=master)](https://travis-ci.org/remithomas/eslint-plugin-ban) [![npm version](https://img.shields.io/npm/v/eslint-plugin-ban.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-ban) | ||
{ | ||
"plugins": [ | ||
"ban" | ||
] | ||
"plugins": ["ban"] | ||
} | ||
``` | ||
Then configure the rules you want to use under the rules section. | ||
@@ -39,8 +36,8 @@ | ||
{ | ||
"rules": { | ||
"ban/ban": [ | ||
2, | ||
{"name": "functionName", "message": "Prefer use functionName2"} | ||
] | ||
} | ||
"rules": { | ||
"ban/ban": [ | ||
2, | ||
{ "name": "functionName", "message": "Prefer use functionName2" } | ||
] | ||
} | ||
} | ||
@@ -52,10 +49,14 @@ ``` | ||
> An error | ||
```json | ||
{ | ||
"rules": { | ||
"ban/ban": [ | ||
2, | ||
{"name": ["*", "push"], "message": "Prefer use es6 spread like [...items, newItem]"} | ||
] | ||
} | ||
"rules": { | ||
"ban/ban": [ | ||
2, | ||
{ | ||
"name": ["*", "push"], | ||
"message": "Prefer use es6 spread like [...items, newItem]" | ||
} | ||
] | ||
} | ||
} | ||
@@ -65,10 +66,14 @@ ``` | ||
> A simple warning | ||
```json | ||
{ | ||
"rules": { | ||
"ban/ban": [ | ||
1, | ||
{"name": "api", "message": "This function is deprecated, please use api.call()"} | ||
] | ||
} | ||
"rules": { | ||
"ban/ban": [ | ||
1, | ||
{ | ||
"name": "api", | ||
"message": "This function is deprecated, please use api.call()" | ||
} | ||
] | ||
} | ||
} | ||
@@ -78,15 +83,35 @@ ``` | ||
> Multiple errors | ||
```json | ||
{ | ||
"rules": { | ||
"ban/ban": [ | ||
"error", | ||
{"name": "api", "message": "This function is deprecated, please use api.call()"}, | ||
{"name": ["*", "push"], "message": "Prefer use es6 spread like [...items, newItem]"}, | ||
{"name": "functionName", "message": "Prefer use functionName2"} | ||
] | ||
} | ||
"rules": { | ||
"ban/ban": [ | ||
"error", | ||
{ | ||
"name": "api", | ||
"message": "This function is deprecated, please use api.call()" | ||
}, | ||
{ | ||
"name": ["*", "push"], | ||
"message": "Prefer use es6 spread like [...items, newItem]" | ||
}, | ||
{ "name": "functionName", "message": "Prefer use functionName2" } | ||
] | ||
} | ||
} | ||
``` | ||
> Widcard | ||
```json | ||
{ | ||
"rules": { | ||
"ban/ban": [ | ||
2, | ||
{ "name": ["console", "*"], "message": "Please use our logger" } | ||
] | ||
} | ||
} | ||
``` | ||
# Todo | ||
@@ -93,0 +118,0 @@ |
@@ -246,1 +246,57 @@ /** | ||
}); | ||
// wildcard | ||
const wildcard = [ | ||
{ name: ['console', '*'], message: 'Unexpected console statement' }, | ||
]; | ||
ruleTester.run('should ban using wildcard (end)', rule, { | ||
valid: [ | ||
{ | ||
code: 'hello.it("dogs");', | ||
options: wildcard, | ||
}, | ||
{ | ||
code: 'log.console("dogs");', | ||
options: wildcard, | ||
}, | ||
{ | ||
code: 'console("dogs");', | ||
options: wildcard, | ||
}, | ||
], | ||
invalid: [ | ||
// Ban method | ||
{ | ||
code: [ | ||
'console.log("bad usage");', | ||
'console.warn("wrong usage")', | ||
'console.error("oh no")', | ||
].join('\n'), | ||
errors: [ | ||
{ | ||
message: 'Unexpected console statement', | ||
line: 1, | ||
endLine: 1, | ||
column: 1, | ||
endColumn: 12, | ||
}, | ||
{ | ||
message: 'Unexpected console statement', | ||
line: 2, | ||
endLine: 2, | ||
column: 1, | ||
endColumn: 13, | ||
}, | ||
{ | ||
message: 'Unexpected console statement', | ||
line: 3, | ||
endLine: 3, | ||
column: 1, | ||
endColumn: 14, | ||
}, | ||
], | ||
options: wildcard, | ||
}, | ||
], | ||
}); |
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
17213
467
119