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

eslint-plugin-unicorn

Package Overview
Dependencies
Maintainers
3
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-unicorn - npm Package Compare versions

Comparing version 4.0.3 to 5.0.0

rules/.DS_Store

16

package.json
{
"name": "eslint-plugin-unicorn",
"version": "4.0.3",
"version": "5.0.0",
"description": "Various awesome ESLint rules",

@@ -13,6 +13,6 @@ "license": "MIT",

"engines": {
"node": ">=4"
"node": ">=6"
},
"scripts": {
"test": "xo && nyc ava",
"test": "nyc ava",
"integration": "./test/integration/test.js",

@@ -50,7 +50,7 @@ "coveralls": "nyc report --reporter=text-lcov | coveralls"

"del": "^3.0.0",
"eslint": "^4.0.0",
"eslint": "^5.0.0",
"eslint-ava-rule-tester": "^2.0.0",
"execa": "^0.9.0",
"listr": "^0.13.0",
"nyc": "^11.0.3",
"execa": "^0.10.0",
"listr": "^0.14.1",
"nyc": "^12.0.2",
"pify": "^3.0.0",

@@ -61,3 +61,3 @@ "tempy": "^0.2.1",

"peerDependencies": {
"eslint": ">=4"
"eslint": ">=5.0.0"
},

@@ -64,0 +64,0 @@ "ava": {

@@ -29,3 +29,3 @@ # eslint-plugin-unicorn [![Build Status](https://travis-ci.org/sindresorhus/eslint-plugin-unicorn.svg?branch=master)](https://travis-ci.org/sindresorhus/eslint-plugin-unicorn) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/eslint-plugin-unicorn/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/eslint-plugin-unicorn?branch=master)

"parserOptions": {
"ecmaVersion": 2017,
"ecmaVersion": 2018,
"sourceType": "module"

@@ -32,0 +32,0 @@ },

@@ -7,3 +7,3 @@ 'use strict';

function isLintablePromiseCatch(node) {
const callee = node.callee;
const {callee} = node;

@@ -14,3 +14,3 @@ if (callee.type !== 'MemberExpression') {

const property = callee.property;
const {property} = callee;

@@ -25,3 +25,3 @@ if (property.type !== 'Identifier' || property.name !== 'catch') {

const arg0 = node.arguments[0];
const [arg0] = node.arguments;

@@ -48,3 +48,3 @@ return arg0.type === 'FunctionExpression' || arg0.type === 'ArrowFunctionExpression';

const name = options.name;
const {name} = options;
const caughtErrorsIgnorePattern = new RegExp(options.caughtErrorsIgnorePattern);

@@ -75,3 +75,3 @@ const stack = [];

if (isLintablePromiseCatch(node)) {
const params = node.arguments[0].params;
const {params} = node.arguments[0];

@@ -78,0 +78,0 @@ if (params.length > 0 && params[0].name === '_') {

@@ -21,6 +21,6 @@ 'use strict';

let name = node.superClass.name;
let {name} = node.superClass;
if (node.superClass.type === 'MemberExpression') {
name = node.superClass.property.name;
({name} = node.superClass.property);
}

@@ -52,3 +52,3 @@

const name = node.id.name;
const {name} = node.id;
const className = getClassName(name);

@@ -63,4 +63,3 @@

const body = node.body.body;
const {body} = node.body;
const constructor = body.find(x => x.kind === 'constructor');

@@ -67,0 +66,0 @@

@@ -39,9 +39,10 @@ 'use strict';

function checkNonZeroType(context, node, type) {
const value = node.right.value;
const operator = node.operator;
const {value} = node.right;
const {operator} = node;
switch (type) {
case 'greater-than':
if ((operatorTypes.gte.indexOf(operator) !== -1 && value === 1) ||
(operatorTypes.ne.indexOf(operator) !== -1 && value === 0)
if (
(operatorTypes.gte.includes(operator) && value === 1) ||
(operatorTypes.ne.includes(operator) && value === 0)
) {

@@ -61,4 +62,5 @@ reportError(

case 'greater-than-or-equal':
if ((operatorTypes.gt.indexOf(operator) !== -1 && value === 0) ||
(operatorTypes.ne.indexOf(operator) !== -1 && value === 0)
if (
(operatorTypes.gt.includes(operator) && value === 0) ||
(operatorTypes.ne.includes(operator) && value === 0)
) {

@@ -78,4 +80,5 @@ reportError(

case 'not-equal':
if ((operatorTypes.gt.indexOf(operator) !== -1 && value === 0) ||
(operatorTypes.gte.indexOf(operator) !== -1 && value === 1)
if (
(operatorTypes.gt.includes(operator) && value === 0) ||
(operatorTypes.gte.includes(operator) && value === 1)
) {

@@ -139,2 +142,5 @@ reportError(

checkExpression(context, node.test);
},
ConditionalExpression: node => {
checkExpression(context, node.test);
}

@@ -141,0 +147,0 @@ };

@@ -39,3 +39,3 @@ 'use strict';

CallExpression: node => {
const name = node.callee.name;
const {name} = node.callee;

@@ -51,3 +51,3 @@ if (enforceNew.has(name)) {

NewExpression: node => {
const name = node.callee.name;
const {name} = node.callee;

@@ -54,0 +54,0 @@ if (disallowNew.has(name)) {

@@ -8,7 +8,8 @@ 'use strict';

Program: node => {
node.comments.forEach(comment => {
for (const comment of node.comments) {
const value = comment.value.trim();
const res = disableRegex.exec(value);
if (res && // It's a eslint-disable comment
if (
res && // It's a eslint-disable comment
!res[2] // But it did not specify any rules

@@ -28,3 +29,3 @@ ) {

}
});
}
}

@@ -31,0 +32,0 @@ });

@@ -37,3 +37,3 @@ 'use strict';

if (isIteratorMethod(node) && hasFunctionArgument(node)) {
const arg = node.arguments[0];
const [arg] = node.arguments;

@@ -40,0 +40,0 @@ context.report({

@@ -15,3 +15,3 @@ 'use strict';

CallExpression: node => {
const callee = node.callee;
const {callee} = node;

@@ -18,0 +18,0 @@ if (callee.type === 'MemberExpression' && callee.object.name === 'process') {

@@ -35,3 +35,3 @@ 'use strict';

if (hasRegExp) {
pattern = args[0].regex.pattern;
({pattern} = args[0].regex);
flags = args[1] && args[1].type === 'Literal' ? args[1].value : args[0].regex.flags;

@@ -38,0 +38,0 @@ } else {

@@ -5,3 +5,3 @@ 'use strict';

const isArrayFrom = node => {
const callee = node.callee;
const {callee} = node;
return (

@@ -8,0 +8,0 @@ callee.type === 'MemberExpression' &&

@@ -14,3 +14,3 @@ 'use strict';

CallExpression(node) {
const callee = node.callee;
const {callee} = node;
const prop = callee.property;

@@ -26,5 +26,5 @@

if (prop.name === 'test' && callee.object.regex) {
regex = callee.object.regex;
({regex} = callee.object);
} else if (prop.name === 'match' && args && args[0] && args[0].regex) {
regex = args[0].regex;
({regex} = args[0]);
} else {

@@ -38,3 +38,3 @@ return;

const pattern = regex.pattern;
const {pattern} = regex;
if (pattern.startsWith('^') && isSimpleString(pattern.slice(1))) {

@@ -41,0 +41,0 @@ context.report({

@@ -11,3 +11,3 @@ 'use strict';

const oldPattern = node.regex.pattern;
const flags = node.regex.flags;
const {flags} = node.regex;

@@ -14,0 +14,0 @@ const newPattern = cleanRegexp(oldPattern, flags);

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