eslint-plugin-unicorn
Advanced tools
Comparing version 21.0.0 to 22.0.0
@@ -13,3 +13,3 @@ 'use strict'; | ||
parserOptions: { | ||
ecmaVersion: 2020, | ||
ecmaVersion: 2021, | ||
sourceType: 'module' | ||
@@ -31,2 +31,3 @@ }, | ||
'unicorn/import-index': 'error', | ||
'unicorn/import-style': 'error', | ||
'unicorn/new-for-builtins': 'error', | ||
@@ -33,0 +34,0 @@ 'unicorn/no-abusive-eslint-disable': 'error', |
{ | ||
"name": "eslint-plugin-unicorn", | ||
"version": "21.0.0", | ||
"version": "22.0.0", | ||
"description": "Various awesome ESLint rules", | ||
@@ -39,6 +39,6 @@ "license": "MIT", | ||
"eslint-ast-utils": "^1.1.0", | ||
"eslint-template-visitor": "^2.0.0", | ||
"eslint-template-visitor": "^2.2.1", | ||
"eslint-utils": "^2.1.0", | ||
"import-modules": "^2.0.0", | ||
"lodash": "^4.17.15", | ||
"lodash": "^4.17.20", | ||
"pluralize": "^8.0.0", | ||
@@ -53,22 +53,23 @@ "read-pkg-up": "^7.0.1", | ||
"@ava/babel": "^1.0.1", | ||
"@babel/code-frame": "7.10.3", | ||
"@babel/code-frame": "7.10.4", | ||
"@lubien/fixture-beta-package": "^1.0.0-beta.1", | ||
"@typescript-eslint/parser": "^3.4.0", | ||
"ava": "^3.9.0", | ||
"@typescript-eslint/parser": "^4.1.0", | ||
"ava": "^3.12.1", | ||
"babel-eslint": "^10.1.0", | ||
"chalk": "^4.1.0", | ||
"eslint": "^7.3.0", | ||
"eslint": "^7.8.0", | ||
"eslint-ava-rule-tester": "^4.0.0", | ||
"eslint-plugin-eslint-plugin": "^2.3.0", | ||
"execa": "^4.0.2", | ||
"execa": "^4.0.3", | ||
"listr": "^0.14.3", | ||
"mem": "6.1.1", | ||
"nyc": "^15.1.0", | ||
"outdent": "^0.7.1", | ||
"pify": "^5.0.0", | ||
"typescript": "^3.9.5", | ||
"typescript": "^4.0.2", | ||
"vue-eslint-parser": "^7.1.0", | ||
"xo": "^0.32.0" | ||
"xo": "^0.33.1" | ||
}, | ||
"peerDependencies": { | ||
"eslint": ">=7.3.0" | ||
"eslint": ">=7.8.0" | ||
}, | ||
@@ -75,0 +76,0 @@ "ava": { |
@@ -29,3 +29,3 @@ # eslint-plugin-unicorn [![Build Status](https://github.com/sindresorhus/eslint-plugin-unicorn/workflows/CI/badge.svg?branch=master)](https://github.com/sindresorhus/eslint-plugin-unicorn/actions?query=branch%3Amaster+workflow%3ACI) [![Coverage Status](https://codecov.io/gh/sindresorhus/eslint-plugin-unicorn/branch/master/graph/badge.svg)](https://codecov.io/gh/sindresorhus/eslint-plugin-unicorn/branch/master) | ||
"parserOptions": { | ||
"ecmaVersion": 2020, | ||
"ecmaVersion": 2021, | ||
"sourceType": "module" | ||
@@ -47,2 +47,3 @@ }, | ||
"unicorn/import-index": "error", | ||
"unicorn/import-style": "error", | ||
"unicorn/new-for-builtins": "error", | ||
@@ -111,2 +112,3 @@ "unicorn/no-abusive-eslint-disable": "error", | ||
- [import-index](docs/rules/import-index.md) - Enforce importing index files with `.`. *(fixable)* | ||
- [import-style](docs/rules/import-style.md) - Enforce specific import styles per module. | ||
- [new-for-builtins](docs/rules/new-for-builtins.md) - Enforce the use of `new` for all builtins, except `String`, `Number`, `Boolean`, `Symbol` and `BigInt`. *(fixable)* | ||
@@ -113,0 +115,0 @@ - [no-abusive-eslint-disable](docs/rules/no-abusive-eslint-disable.md) - Enforce specifying rules to disable in `eslint-disable` comments. |
@@ -19,3 +19,3 @@ 'use strict'; | ||
const MESSAGE_ID_ENGINE_MATCHES = 'unicorn/engineMatches'; | ||
const MESSAGE_ID_REMOVE_WHITESPACES = 'unicorn/removeWhitespaces'; | ||
const MESSAGE_ID_REMOVE_WHITESPACE = 'unicorn/removeWhitespaces'; | ||
const MESSAGE_ID_MISSING_AT_SYMBOL = 'unicorn/missingAtSymbol'; | ||
@@ -452,12 +452,12 @@ | ||
const withoutWhitespaces = unknown.replace(/ /g, ''); | ||
const withoutWhitespace = unknown.replace(/ /g, ''); | ||
if (parseArgument(withoutWhitespaces).type !== 'unknowns') { | ||
if (parseArgument(withoutWhitespace).type !== 'unknowns') { | ||
uses++; | ||
context.report({ | ||
loc: comment.loc, | ||
messageId: MESSAGE_ID_REMOVE_WHITESPACES, | ||
messageId: MESSAGE_ID_REMOVE_WHITESPACE, | ||
data: { | ||
original: unknown, | ||
fix: withoutWhitespaces, | ||
fix: withoutWhitespace, | ||
message: parseTodoMessage(comment.value) | ||
@@ -531,4 +531,4 @@ } | ||
'There is a TODO match for Node.js version: {{comparison}}. {{message}}', | ||
[MESSAGE_ID_REMOVE_WHITESPACES]: | ||
'Avoid using whitespaces on TODO argument. On \'{{original}}\' use \'{{fix}}\'. {{message}}', | ||
[MESSAGE_ID_REMOVE_WHITESPACE]: | ||
'Avoid using whitespace on TODO argument. On \'{{original}}\' use \'{{fix}}\'. {{message}}', | ||
[MESSAGE_ID_MISSING_AT_SYMBOL]: | ||
@@ -535,0 +535,0 @@ 'Missing \'@\' on TODO argument. On \'{{original}}\' use \'{{fix}}\'. {{message}}', |
@@ -12,2 +12,3 @@ 'use strict'; | ||
const isIgnoredChar = char => !/^[a-z\d-_$]$/i.test(char); | ||
const ignoredByDefault = new Set(['index.js', 'index.mjs', 'index.cjs', 'index.ts', 'index.tsx', 'index.vue']); | ||
@@ -163,3 +164,3 @@ function ignoreNumbers(fn) { | ||
if (base === 'index.js' || ignore.some(regexp => regexp.test(base))) { | ||
if (ignoredByDefault.has(base) || ignore.some(regexp => regexp.test(base))) { | ||
return; | ||
@@ -166,0 +167,0 @@ } |
@@ -63,2 +63,3 @@ 'use strict'; | ||
'React.children', | ||
'Children', | ||
'lodash', | ||
@@ -65,0 +66,0 @@ 'underscore', |
@@ -60,3 +60,3 @@ 'use strict'; | ||
return pattern.properties.some(property => { | ||
if (property.type === 'ExperimentalRestProperty') { | ||
if (property.type === 'ExperimentalRestProperty' || property.type === 'RestElement') { | ||
return true; | ||
@@ -63,0 +63,0 @@ } |
'use strict'; | ||
const getDocumentationUrl = require('./utils/get-documentation-url'); | ||
const fix = (value, isBigInt) => { | ||
value = value.toLowerCase(); | ||
if (value.startsWith('0x')) { | ||
value = '0x' + value.slice(2).toUpperCase(); | ||
const fix = (raw, isBigInt) => { | ||
let fixed = raw.toLowerCase(); | ||
if (fixed.startsWith('0x')) { | ||
fixed = '0x' + fixed.slice(2).toUpperCase(); | ||
if (isBigInt) { | ||
fixed = fixed.slice(0, -1) + 'n'; | ||
} | ||
} | ||
return `${value}${isBigInt ? 'n' : ''}`; | ||
return fixed; | ||
}; | ||
@@ -23,3 +27,3 @@ | ||
const fixed = fix(isBigInt ? bigint : raw, isBigInt); | ||
const fixed = fix(raw, isBigInt); | ||
@@ -26,0 +30,0 @@ if (raw !== fixed) { |
@@ -10,10 +10,14 @@ 'use strict'; | ||
const selector = methodSelector({ | ||
names: ['trimLeft', 'trimRight'], | ||
length: 0 | ||
}); | ||
const selector = [ | ||
methodSelector({ | ||
names: ['trimLeft', 'trimRight'], | ||
length: 0 | ||
}), | ||
'> MemberExpression.callee', | ||
'> Identifier.property' | ||
].join(' '); | ||
const messages = {}; | ||
for (const [method, replacement] of methods.entries()) { | ||
messages[method] = `Prefer \`String#${method}()\` over \`String#${replacement}()\`.`; | ||
messages[method] = `Prefer \`String#${replacement}()\` over \`String#${method}()\`.`; | ||
} | ||
@@ -24,8 +28,7 @@ | ||
[selector](node) { | ||
const {property} = node.callee; | ||
const method = property.name; | ||
const method = node.name; | ||
context.report({ | ||
node, | ||
messageId: method, | ||
fix: fixer => fixer.replaceText(property, methods.get(method)) | ||
fix: fixer => fixer.replaceText(node, methods.get(method)) | ||
}); | ||
@@ -32,0 +35,0 @@ } |
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
234959
92
7737
192
19
Updatedlodash@^4.17.20