Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-ban

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-ban - npm Package Compare versions

Comparing version 1.5.3 to 1.6.0

6

lib/rules/ban.js

@@ -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;

2

package.json
{
"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,
},
],
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc