eslint
Advanced tools
Comparing version 9.0.0-beta.0 to 9.0.0-beta.1
@@ -8,4 +8,3 @@ /** | ||
const globals = require("globals"); | ||
const { isNullLiteral, isConstant, isReferenceToGlobalVariable, isLogicalAssignmentOperator } = require("./utils/ast-utils"); | ||
const { isNullLiteral, isConstant, isReferenceToGlobalVariable, isLogicalAssignmentOperator, ECMASCRIPT_GLOBALS } = require("./utils/ast-utils"); | ||
@@ -380,3 +379,3 @@ const NUMERIC_OR_STRING_BINARY_OPERATORS = new Set(["+", "-", "*", "/", "%", "|", "^", "&", "**", "<<", ">>", ">>>"]); | ||
*/ | ||
return Object.hasOwn(globals.builtin, node.callee.name) && | ||
return Object.hasOwn(ECMASCRIPT_GLOBALS, node.callee.name) && | ||
isReferenceToGlobalVariable(scope, node.callee); | ||
@@ -383,0 +382,0 @@ } |
@@ -13,3 +13,2 @@ /** | ||
const astUtils = require("./utils/ast-utils"); | ||
const globals = require("globals"); | ||
@@ -58,3 +57,3 @@ //------------------------------------------------------------------------------ | ||
const modifiedBuiltins = new Set( | ||
Object.keys(globals.builtin) | ||
Object.keys(astUtils.ECMASCRIPT_GLOBALS) | ||
.filter(builtin => builtin[0].toUpperCase() === builtin[0]) | ||
@@ -61,0 +60,0 @@ .filter(builtin => !exceptions.has(builtin)) |
@@ -77,3 +77,4 @@ /** | ||
replaceWithIsNaN: "Replace with Number.isNaN.", | ||
replaceWithCastingAndIsNaN: "Replace with Number.isNaN cast to a Number." | ||
replaceWithCastingAndIsNaN: "Replace with Number.isNaN and cast to a Number.", | ||
replaceWithFindIndex: "Replace with Array.prototype.{{ methodName }}." | ||
} | ||
@@ -130,6 +131,6 @@ }, | ||
const isSequenceExpression = NaNNode.type === "SequenceExpression"; | ||
const isFixable = fixableOperators.has(node.operator) && !isSequenceExpression; | ||
const isSuggestable = fixableOperators.has(node.operator) && !isSequenceExpression; | ||
const isCastable = castableOperators.has(node.operator); | ||
if (isFixable) { | ||
if (isSuggestable) { | ||
suggestedFixes.push({ | ||
@@ -189,3 +190,31 @@ messageId: "replaceWithIsNaN", | ||
) { | ||
context.report({ node, messageId: "indexOfNaN", data: { methodName } }); | ||
/* | ||
* To retain side effects, it's essential to address `NaN` beforehand, which | ||
* is not possible with fixes like `arr.findIndex(Number.isNaN)`. | ||
*/ | ||
const isSuggestable = node.arguments[0].type !== "SequenceExpression"; | ||
const suggestedFixes = []; | ||
if (isSuggestable) { | ||
const shouldWrap = callee.computed; | ||
const findIndexMethod = methodName === "indexOf" ? "findIndex" : "findLastIndex"; | ||
const propertyName = shouldWrap ? `"${findIndexMethod}"` : findIndexMethod; | ||
suggestedFixes.push({ | ||
messageId: "replaceWithFindIndex", | ||
data: { methodName: findIndexMethod }, | ||
fix: fixer => [ | ||
fixer.replaceText(callee.property, propertyName), | ||
fixer.replaceText(node.arguments[0], "Number.isNaN") | ||
] | ||
}); | ||
} | ||
context.report({ | ||
node, | ||
messageId: "indexOfNaN", | ||
data: { methodName }, | ||
suggest: suggestedFixes | ||
}); | ||
} | ||
@@ -192,0 +221,0 @@ } |
{ | ||
"name": "eslint", | ||
"version": "9.0.0-beta.0", | ||
"version": "9.0.0-beta.1", | ||
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>", | ||
@@ -68,4 +68,4 @@ "description": "An AST-based pattern checker for JavaScript.", | ||
"@eslint-community/regexpp": "^4.6.1", | ||
"@eslint/eslintrc": "^3.0.1", | ||
"@eslint/js": "9.0.0-beta.0", | ||
"@eslint/eslintrc": "^3.0.2", | ||
"@eslint/js": "9.0.0-beta.1", | ||
"@humanwhocodes/config-array": "^0.11.14", | ||
@@ -88,3 +88,2 @@ "@humanwhocodes/module-importer": "^1.0.1", | ||
"glob-parent": "^6.0.2", | ||
"globals": "^13.19.0", | ||
"graphemer": "^1.4.0", | ||
@@ -127,3 +126,3 @@ "ignore": "^5.2.0", | ||
"eslint-plugin-unicorn": "^49.0.0", | ||
"eslint-release": "^3.2.0", | ||
"eslint-release": "^3.2.2", | ||
"eslump": "^3.0.0", | ||
@@ -134,2 +133,3 @@ "esprima": "^4.0.1", | ||
"glob": "^10.0.0", | ||
"globals": "^14.0.0", | ||
"got": "^11.8.3", | ||
@@ -136,0 +136,0 @@ "gray-matter": "^4.0.3", |
@@ -106,3 +106,3 @@ [![npm version](https://img.shields.io/npm/v/eslint.svg)](https://www.npmjs.com/package/eslint) | ||
No, ESLint and Prettier have diffent jobs: ESLint is a linter (looking for problematic patterns) and Prettier is a code formatter. Using both tools is common, refer to [Prettier's documentation](https://prettier.io/docs/en/install#eslint-and-other-linters) to learn how to configure them to work well with each other. | ||
No, ESLint and Prettier have different jobs: ESLint is a linter (looking for problematic patterns) and Prettier is a code formatter. Using both tools is common, refer to [Prettier's documentation](https://prettier.io/docs/en/install#eslint-and-other-linters) to learn how to configure them to work well with each other. | ||
@@ -298,3 +298,3 @@ ### Why can't ESLint find my plugins? | ||
<p><a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/eb04ddc/logo.png" alt="JetBrains" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="64"></a> <a href="https://www.workleap.com"><img src="https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4" alt="Workleap" height="64"></a></p><h3>Bronze Sponsors</h3> | ||
<p><a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://transloadit.com/"><img src="https://avatars.githubusercontent.com/u/125754?v=4" alt="Transloadit" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://usenextbase.com"><img src="https://avatars.githubusercontent.com/u/145838380?v=4" alt="Nextbase Starter Kit" height="32"></a></p> | ||
<p><a href="https://www.notion.so"><img src="https://images.opencollective.com/notion/bf3b117/logo.png" alt="notion" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://transloadit.com/"><img src="https://avatars.githubusercontent.com/u/125754?v=4" alt="Transloadit" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://usenextbase.com"><img src="https://avatars.githubusercontent.com/u/145838380?v=4" alt="Nextbase Starter Kit" height="32"></a></p> | ||
<!--sponsorsend--> | ||
@@ -301,0 +301,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2985835
34
70251
63
+ Added@eslint/js@9.0.0-beta.1(transitive)
- Removedglobals@^13.19.0
- Removed@eslint/js@9.0.0-beta.0(transitive)
- Removedglobals@13.24.0(transitive)
- Removedtype-fest@0.20.2(transitive)
Updated@eslint/eslintrc@^3.0.2
Updated@eslint/js@9.0.0-beta.1