📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

eslint-plugin-unicorn

Package Overview
Dependencies
Maintainers
2
Versions
110
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

to
57.0.0

rules/consistent-assert.js

7

configs/flat-config-base.js

@@ -1,5 +0,4 @@

'use strict';
const globals = require('globals');
import globals from 'globals';
module.exports = {
const config = {
languageOptions: {

@@ -9,1 +8,3 @@ globals: globals.builtin,

};
export default config;

@@ -5,5 +5,9 @@ import type {ESLint, Linter} from 'eslint';

configs: {
recommended: Linter.Config;
all: Linter.Config;
recommended: Linter.FlatConfig;
all: Linter.FlatConfig;
/** @deprecated Use `all` instead. The `flat/` prefix is no longer needed. */
'flat/all': Linter.FlatConfig;
/** @deprecated Use `recommended` instead. The `flat/` prefix is no longer needed. */
'flat/recommended': Linter.FlatConfig;

@@ -13,2 +17,2 @@ };

export = eslintPluginUnicorn;
export default eslintPluginUnicorn;

@@ -1,27 +0,9 @@

'use strict';
const createDeprecatedRules = require('./rules/utils/create-deprecated-rules.js');
const {loadRules} = require('./rules/utils/rule.js');
const legacyConfigBase = require('./configs/legacy-config-base.js');
const flatConfigBase = require('./configs/flat-config-base.js');
const {name, version} = require('./package.json');
import createDeprecatedRules from './rules/utils/create-deprecated-rules.js';
import flatConfigBase from './configs/flat-config-base.js';
import rules from './rules/index.js';
import packageJson from './package.json' with {type: 'json'};
const deprecatedRules = createDeprecatedRules({
// {ruleId: ReplacementRuleId | ReplacementRuleId[]}, if no replacement, use `{ruleId: []}`
'import-index': [],
'no-array-instanceof': 'unicorn/no-instanceof-array',
'no-fn-reference-in-iterator': 'unicorn/no-array-callback-reference',
'no-reduce': 'unicorn/no-array-reduce',
'no-unsafe-regex': [],
'prefer-dataset': 'unicorn/prefer-dom-node-dataset',
'prefer-event-key': 'unicorn/prefer-keyboard-event-key',
'prefer-exponentiation-operator': 'prefer-exponentiation-operator',
'prefer-flat-map': 'unicorn/prefer-array-flat-map',
'prefer-node-append': 'unicorn/prefer-dom-node-append',
'prefer-node-remove': 'unicorn/prefer-dom-node-remove',
'prefer-object-has-own': 'prefer-object-has-own',
'prefer-replace-all': 'unicorn/prefer-string-replace-all',
'prefer-starts-ends-with': 'unicorn/prefer-string-starts-ends-with',
'prefer-text-content': 'unicorn/prefer-dom-node-text-content',
'prefer-trim-start-end': 'unicorn/prefer-string-trim-start-end',
'regex-shorthand': 'unicorn/better-regex',
'no-instanceof-array': 'unicorn/no-instanceof-builtins',
});

@@ -36,3 +18,2 @@

const rules = loadRules();
const recommendedRules = Object.fromEntries(

@@ -44,2 +25,3 @@ Object.entries(rules).map(([id, rule]) => [

);
const allRules = Object.fromEntries(

@@ -52,9 +34,12 @@ Object.keys(rules).map(id => [

const createConfig = (rules, flatConfigName = false) => ({
...(
flatConfigName
? {...flatConfigBase, name: flatConfigName, plugins: {unicorn}}
: {...legacyConfigBase, plugins: ['unicorn']}
),
rules: {...externalRules, ...rules},
const createConfig = (rules, flatConfigName) => ({
...flatConfigBase,
name: flatConfigName,
plugins: {
unicorn,
},
rules: {
...externalRules,
...rules,
},
});

@@ -64,4 +49,4 @@

meta: {
name,
version,
name: packageJson.name,
version: packageJson.version,
},

@@ -75,4 +60,6 @@ rules: {

const configs = {
recommended: createConfig(recommendedRules),
all: createConfig(allRules),
recommended: createConfig(recommendedRules, 'unicorn/recommended'),
all: createConfig(allRules, 'unicorn/all'),
// TODO: Remove this at some point. Kept for now to avoid breaking users.
'flat/recommended': createConfig(recommendedRules, 'unicorn/flat/recommended'),

@@ -82,2 +69,7 @@ 'flat/all': createConfig(allRules, 'unicorn/flat/all'),

module.exports = {...unicorn, configs};
const allConfigs = {
...unicorn,
configs,
};
export default allConfigs;
{
"name": "eslint-plugin-unicorn",
"version": "56.0.1",
"version": "57.0.0",
"description": "More than 100 powerful ESLint rules",

@@ -13,4 +13,7 @@ "license": "MIT",

},
"main": "index.js",
"types": "index.d.ts",
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,

@@ -21,17 +24,19 @@ "engines": {

"scripts": {
"bundle-lodash": "echo \"export {defaultsDeep, camelCase, kebabCase, snakeCase, upperFirst, lowerFirst} from 'lodash-es';\" | npx esbuild --bundle --outfile=rules/utils/lodash.js --format=cjs",
"create-rule": "node ./scripts/create-rule.mjs && npm run fix:eslint-docs",
"bundle-lodash": "echo export {defaultsDeep, camelCase, kebabCase, snakeCase, upperFirst, lowerFirst} from 'lodash-es'; | npx esbuild --bundle --outfile=rules/utils/lodash.js --format=esm",
"create-rule": "node ./scripts/create-rule.js && npm run create-rules-index-file && npm run fix:eslint-docs",
"create-rules-index-file": "node ./scripts/create-rules-index-file.js",
"fix": "run-p --continue-on-error fix:*",
"fix:eslint-docs": "eslint-doc-generator",
"fix:eslint-docs": "eslint-doc-generator workaround-for-eslint-doc-generator",
"fix:js": "npm run lint:js -- --fix",
"fix:markdown": "npm run lint:markdown -- --fix",
"fix:snapshots": "ava --update-snapshots",
"integration": "node ./test/integration/test.mjs",
"integration": "node ./test/integration/test.js",
"lint": "run-p --continue-on-error lint:*",
"lint:eslint-docs": "npm run fix:eslint-docs -- --check",
"lint:js": "xo",
"lint:js": "eslint",
"lint:markdown": "markdownlint \"**/*.md\"",
"lint:package-json": "npmPkgJsonLint .",
"run-rules-on-codebase": "eslint --config=./eslint.dogfooding.config.mjs",
"smoke": "eslint-remote-tester --config ./test/smoke/eslint-remote-tester.config.mjs",
"rename-rule": "node ./scripts/rename-rule.js && npm run create-rules-index-file && npm run fix:eslint-docs",
"run-rules-on-codebase": "eslint --config=./eslint.dogfooding.config.js",
"smoke": "eslint-remote-tester --config ./test/smoke/eslint-remote-tester.config.js",
"test": "npm-run-all --continue-on-error lint test:*",

@@ -57,59 +62,61 @@ "test:js": "c8 ava"

"dependencies": {
"@babel/helper-validator-identifier": "^7.24.7",
"@eslint-community/eslint-utils": "^4.4.0",
"ci-info": "^4.0.0",
"@babel/helper-validator-identifier": "^7.25.9",
"@eslint-community/eslint-utils": "^4.4.1",
"ci-info": "^4.1.0",
"clean-regexp": "^1.0.0",
"core-js-compat": "^3.38.1",
"core-js-compat": "^3.40.0",
"esquery": "^1.6.0",
"globals": "^15.9.0",
"indent-string": "^4.0.0",
"is-builtin-module": "^3.2.1",
"jsesc": "^3.0.2",
"globals": "^15.15.0",
"indent-string": "^5.0.0",
"is-builtin-module": "^4.0.0",
"jsesc": "^3.1.0",
"pluralize": "^8.0.0",
"read-pkg-up": "^7.0.1",
"read-package-up": "^11.0.0",
"regexp-tree": "^0.1.27",
"regjsparser": "^0.10.0",
"semver": "^7.6.3",
"strip-indent": "^3.0.0"
"regjsparser": "^0.12.0",
"semver": "^7.7.1",
"strip-indent": "^4.0.0"
},
"devDependencies": {
"@babel/code-frame": "^7.24.7",
"@babel/core": "^7.25.2",
"@babel/eslint-parser": "^7.25.1",
"@eslint/eslintrc": "^3.1.0",
"@babel/code-frame": "^7.26.2",
"@babel/core": "^7.26.9",
"@babel/eslint-parser": "^7.26.8",
"@eslint/eslintrc": "^3.2.0",
"@lubien/fixture-beta-package": "^1.0.0-beta.1",
"@typescript-eslint/parser": "^8.4.0",
"ava": "^6.1.3",
"c8": "^10.1.2",
"chalk": "^5.3.0",
"@typescript-eslint/parser": "^8.24.1",
"ava": "^6.2.0",
"c8": "^10.1.3",
"enquirer": "^2.4.1",
"eslint": "^9.10.0",
"eslint": "^9.20.1",
"eslint-ava-rule-tester": "^5.0.1",
"eslint-doc-generator": "1.7.0",
"eslint-plugin-eslint-plugin": "^6.2.0",
"eslint-config-xo": "^0.46.0",
"eslint-doc-generator": "^2.0.2",
"eslint-plugin-eslint-plugin": "^6.4.0",
"eslint-plugin-internal-rules": "file:./scripts/internal-rules/",
"eslint-plugin-jsdoc": "^50.6.3",
"eslint-remote-tester": "^4.0.1",
"eslint-remote-tester-repositories": "^2.0.0",
"espree": "^10.1.0",
"execa": "^8.0.1",
"listr": "^0.14.3",
"espree": "^10.3.0",
"listr2": "^8.2.5",
"lodash-es": "^4.17.21",
"markdownlint-cli": "^0.41.0",
"markdownlint-cli": "^0.44.0",
"memoize": "^10.0.0",
"nano-spawn": "^0.2.0",
"node-style-text": "^0.0.7",
"npm-package-json-lint": "^8.0.0",
"npm-run-all2": "^6.2.2",
"npm-run-all2": "^7.0.2",
"open-editor": "^5.1.0",
"outdent": "^0.8.0",
"pretty-ms": "^9.1.0",
"typescript": "^5.5.4",
"pretty-ms": "^9.2.0",
"typescript": "^5.7.3",
"vue-eslint-parser": "^9.4.3",
"xo": "^0.59.3",
"yaml": "^2.5.1"
"yaml": "^2.7.0"
},
"peerDependencies": {
"eslint": ">=8.56.0"
"eslint": ">=9.20.0"
},
"ava": {
"files": [
"test/*.mjs",
"test/unit/*.mjs"
"test/*.js",
"test/unit/*.js"
]

@@ -122,68 +129,3 @@ },

]
},
"xo": {
"extends": [
"plugin:internal-rules/all"
],
"ignores": [
".cache-eslint-remote-tester",
"eslint-remote-tester-results",
"rules/utils/lodash.js",
"test/integration/{fixtures,fixtures-local}/**"
],
"rules": {
"unicorn/escape-case": "off",
"unicorn/expiring-todo-comments": "off",
"unicorn/no-hex-escape": "off",
"unicorn/no-null": "error",
"unicorn/prefer-array-flat": [
"error",
{
"functions": [
"flat",
"flatten"
]
}
],
"import/order": "off",
"func-names": "off"
},
"overrides": [
{
"files": [
"**/*.js"
],
"parserOptions": {
"sourceType": "script"
},
"rules": {
"strict": "error",
"unicorn/prefer-module": "off"
}
},
{
"files": [
"rules/*.js"
],
"plugins": [
"eslint-plugin"
],
"extends": [
"plugin:eslint-plugin/all"
],
"rules": {
"eslint-plugin/require-meta-docs-description": [
"error",
{
"pattern": ".+"
}
],
"eslint-plugin/require-meta-docs-url": "off",
"eslint-plugin/require-meta-has-suggestions": "off",
"eslint-plugin/require-meta-schema": "off",
"eslint-plugin/require-meta-schema-description": "off"
}
}
]
}
}

@@ -18,12 +18,10 @@ # eslint-plugin-unicorn [![Coverage Status](https://codecov.io/gh/sindresorhus/eslint-plugin-unicorn/branch/main/graph/badge.svg)](https://codecov.io/gh/sindresorhus/eslint-plugin-unicorn/branch/main) [![npm version](https://img.shields.io/npm/v/eslint-plugin-unicorn.svg?style=flat)](https://npmjs.com/package/eslint-plugin-unicorn)

## Usage (`eslint.config.js`)
**Requires ESLint `>=9.20.0`, [flat config](https://eslint.org/docs/latest/use/configure/configuration-files), and [ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-make-my-typescript-project-output-esm).**
**Requires ESLint `>=8.56.0`.**
## Usage
Use a [preset config](#preset-configs-eslintconfigjs) or configure each rule in `eslint.config.js`.
Use a [preset config](#preset-configs) or configure each rule in `eslint.config.js`.
If you don't use the preset, ensure you use the same `languageOptions` config as below.
### ES Module (Recommended)
```js

@@ -50,54 +48,2 @@ import eslintPluginUnicorn from 'eslint-plugin-unicorn';

### CommonJS
```js
'use strict';
const eslintPluginUnicorn = require('eslint-plugin-unicorn');
const globals = require('globals');
module.exports = [
{
languageOptions: {
globals: globals.builtin,
},
plugins: {
unicorn: eslintPluginUnicorn,
},
rules: {
'unicorn/better-regex': 'error',
'unicorn/…': 'error',
},
},
// …
];
```
## Usage (legacy: `.eslintrc.*` or `package.json`)
Use a [preset config](#legacy-preset-configs-eslintrc-or-packagejson) or configure each rule in `package.json`.
If you don't use the preset, ensure you use the same `env` and `parserOptions` config as below.
```json
{
"name": "my-awesome-project",
"eslintConfig": {
"env": {
"es2024": true
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"unicorn"
],
"rules": {
"unicorn/better-regex": "error",
"unicorn/…": "error"
}
}
}
```
## Rules

@@ -117,2 +63,4 @@

| [catch-error-name](docs/rules/catch-error-name.md) | Enforce a specific parameter name in catch clauses. | ✅ | 🔧 | |
| [consistent-assert](docs/rules/consistent-assert.md) | Enforce consistent assertion style with `node:assert`. | ✅ | 🔧 | |
| [consistent-date-clone](docs/rules/consistent-date-clone.md) | Prefer passing `Date` directly to the constructor when cloning. | ✅ | 🔧 | |
| [consistent-destructuring](docs/rules/consistent-destructuring.md) | Use destructured variables over properties. | | 🔧 | 💡 |

@@ -130,4 +78,5 @@ | [consistent-empty-array-spread](docs/rules/consistent-empty-array-spread.md) | Prefer consistent types when spreading a ternary in an array literal. | ✅ | 🔧 | |

| [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`. | ✅ | 🔧 | |
| [new-for-builtins](docs/rules/new-for-builtins.md) | Enforce the use of `new` for all builtins, except `String`, `Number`, `Boolean`, `Symbol` and `BigInt`. | ✅ | 🔧 | 💡 |
| [no-abusive-eslint-disable](docs/rules/no-abusive-eslint-disable.md) | Enforce specifying rules to disable in `eslint-disable` comments. | ✅ | | |
| [no-accessor-recursion](docs/rules/no-accessor-recursion.md) | Disallow recursive access to `this` within getters and setters. | ✅ | | |
| [no-anonymous-default-export](docs/rules/no-anonymous-default-export.md) | Disallow anonymous functions and classes as the default export. | ✅ | | 💡 |

@@ -146,3 +95,3 @@ | [no-array-callback-reference](docs/rules/no-array-callback-reference.md) | Prevent passing a function reference directly to iterator methods. | ✅ | | 💡 |

| [no-hex-escape](docs/rules/no-hex-escape.md) | Enforce the use of Unicode escapes instead of hexadecimal escapes. | ✅ | 🔧 | |
| [no-instanceof-array](docs/rules/no-instanceof-array.md) | Require `Array.isArray()` instead of `instanceof Array`. | ✅ | 🔧 | |
| [no-instanceof-builtins](docs/rules/no-instanceof-builtins.md) | Disallow `instanceof` with built-in objects | ✅ | 🔧 | 💡 |
| [no-invalid-fetch-options](docs/rules/no-invalid-fetch-options.md) | Disallow invalid options in `fetch()` and `new Request()`. | ✅ | | |

@@ -154,2 +103,3 @@ | [no-invalid-remove-event-listener](docs/rules/no-invalid-remove-event-listener.md) | Prevent calling `EventTarget#removeEventListener()` with the result of an expression. | ✅ | | |

| [no-magic-array-flat-depth](docs/rules/no-magic-array-flat-depth.md) | Disallow a magic number as the `depth` argument in `Array#flat(…).` | ✅ | | |
| [no-named-default](docs/rules/no-named-default.md) | Disallow named usage of default import and export. | ✅ | 🔧 | |
| [no-negated-condition](docs/rules/no-negated-condition.md) | Disallow negated conditions. | ✅ | 🔧 | |

@@ -249,3 +199,3 @@ | [no-negation-in-equality-check](docs/rules/no-negation-in-equality-check.md) | Disallow negated expression in equality check. | ✅ | | 💡 |

## Preset configs (`eslint.config.js`)
## Preset configs

@@ -260,4 +210,2 @@ See the [ESLint docs](https://eslint.org/docs/latest/use/configure/configuration-files) for more information about extending config files.

#### ES Module (Recommended)
```js

@@ -268,3 +216,3 @@ import eslintPluginUnicorn from 'eslint-plugin-unicorn';

// …
eslintPluginUnicorn.configs['flat/recommended'],
eslintPluginUnicorn.configs.recommended,
{

@@ -278,19 +226,2 @@ rules: {

#### CommonJS
```js
'use strict';
const eslintPluginUnicorn = require('eslint-plugin-unicorn');
module.exports = [
// …
eslintPluginUnicorn.configs['flat/recommended'],
{
rules: {
'unicorn/better-regex': 'warn',
},
},
];
```
### All config

@@ -300,4 +231,2 @@

#### ES Module (Recommended)
```js

@@ -308,3 +237,3 @@ import eslintPluginUnicorn from 'eslint-plugin-unicorn';

// …
eslintPluginUnicorn.configs['flat/all'],
eslintPluginUnicorn.configs.all,
{

@@ -318,54 +247,2 @@ rules: {

#### CommonJS
```js
'use strict';
const eslintPluginUnicorn = require('eslint-plugin-unicorn');
module.exports = [
// …
eslintPluginUnicorn.configs['flat/all'],
{
rules: {
'unicorn/better-regex': 'warn',
},
},
];
```
## Legacy preset configs (`.eslintrc.*` or `package.json`)
See the [ESLint docs](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated) for more information about extending deprecated legacy config files.
**Note**: Preset configs will also enable the correct [parser options](https://eslint.org/docs/latest/use/configure/parser-deprecated) and [environment](https://eslint.org/docs/latest/use/configure/language-options-deprecated).
### Recommended legacy config
This plugin exports a `recommended` legacy config that enforces good practices.
```json
{
"name": "my-awesome-project",
"eslintConfig": {
"extends": "plugin:unicorn/recommended",
"rules": {
"unicorn/better-regex": "warn"
}
}
}
```
### All legacy config
This plugin exports an `all` legacy config that makes use of all rules (except for deprecated ones).
```json
{
"name": "my-awesome-project",
"eslintConfig": {
"extends": "plugin:unicorn/all"
}
}
```
## Maintainers

@@ -372,0 +249,0 @@

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -103,3 +101,3 @@ @typedef {

*/
const isCallExpression = (node, options) => create(node, options, ['CallExpression']);
export const isCallExpression = (node, options) => create(node, options, ['CallExpression']);

@@ -110,3 +108,3 @@ /**

*/
const isNewExpression = (node, options) => {
export const isNewExpression = (node, options) => {
if (typeof options?.optional === 'boolean') {

@@ -123,8 +121,2 @@ throw new TypeError('Cannot check node.optional in `isNewExpression`.');

*/
const isCallOrNewExpression = (node, options) => create(node, options, ['CallExpression', 'NewExpression']);
module.exports = {
isCallExpression,
isNewExpression,
isCallOrNewExpression,
};
export const isCallOrNewExpression = (node, options) => create(node, options, ['CallExpression', 'NewExpression']);

@@ -1,5 +0,7 @@

'use strict';
const functionTypes = [
'FunctionDeclaration',
'FunctionExpression',
'ArrowFunctionExpression',
];
const functionTypes = ['FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression'];
module.exports = functionTypes;
export default functionTypes;

@@ -1,4 +0,2 @@

'use strict';
const {
export {
isLiteral,

@@ -10,34 +8,22 @@ isStringLiteral,

isRegexLiteral,
} = require('./literal.js');
const {
} from './literal.js';
export {
isNewExpression,
isCallExpression,
isCallOrNewExpression,
} = require('./call-or-new-expression.js');
} from './call-or-new-expression.js';
module.exports = {
isLiteral,
isStringLiteral,
isNumberLiteral,
isBigIntLiteral,
isNullLiteral,
isRegexLiteral,
isArrowFunctionBody: require('./is-arrow-function-body.js'),
isCallExpression,
isCallOrNewExpression,
isDirective: require('./is-directive.js'),
isEmptyNode: require('./is-empty-node.js'),
isExpressionStatement: require('./is-expression-statement.js'),
isFunction: require('./is-function.js'),
isMemberExpression: require('./is-member-expression.js'),
isMethodCall: require('./is-method-call.js'),
isNegativeOne: require('./is-negative-one.js'),
isNewExpression,
isReferenceIdentifier: require('./is-reference-identifier.js'),
isStaticRequire: require('./is-static-require.js'),
isTaggedTemplateLiteral: require('./is-tagged-template-literal.js'),
isUndefined: require('./is-undefined.js'),
functionTypes: require('./function-types.js'),
};
export {default as isArrowFunctionBody} from './is-arrow-function-body.js';
export {default as isDirective} from './is-directive.js';
export {default as isEmptyNode} from './is-empty-node.js';
export {default as isExpressionStatement} from './is-expression-statement.js';
export {default as isFunction} from './is-function.js';
export {default as isMemberExpression} from './is-member-expression.js';
export {default as isMethodCall} from './is-method-call.js';
export {default as isNegativeOne} from './is-negative-one.js';
export {default as isReferenceIdentifier} from './is-reference-identifier.js';
export {default as isStaticRequire} from './is-static-require.js';
export {default as isTaggedTemplateLiteral} from './is-tagged-template-literal.js';
export {default as isUndefined} from './is-undefined.js';
export {default as functionTypes} from './function-types.js';

@@ -1,7 +0,3 @@

'use strict';
function isArrowFunctionBody(node) {
export default function isArrowFunctionBody(node) {
return node.parent.type === 'ArrowFunctionExpression' && node.parent.body === node;
}
module.exports = isArrowFunctionBody;

@@ -1,7 +0,4 @@

'use strict';
const isDirective = node =>
node.type === 'ExpressionStatement'
const isDirective = node => node.type === 'ExpressionStatement'
&& typeof node.directive === 'string';
module.exports = isDirective;
export default isDirective;

@@ -1,3 +0,2 @@

'use strict';
function isEmptyNode(node, additionalEmpty) {
export default function isEmptyNode(node, additionalEmpty) {
const {type} = node;

@@ -19,3 +18,1 @@

}
module.exports = isEmptyNode;

@@ -1,4 +0,2 @@

'use strict';
function isExpressionStatement(node) {
export default function isExpressionStatement(node) {
return node.type === 'ExpressionStatement'

@@ -10,3 +8,1 @@ || (

}
module.exports = isExpressionStatement;

@@ -1,8 +0,5 @@

'use strict';
const functionTypes = require('./function-types.js');
import functionTypes from './function-types.js';
function isFunction(node) {
export default function isFunction(node) {
return functionTypes.includes(node.type);
}
module.exports = isFunction;

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -16,3 +14,3 @@ @param {

*/
function isMemberExpression(node, options) {
export default function isMemberExpression(node, options) {
if (node?.type !== 'MemberExpression') {

@@ -101,3 +99,1 @@ return false;

}
module.exports = isMemberExpression;

@@ -1,4 +0,3 @@

'use strict';
const isMemberExpression = require('./is-member-expression.js');
const {isCallExpression} = require('./call-or-new-expression.js');
import isMemberExpression from './is-member-expression.js';
import {isCallExpression} from './call-or-new-expression.js';

@@ -26,3 +25,3 @@ /**

*/
function isMethodCall(node, options) {
export default function isMethodCall(node, options) {
if (typeof options === 'string') {

@@ -65,3 +64,1 @@ options = {methods: [options]};

}
module.exports = isMethodCall;

@@ -1,6 +0,4 @@

'use strict';
import {isNumberLiteral} from './literal.js';
const {isNumberLiteral} = require('./literal.js');
function isNegativeOne(node) {
export default function isNegativeOne(node) {
return node?.type === 'UnaryExpression'

@@ -11,3 +9,1 @@ && node.operator === '-'

}
module.exports = isNegativeOne;

@@ -1,3 +0,1 @@

'use strict';
// eslint-disable-next-line complexity

@@ -150,3 +148,3 @@ function isNotReference(node) {

function isReferenceIdentifier(node, nameOrNames = []) {
export default function isReferenceIdentifier(node, nameOrNames = []) {
if (node.type !== 'Identifier') {

@@ -163,3 +161,1 @@ return false;

}
module.exports = isReferenceIdentifier;

@@ -1,14 +0,10 @@

'use strict';
import {isStringLiteral} from './literal.js';
import {isCallExpression} from './call-or-new-expression.js';
const {isStringLiteral} = require('./literal.js');
const {isCallExpression} = require('./call-or-new-expression.js');
const isStaticRequire = node => isCallExpression(node, {
name: 'require',
argumentsLength: 1,
optional: false,
}) && isStringLiteral(node.arguments[0]);
const isStaticRequire = node =>
isCallExpression(node, {
name: 'require',
argumentsLength: 1,
optional: false,
})
&& isStringLiteral(node.arguments[0]);
module.exports = isStaticRequire;
export default isStaticRequire;

@@ -1,5 +0,3 @@

'use strict';
import {isNodeMatches} from '../utils/is-node-matches.js';
const {isNodeMatches} = require('../utils/is-node-matches.js');
/**

@@ -12,3 +10,3 @@ Check if the given node is a tagged template literal.

*/
function isTaggedTemplateLiteral(node, tags) {
export default function isTaggedTemplateLiteral(node, tags) {
if (

@@ -28,3 +26,1 @@ node.type !== 'TemplateLiteral'

}
module.exports = isTaggedTemplateLiteral;

@@ -1,7 +0,3 @@

'use strict';
function isUndefined(node) {
export default function isUndefined(node) {
return node.type === 'Identifier' && node.name === 'undefined';
}
module.exports = isUndefined;

@@ -1,4 +0,2 @@

'use strict';
function isLiteral(node, value) {
export function isLiteral(node, value) {
if (node?.type !== 'Literal') {

@@ -15,16 +13,12 @@ return false;

const isStringLiteral = node => node?.type === 'Literal' && typeof node.value === 'string';
const isNumberLiteral = node => node.type === 'Literal' && typeof node.value === 'number';
const isRegexLiteral = node => node.type === 'Literal' && Boolean(node.regex);
export const isStringLiteral = node => node?.type === 'Literal' && typeof node.value === 'string';
export const isNumberLiteral = node => node.type === 'Literal' && typeof node.value === 'number';
export const isRegexLiteral = node => node.type === 'Literal' && Boolean(node.regex);
// eslint-disable-next-line unicorn/no-null
const isNullLiteral = node => isLiteral(node, null);
const isBigIntLiteral = node => node.type === 'Literal' && Boolean(node.bigint);
export const isNullLiteral = node => isLiteral(node, null);
module.exports = {
isLiteral,
isStringLiteral,
isNumberLiteral,
isBigIntLiteral,
isNullLiteral,
isRegexLiteral,
};
export const isBigIntLiteral = node => node.type === 'Literal' && Boolean(node.bigint);

@@ -1,6 +0,5 @@

'use strict';
const cleanRegexp = require('clean-regexp');
const {optimize} = require('regexp-tree');
const escapeString = require('./utils/escape-string.js');
const {isStringLiteral, isNewExpression, isRegexLiteral} = require('./ast/index.js');
import cleanRegexp from 'clean-regexp';
import regexpTree from 'regexp-tree';
import escapeString from './utils/escape-string.js';
import {isStringLiteral, isNewExpression, isRegexLiteral} from './ast/index.js';

@@ -40,3 +39,3 @@ const MESSAGE_ID = 'better-regex';

try {
optimized = optimize(original, undefined, {blacklist: ignoreList}).toString();
optimized = regexpTree.optimize(original, undefined, {blacklist: ignoreList}).toString();
} catch (error) {

@@ -127,3 +126,2 @@ return {

type: 'boolean',
default: true,
},

@@ -135,3 +133,3 @@ },

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -146,4 +144,7 @@ meta: {

schema,
defaultOptions: [{sortCharacterClasses: true}],
messages,
},
};
export default config;

@@ -1,6 +0,6 @@

'use strict';
const {findVariable} = require('@eslint-community/eslint-utils');
const avoidCapture = require('./utils/avoid-capture.js');
const {renameVariable} = require('./fix/index.js');
const {isMethodCall} = require('./ast/index.js');
import {isRegExp} from 'node:util/types';
import {findVariable} from '@eslint-community/eslint-utils';
import {getAvailableVariableName} from './utils/index.js';
import {renameVariable} from './fix/index.js';
import {isMethodCall} from './ast/index.js';

@@ -44,3 +44,3 @@ const MESSAGE_ID = 'catch-error-name';

const ignore = options.ignore.map(
pattern => pattern instanceof RegExp ? pattern : new RegExp(pattern, 'u'),
pattern => isRegExp(pattern) ? pattern : new RegExp(pattern, 'u'),
);

@@ -89,3 +89,3 @@ const isNameAllowed = name =>

];
const fixedName = avoidCapture(expectedName, scopes);
const fixedName = getAvailableVariableName(expectedName, scopes);

@@ -127,3 +127,3 @@ const problem = {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -138,4 +138,7 @@ meta: {

schema,
defaultOptions: [{}],
messages,
},
};
export default config;

@@ -1,5 +0,3 @@

'use strict';
const avoidCapture = require('./utils/avoid-capture.js');
const isLeftHandSide = require('./utils/is-left-hand-side.js');
const {isCallOrNewExpression} = require('./ast/index.js');
import {getAvailableVariableName, isLeftHandSide} from './utils/index.js';
import {isCallOrNewExpression} from './ast/index.js';

@@ -111,3 +109,3 @@ const MESSAGE_ID = 'consistentDestructuring';

// Destructured member collides with an existing identifier
if (avoidCapture(member, [memberScope]) !== member) {
if (getAvailableVariableName(member, [memberScope]) !== member) {
return;

@@ -155,3 +153,3 @@ }

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -172,1 +170,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {getStaticValue} = require('@eslint-community/eslint-utils');
import {getStaticValue} from '@eslint-community/eslint-utils';

@@ -114,3 +113,3 @@ const MESSAGE_ID = 'consistent-empty-array-spread';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -128,1 +127,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const toLocation = require('./utils/to-location.js');
const {isMethodCall, isNegativeOne, isNumberLiteral} = require('./ast/index.js');
import toLocation from './utils/to-location.js';
import {isMethodCall, isNegativeOne, isNumberLiteral} from './ast/index.js';

@@ -100,5 +99,8 @@ const MESSAGE_ID = 'consistent-existence-index-check';

const [start] = sourceCode.getRange(operatorToken);
const [, end] = sourceCode.getRange(right);
yield {
node: binaryExpression,
loc: toLocation([operatorToken.range[0], right.range[1]], sourceCode),
loc: toLocation([start, end], sourceCode),
messageId: MESSAGE_ID,

@@ -122,3 +124,3 @@ data: {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -136,1 +138,3 @@ meta: {

};
export default config;

@@ -1,10 +0,4 @@

'use strict';
const {getFunctionHeadLocation, getFunctionNameWithKind} = require('@eslint-community/eslint-utils');
const {
getReferences,
isNodeMatches,
} = require('./utils/index.js');
const {
functionTypes,
} = require('./ast/index.js');
import {getFunctionHeadLocation, getFunctionNameWithKind} from '@eslint-community/eslint-utils';
import {getReferences, isNodeMatches} from './utils/index.js';
import {functionTypes} from './ast/index.js';

@@ -206,3 +200,2 @@ const MESSAGE_ID = 'consistent-function-scoping';

type: 'boolean',
default: true,
},

@@ -214,3 +207,3 @@ },

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -224,4 +217,7 @@ meta: {

schema,
defaultOptions: [{checkArrowFunctions: true}],
messages,
},
};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {upperFirst} = require('./utils/lodash.js');
import {upperFirst} from './utils/lodash.js';

@@ -81,3 +80,5 @@ const MESSAGE_ID_INVALID_EXPORT = 'invalidExport';

const {body, range} = node.body;
const {sourceCode} = context;
const {body} = node.body;
const range = sourceCode.getRange(node.body);
const constructor = body.find(x => x.kind === 'constructor');

@@ -123,12 +124,11 @@

const rhs = expression.expression.right;
yield fixer.insertTextAfterRange([
superExpression.range[0],
superExpression.range[0] + 6,
], rhs.raw || rhs.name);
const [start] = sourceCode.getRange(superExpression);
yield fixer.insertTextAfterRange([start, start + 6], rhs.raw || rhs.name);
}
yield fixer.removeRange([
messageExpressionIndex === 0 ? constructorBodyNode.range[0] : constructorBody[messageExpressionIndex - 1].range[1],
expression.range[1],
]);
const start = messageExpressionIndex === 0
? sourceCode.getRange(constructorBodyNode)[0]
: sourceCode.getRange(constructorBody[messageExpressionIndex - 1])[1];
const [, end] = sourceCode.getRange(expression);
yield fixer.removeRange([start, end]);
},

@@ -207,3 +207,3 @@ };

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -220,1 +220,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {isOpeningBraceToken} = require('@eslint-community/eslint-utils');
import {isOpeningBraceToken} from '@eslint-community/eslint-utils';

@@ -16,4 +15,4 @@ const MESSAGE_ID = 'empty-brace-spaces';

const closingBrace = sourceCode.getLastToken(node);
const [, start] = openingBrace.range;
const [end] = closingBrace.range;
const [, start] = sourceCode.getRange(openingBrace);
const [end] = sourceCode.getRange(closingBrace);
const textBetween = sourceCode.text.slice(start, end);

@@ -27,4 +26,4 @@

loc: {
start: openingBrace.loc.end,
end: closingBrace.loc.start,
start: sourceCode.getLoc(openingBrace).end,
end: sourceCode.getLoc(closingBrace).start,
},

@@ -64,3 +63,3 @@ messageId: MESSAGE_ID,

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -77,1 +76,3 @@ meta: {

};
export default config;

@@ -1,5 +0,5 @@

'use strict';
const {getStaticValue} = require('@eslint-community/eslint-utils');
const isShadowed = require('./utils/is-shadowed.js');
const {isCallOrNewExpression} = require('./ast/index.js');
import {getStaticValue} from '@eslint-community/eslint-utils';
import isShadowed from './utils/is-shadowed.js';
import {isCallOrNewExpression} from './ast/index.js';
import builtinErrors from './shared/builtin-errors.js';

@@ -15,15 +15,2 @@ const MESSAGE_ID_MISSING_MESSAGE = 'missing-message';

const builtinErrors = [
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
'Error',
'EvalError',
'RangeError',
'ReferenceError',
'SyntaxError',
'TypeError',
'URIError',
'InternalError',
'AggregateError',
];
/** @param {import('eslint').Rule.RuleContext} context */

@@ -96,3 +83,3 @@ const create = context => {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -108,1 +95,3 @@ meta: {

};
export default config;

@@ -1,8 +0,3 @@

'use strict';
const {replaceTemplateElement} = require('./fix/index.js');
const {
isRegexLiteral,
isStringLiteral,
isTaggedTemplateLiteral,
} = require('./ast/index.js');
import {replaceTemplateElement} from './fix/index.js';
import {isRegexLiteral, isStringLiteral, isTaggedTemplateLiteral} from './ast/index.js';

@@ -63,3 +58,3 @@ const MESSAGE_ID = 'escape-case';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -76,1 +71,3 @@ meta: {

};
export default config;

@@ -1,7 +0,7 @@

'use strict';
const path = require('node:path');
const readPkgUp = require('read-pkg-up');
const semver = require('semver');
const ci = require('ci-info');
const getBuiltinRule = require('./utils/get-builtin-rule.js');
import path from 'node:path';
import {isRegExp} from 'node:util/types';
import {readPackageUpSync} from 'read-package-up';
import semver from 'semver';
import * as ci from 'ci-info';
import getBuiltinRule from './utils/get-builtin-rule.js';

@@ -59,3 +59,3 @@ const baseRule = getBuiltinRule('no-warning-comments');

try {
packageResult = readPkgUp.sync({normalize: false, cwd: dirname});
packageResult = readPackageUpSync({normalize: false, cwd: dirname});
} catch {

@@ -291,3 +291,3 @@ // This can happen if package.json files have comments in them etc.

const ignoreRegexes = options.ignore.map(
pattern => pattern instanceof RegExp ? pattern : new RegExp(pattern, 'u'),
pattern => isRegExp(pattern) ? pattern : new RegExp(pattern, 'u'),
);

@@ -359,3 +359,3 @@

context.report({
loc: comment.loc,
loc: sourceCode.getLoc(comment),
messageId: MESSAGE_ID_AVOID_MULTIPLE_DATES,

@@ -374,3 +374,3 @@ data: {

context.report({
loc: comment.loc,
loc: sourceCode.getLoc(comment),
messageId: MESSAGE_ID_EXPIRED_TODO,

@@ -388,3 +388,3 @@ data: {

context.report({
loc: comment.loc,
loc: sourceCode.getLoc(comment),
messageId: MESSAGE_ID_AVOID_MULTIPLE_PACKAGE_VERSIONS,

@@ -408,3 +408,3 @@ data: {

context.report({
loc: comment.loc,
loc: sourceCode.getLoc(comment),
messageId: MESSAGE_ID_REACHED_PACKAGE_VERSION,

@@ -435,3 +435,3 @@ data: {

context.report({
loc: comment.loc,
loc: sourceCode.getLoc(comment),
messageId,

@@ -462,3 +462,3 @@ data: {

context.report({
loc: comment.loc,
loc: sourceCode.getLoc(comment),
messageId: MESSAGE_ID_VERSION_MATCHES,

@@ -495,3 +495,3 @@ data: {

context.report({
loc: comment.loc,
loc: sourceCode.getLoc(comment),
messageId: MESSAGE_ID_ENGINE_MATCHES,

@@ -520,3 +520,3 @@ data: {

context.report({
loc: comment.loc,
loc: sourceCode.getLoc(comment),
messageId: MESSAGE_ID_MISSING_AT_SYMBOL,

@@ -538,3 +538,3 @@ data: {

context.report({
loc: comment.loc,
loc: sourceCode.getLoc(comment),
messageId: MESSAGE_ID_REMOVE_WHITESPACE,

@@ -578,7 +578,5 @@ data: {

type: 'boolean',
default: true,
},
allowWarningComments: {
type: 'boolean',
default: true,
},

@@ -594,3 +592,3 @@ date: {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -608,1 +606,3 @@ meta: {

};
export default config;

@@ -1,8 +0,7 @@

'use strict';
const {isParenthesized, getStaticValue} = require('@eslint-community/eslint-utils');
const {checkVueTemplate} = require('./utils/rule.js');
const isLogicalExpression = require('./utils/is-logical-expression.js');
const {isBooleanNode, getBooleanAncestor} = require('./utils/boolean.js');
const {fixSpaceAroundKeyword} = require('./fix/index.js');
const {isLiteral, isMemberExpression, isNumberLiteral} = require('./ast/index.js');
import {isParenthesized, getStaticValue} from '@eslint-community/eslint-utils';
import {checkVueTemplate} from './utils/rule.js';
import isLogicalExpression from './utils/is-logical-expression.js';
import {isBooleanNode, getBooleanAncestor} from './utils/boolean.js';
import {fixSpaceAroundKeyword} from './fix/index.js';
import {isLiteral, isMemberExpression, isNumberLiteral} from './ast/index.js';

@@ -222,3 +221,3 @@ const TYPE_NON_ZERO = 'non-zero';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create: checkVueTemplate(create),

@@ -237,1 +236,3 @@ meta: {

};
export default config;

@@ -1,5 +0,10 @@

'use strict';
const path = require('node:path');
const {camelCase, kebabCase, snakeCase, upperFirst} = require('./utils/lodash.js');
const cartesianProductSamples = require('./utils/cartesian-product-samples.js');
import path from 'node:path';
import {isRegExp} from 'node:util/types';
import {
camelCase,
kebabCase,
snakeCase,
upperFirst,
} from './utils/lodash.js';
import cartesianProductSamples from './utils/cartesian-product-samples.js';

@@ -163,3 +168,3 @@ const MESSAGE_ID = 'filename-case';

const ignore = (options.ignore || []).map(item => {
if (item instanceof RegExp) {
if (isRegExp(item)) {
return item;

@@ -282,3 +287,3 @@ }

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -292,4 +297,8 @@ meta: {

schema,
// eslint-disable-next-line eslint-plugin/require-meta-default-options
defaultOptions: [],
messages,
},
};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {isSemicolonToken} = require('@eslint-community/eslint-utils');
import {isSemicolonToken} from '@eslint-community/eslint-utils';
function * addParenthesizesToReturnOrThrowExpression(fixer, node, sourceCode) {
export default function * addParenthesizesToReturnOrThrowExpression(fixer, node, sourceCode) {
if (node.type !== 'ReturnStatement' && node.type !== 'ThrowStatement') {

@@ -11,3 +10,2 @@ return;

yield fixer.insertTextAfter(returnOrThrowToken, ' (');
const lastToken = sourceCode.getLastToken(node);

@@ -21,3 +19,1 @@ if (!isSemicolonToken(lastToken)) {

}
module.exports = addParenthesizesToReturnOrThrowExpression;

@@ -1,5 +0,4 @@

'use strict';
const {isCommaToken} = require('@eslint-community/eslint-utils');
import {isCommaToken} from '@eslint-community/eslint-utils';
function appendArgument(fixer, node, text, sourceCode) {
export default function appendArgument(fixer, node, text, sourceCode) {
// This function should also work for `NewExpression`

@@ -19,3 +18,1 @@ // But parentheses of `NewExpression` could be omitted, add this check to prevent accident use on it

}
module.exports = appendArgument;

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -10,7 +8,5 @@ Extend fix range to prevent changes from other rules.

*/
function * extendFixRange(fixer, range) {
export default function * extendFixRange(fixer, range) {
yield fixer.insertTextBeforeRange(range, '');
yield fixer.insertTextAfterRange(range, '');
}
module.exports = extendFixRange;

@@ -1,3 +0,2 @@

'use strict';
const {getParenthesizedRange} = require('../utils/parentheses.js');
import {getParenthesizedRange} from '../utils/parentheses.js';

@@ -12,3 +11,3 @@ const isProblematicToken = ({type, value}) => (

function * fixSpaceAroundKeyword(fixer, node, sourceCode) {
export default function * fixSpaceAroundKeyword(fixer, node, sourceCode) {
const range = getParenthesizedRange(node, sourceCode);

@@ -35,3 +34,1 @@ const tokenBefore = sourceCode.getTokenBefore({range}, {includeComments: true});

}
module.exports = fixSpaceAroundKeyword;

@@ -1,23 +0,18 @@

'use strict';
module.exports = {
// Utilities
extendFixRange: require('./extend-fix-range.js'),
removeParentheses: require('./remove-parentheses.js'),
appendArgument: require('./append-argument.js'),
removeArgument: require('./remove-argument.js'),
replaceArgument: require('./replace-argument.js'),
switchNewExpressionToCallExpression: require('./switch-new-expression-to-call-expression.js'),
switchCallExpressionToNewExpression: require('./switch-call-expression-to-new-expression.js'),
removeMemberExpressionProperty: require('./remove-member-expression-property.js'),
removeMethodCall: require('./remove-method-call.js'),
replaceTemplateElement: require('./replace-template-element.js'),
replaceReferenceIdentifier: require('./replace-reference-identifier.js'),
renameVariable: require('./rename-variable.js'),
replaceNodeOrTokenAndSpacesBefore: require('./replace-node-or-token-and-spaces-before.js'),
removeSpacesAfter: require('./remove-spaces-after.js'),
fixSpaceAroundKeyword: require('./fix-space-around-keywords.js'),
replaceStringLiteral: require('./replace-string-literal.js'),
addParenthesizesToReturnOrThrowExpression: require('./add-parenthesizes-to-return-or-throw-expression.js'),
};
export {default as extendFixRange} from './extend-fix-range.js';
export {default as removeParentheses} from './remove-parentheses.js';
export {default as appendArgument} from './append-argument.js';
export {default as removeArgument} from './remove-argument.js';
export {default as replaceArgument} from './replace-argument.js';
export {default as switchNewExpressionToCallExpression} from './switch-new-expression-to-call-expression.js';
export {default as switchCallExpressionToNewExpression} from './switch-call-expression-to-new-expression.js';
export {default as removeMemberExpressionProperty} from './remove-member-expression-property.js';
export {default as removeMethodCall} from './remove-method-call.js';
export {default as replaceTemplateElement} from './replace-template-element.js';
export {default as replaceReferenceIdentifier} from './replace-reference-identifier.js';
export {default as renameVariable} from './rename-variable.js';
export {default as replaceNodeOrTokenAndSpacesBefore} from './replace-node-or-token-and-spaces-before.js';
export {default as removeSpacesAfter} from './remove-spaces-after.js';
export {default as removeSpecifier} from './remove-specifier.js';
export {default as fixSpaceAroundKeyword} from './fix-space-around-keywords.js';
export {default as replaceStringRaw} from './replace-string-raw.js';
export {default as addParenthesizesToReturnOrThrowExpression} from './add-parenthesizes-to-return-or-throw-expression.js';

@@ -1,6 +0,5 @@

'use strict';
const {isCommaToken} = require('@eslint-community/eslint-utils');
const {getParentheses} = require('../utils/parentheses.js');
import {isCommaToken} from '@eslint-community/eslint-utils';
import {getParentheses} from '../utils/parentheses.js';
function removeArgument(fixer, node, sourceCode) {
export default function removeArgument(fixer, node, sourceCode) {
const callExpression = node.parent;

@@ -12,7 +11,8 @@ const index = callExpression.arguments.indexOf(node);

let [start] = firstToken.range;
let [, end] = lastToken.range;
let [start] = sourceCode.getRange(firstToken);
let [, end] = sourceCode.getRange(lastToken);
if (index !== 0) {
start = sourceCode.getTokenBefore(firstToken).range[0];
const commaToken = sourceCode.getTokenBefore(firstToken);
[start] = sourceCode.getRange(commaToken);
}

@@ -25,3 +25,3 @@

if (isCommaToken(tokenAfter)) {
end = tokenAfter[1];
[, end] = sourceCode.getRange(tokenAfter);
}

@@ -31,5 +31,3 @@ }

return fixer.replaceTextRange([start, end], '');
return fixer.removeRange([start, end]);
}
module.exports = removeArgument;

@@ -1,11 +0,7 @@

'use strict';
const {getParenthesizedRange} = require('../utils/parentheses.js');
import {getParenthesizedRange} from '../utils/parentheses.js';
function removeMemberExpressionProperty(fixer, memberExpression, sourceCode) {
export default function removeMemberExpressionProperty(fixer, memberExpression, sourceCode) {
const [, start] = getParenthesizedRange(memberExpression.object, sourceCode);
const [, end] = memberExpression.range;
const [, end] = sourceCode.getRange(memberExpression);
return fixer.removeRange([start, end]);
}
module.exports = removeMemberExpressionProperty;

@@ -1,6 +0,5 @@

'use strict';
const {getParenthesizedRange} = require('../utils/parentheses.js');
const removeMemberExpressionProperty = require('./remove-member-expression-property.js');
import {getParenthesizedRange} from '../utils/parentheses.js';
import removeMemberExpressionProperty from './remove-member-expression-property.js';
function * removeMethodCall(fixer, callExpression, sourceCode) {
export default function * removeMethodCall(fixer, callExpression, sourceCode) {
const memberExpression = callExpression.callee;

@@ -15,7 +14,5 @@

const [, start] = getParenthesizedRange(memberExpression, sourceCode);
const [, end] = callExpression.range;
const [, end] = sourceCode.getRange(callExpression);
yield fixer.removeRange([start, end]);
}
module.exports = removeMethodCall;

@@ -1,5 +0,4 @@

'use strict';
const {getParentheses} = require('../utils/parentheses.js');
import {getParentheses} from '../utils/parentheses.js';
function * removeParentheses(node, fixer, sourceCode) {
export default function * removeParentheses(node, fixer, sourceCode) {
const parentheses = getParentheses(node, sourceCode);

@@ -10,3 +9,1 @@ for (const token of parentheses) {

}
module.exports = removeParentheses;

@@ -1,4 +0,2 @@

'use strict';
function removeSpacesAfter(indexOrNodeOrToken, sourceCode, fixer) {
export default function removeSpacesAfter(indexOrNodeOrToken, sourceCode, fixer) {
let index = indexOrNodeOrToken;

@@ -13,3 +11,1 @@ if (typeof indexOrNodeOrToken === 'object' && Array.isArray(indexOrNodeOrToken.range)) {

}
module.exports = removeSpacesAfter;

@@ -1,9 +0,7 @@

'use strict';
const getVariableIdentifiers = require('../utils/get-variable-identifiers.js');
const replaceReferenceIdentifier = require('./replace-reference-identifier.js');
import getVariableIdentifiers from '../utils/get-variable-identifiers.js';
import replaceReferenceIdentifier from './replace-reference-identifier.js';
const renameVariable = (variable, name, fixer) =>
getVariableIdentifiers(variable)
.map(identifier => replaceReferenceIdentifier(identifier, name, fixer));
const renameVariable = (variable, name, fixer) => getVariableIdentifiers(variable)
.map(identifier => replaceReferenceIdentifier(identifier, name, fixer));
module.exports = renameVariable;
export default renameVariable;

@@ -1,8 +0,5 @@

'use strict';
const {getParenthesizedRange} = require('../utils/parentheses.js');
import {getParenthesizedRange} from '../utils/parentheses.js';
function replaceArgument(fixer, node, text, sourceCode) {
export default function replaceArgument(fixer, node, text, sourceCode) {
return fixer.replaceTextRange(getParenthesizedRange(node, sourceCode), text);
}
module.exports = replaceArgument;

@@ -1,5 +0,4 @@

'use strict';
const {getParentheses} = require('../utils/parentheses.js');
import {getParentheses} from '../utils/parentheses.js';
function * replaceNodeOrTokenAndSpacesBefore(nodeOrToken, replacement, fixer, sourceCode, tokenStore = sourceCode) {
export default function * replaceNodeOrTokenAndSpacesBefore(nodeOrToken, replacement, fixer, sourceCode, tokenStore = sourceCode) {
const tokens = getParentheses(nodeOrToken, tokenStore);

@@ -11,3 +10,3 @@

let [start, end] = nodeOrToken.range;
let [start, end] = sourceCode.getRange(nodeOrToken);

@@ -21,3 +20,1 @@ const textBefore = sourceCode.text.slice(0, start);

}
module.exports = replaceNodeOrTokenAndSpacesBefore;

@@ -1,9 +0,7 @@

'use strict';
import isShorthandPropertyValue from '../utils/is-shorthand-property-value.js';
import isShorthandPropertyAssignmentPatternLeft from '../utils/is-shorthand-property-assignment-pattern-left.js';
import isShorthandImportLocal from '../utils/is-shorthand-import-local.js';
import isShorthandExportLocal from '../utils/is-shorthand-export-local.js';
const isShorthandPropertyValue = require('../utils/is-shorthand-property-value.js');
const isShorthandPropertyAssignmentPatternLeft = require('../utils/is-shorthand-property-assignment-pattern-left.js');
const isShorthandImportLocal = require('../utils/is-shorthand-import-local.js');
const isShorthandExportLocal = require('../utils/is-shorthand-export-local.js');
function replaceReferenceIdentifier(identifier, replacement, fixer) {
export default function replaceReferenceIdentifier(identifier, replacement, fixer) {
if (

@@ -34,3 +32,1 @@ isShorthandPropertyValue(identifier)

}
module.exports = replaceReferenceIdentifier;

@@ -1,3 +0,1 @@

'use strict';
// Replace `StringLiteral` or `TemplateLiteral` node with raw text

@@ -14,2 +12,2 @@ const replaceStringRaw = (fixer, node, raw) =>

module.exports = replaceStringRaw;
export default replaceStringRaw;

@@ -1,3 +0,1 @@

'use strict';
const replaceTemplateElement = (fixer, node, replacement) => {

@@ -11,2 +9,2 @@ const {range: [start, end], tail} = node;

module.exports = replaceTemplateElement;
export default replaceTemplateElement;

@@ -1,7 +0,6 @@

'use strict';
const {isParenthesized} = require('../utils/parentheses.js');
const shouldAddParenthesesToNewExpressionCallee = require('../utils/should-add-parentheses-to-new-expression-callee.js');
const fixSpaceAroundKeyword = require('./fix-space-around-keywords.js');
import {isParenthesized} from '../utils/parentheses.js';
import shouldAddParenthesesToNewExpressionCallee from '../utils/should-add-parentheses-to-new-expression-callee.js';
import fixSpaceAroundKeyword from './fix-space-around-keywords.js';
function * switchCallExpressionToNewExpression(node, sourceCode, fixer) {
export default function * switchCallExpressionToNewExpression(node, sourceCode, fixer) {
yield * fixSpaceAroundKeyword(fixer, node, sourceCode);

@@ -19,3 +18,1 @@ yield fixer.insertTextBefore(node, 'new ');

}
module.exports = switchCallExpressionToNewExpression;

@@ -1,9 +0,8 @@

'use strict';
const isNewExpressionWithParentheses = require('../utils/is-new-expression-with-parentheses.js');
const {isParenthesized} = require('../utils/parentheses.js');
const isOnSameLine = require('../utils/is-on-same-line.js');
const addParenthesizesToReturnOrThrowExpression = require('./add-parenthesizes-to-return-or-throw-expression.js');
const removeSpaceAfter = require('./remove-spaces-after.js');
import isNewExpressionWithParentheses from '../utils/is-new-expression-with-parentheses.js';
import {isParenthesized} from '../utils/parentheses.js';
import isOnSameLine from '../utils/is-on-same-line.js';
import addParenthesizesToReturnOrThrowExpression from './add-parenthesizes-to-return-or-throw-expression.js';
import removeSpaceAfter from './remove-spaces-after.js';
function * switchNewExpressionToCallExpression(newExpression, sourceCode, fixer) {
export default function * switchNewExpressionToCallExpression(newExpression, sourceCode, fixer) {
const newToken = sourceCode.getFirstToken(newExpression);

@@ -33,3 +32,1 @@ yield fixer.remove(newToken);

}
module.exports = switchNewExpressionToCallExpression;

@@ -1,5 +0,4 @@

'use strict';
const {defaultsDeep} = require('./utils/lodash.js');
const {getStringIfConstant} = require('@eslint-community/eslint-utils');
const {isCallExpression} = require('./ast/index.js');
import {getStringIfConstant} from '@eslint-community/eslint-utils';
import {defaultsDeep} from './utils/lodash.js';
import {isCallExpression} from './ast/index.js';

@@ -360,3 +359,3 @@ const MESSAGE_ID = 'importStyle';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -370,4 +369,7 @@ meta: {

schema,
defaultOptions: [{}],
messages,
},
};
export default config;

@@ -1,12 +0,17 @@

'use strict';
const {GlobalReferenceTracker} = require('./utils/global-reference-tracker.js');
const builtins = require('./utils/builtins.js');
const {
import {GlobalReferenceTracker} from './utils/global-reference-tracker.js';
import * as builtins from './utils/builtins.js';
import {
switchCallExpressionToNewExpression,
switchNewExpressionToCallExpression,
} = require('./fix/index.js');
fixSpaceAroundKeyword,
} from './fix/index.js';
const MESSAGE_ID_ERROR_DATE = 'error-date';
const MESSAGE_ID_SUGGESTION_DATE = 'suggestion-date';
const messages = {
enforce: 'Use `new {{name}}()` instead of `{{name}}()`.',
disallow: 'Use `{{name}}()` instead of `new {{name}}()`.',
[MESSAGE_ID_ERROR_DATE]: 'Use `String(new Date())` instead of `Date()`.',
[MESSAGE_ID_SUGGESTION_DATE]: 'Switch to `String(new Date())`.',
};

@@ -26,2 +31,29 @@

// `Date()` returns a string representation of the current date and time, exactly as `new Date().toString()` does.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#return_value
if (name === 'Date') {
function * fix(fixer) {
yield fixer.replaceText(node, 'String(new Date())');
yield * fixSpaceAroundKeyword(fixer, node, sourceCode);
}
const problem = {
node,
messageId: MESSAGE_ID_ERROR_DATE,
};
if (sourceCode.getCommentsInside(node).length === 0 && node.arguments.length === 0) {
problem.fix = fix;
} else {
problem.suggest = [
{
messageId: MESSAGE_ID_SUGGESTION_DATE,
fix,
},
];
}
return problem;
}
return {

@@ -76,3 +108,3 @@ node,

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -86,4 +118,7 @@ meta: {

fixable: 'code',
hasSuggestions: true,
messages,
},
};
export default config;

@@ -1,3 +0,1 @@

'use strict';
const MESSAGE_ID = 'no-abusive-eslint-disable';

@@ -11,3 +9,3 @@ const messages = {

/** @param {import('eslint').Rule.RuleContext} context */
const create = () => ({
const create = context => ({
* Program(node) {

@@ -22,2 +20,4 @@ for (const comment of node.comments) {

) {
const {sourceCode} = context;
yield {

@@ -28,6 +28,6 @@ // Can't set it at the given location as the warning

start: {
...comment.loc.start,
...sourceCode.getLoc(comment).start,
column: -1,
},
end: comment.loc.end,
end: sourceCode.getLoc(comment).end,
},

@@ -42,3 +42,3 @@ messageId: MESSAGE_ID,

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -54,1 +54,3 @@ meta: {

};
export default config;

@@ -1,20 +0,11 @@

'use strict';
import path from 'node:path';
import {getFunctionHeadLocation, getFunctionNameWithKind, isOpeningParenToken} from '@eslint-community/eslint-utils';
import helperValidatorIdentifier from '@babel/helper-validator-identifier';
import getClassHeadLocation from './utils/get-class-head-location.js';
import {upperFirst, camelCase} from './utils/lodash.js';
import {getParenthesizedRange} from './utils/parentheses.js';
import {getScopes, getAvailableVariableName} from './utils/index.js';
import {isMemberExpression} from './ast/index.js';
const path = require('node:path');
const {
getFunctionHeadLocation,
getFunctionNameWithKind,
isOpeningParenToken,
} = require('@eslint-community/eslint-utils');
const {
isIdentifierName,
} = require('@babel/helper-validator-identifier');
const getClassHeadLocation = require('./utils/get-class-head-location.js');
const {upperFirst, camelCase} = require('./utils/lodash.js');
const {getParenthesizedRange} = require('./utils/parentheses.js');
const {
getScopes,
avoidCapture,
} = require('./utils/index.js');
const {isMemberExpression} = require('./ast/index.js');
const {isIdentifierName} = helperValidatorIdentifier;

@@ -54,3 +45,3 @@ const MESSAGE_ID_ERROR = 'no-anonymous-default-export/error';

name = node.type === 'ClassDeclaration' || node.type === 'ClassExpression' ? upperFirst(name) : name;
name = avoidCapture(name, getScopes(sourceCode.getScope(node)));
name = getAvailableVariableName(name, getScopes(sourceCode.getScope(node)));

@@ -77,5 +68,6 @@ return name;

);
const characterBefore = sourceCode.text.charAt(sourceCode.getRange(openingParenthesisToken)[0] - 1);
return fixer.insertTextBefore(
openingParenthesisToken,
`${sourceCode.text.charAt(openingParenthesisToken.range[0] - 1) === ' ' ? '' : ' '}${name} `,
`${characterBefore === ' ' ? '' : ' '}${name} `,
);

@@ -86,5 +78,7 @@ }

const [exportDeclarationStart, exportDeclarationEnd]
= node.parent.type === 'ExportDefaultDeclaration'
? node.parent.range
: node.parent.parent.range;
= sourceCode.getRange(
node.parent.type === 'ExportDefaultDeclaration'
? node.parent
: node.parent.parent,
);
const [arrowFunctionStart, arrowFunctionEnd] = getParenthesizedRange(node, sourceCode);

@@ -205,3 +199,3 @@

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -218,1 +212,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {isMethodCall} = require('./ast/index.js');
const {
import {isMethodCall} from './ast/index.js';
import {
isNodeMatches,

@@ -10,3 +9,3 @@ isNodeValueNotFunction,

shouldAddParenthesesToCallExpressionCallee,
} = require('./utils/index.js');
} from './utils/index.js';

@@ -276,3 +275,3 @@ const ERROR_WITH_NAME_MESSAGE_ID = 'error-with-name';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -289,1 +288,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {
import {
isParenthesized,

@@ -9,13 +8,21 @@ isCommaToken,

hasSideEffect,
} = require('@eslint-community/eslint-utils');
const {extendFixRange} = require('./fix/index.js');
const needsSemicolon = require('./utils/needs-semicolon.js');
const shouldAddParenthesesToExpressionStatementExpression = require('./utils/should-add-parentheses-to-expression-statement-expression.js');
const shouldAddParenthesesToMemberExpressionObject = require('./utils/should-add-parentheses-to-member-expression-object.js');
const {getParentheses, getParenthesizedRange} = require('./utils/parentheses.js');
const isFunctionSelfUsedInside = require('./utils/is-function-self-used-inside.js');
const {isNodeMatches} = require('./utils/is-node-matches.js');
const assertToken = require('./utils/assert-token.js');
const {fixSpaceAroundKeyword, removeParentheses} = require('./fix/index.js');
const {isArrowFunctionBody, isMethodCall, isReferenceIdentifier, functionTypes} = require('./ast/index.js');
} from '@eslint-community/eslint-utils';
import {
extendFixRange,
fixSpaceAroundKeyword,
removeParentheses,
} from './fix/index.js';
import needsSemicolon from './utils/needs-semicolon.js';
import shouldAddParenthesesToExpressionStatementExpression from './utils/should-add-parentheses-to-expression-statement-expression.js';
import shouldAddParenthesesToMemberExpressionObject from './utils/should-add-parentheses-to-member-expression-object.js';
import {getParentheses, getParenthesizedRange} from './utils/parentheses.js';
import isFunctionSelfUsedInside from './utils/is-function-self-used-inside.js';
import {isNodeMatches} from './utils/is-node-matches.js';
import assertToken from './utils/assert-token.js';
import {
isArrowFunctionBody,
isMethodCall,
isReferenceIdentifier,
functionTypes,
} from './ast/index.js';

@@ -98,8 +105,8 @@ const MESSAGE_ID_ERROR = 'no-array-for-each/error';

= isParenthesized(iterableObject, sourceCode)
|| (
|| (
// `1?.forEach()` -> `(1).entries()`
isOptionalObject
&& shouldUseEntries
&& shouldAddParenthesesToMemberExpressionObject(iterableObject, sourceCode)
);
isOptionalObject
&& shouldUseEntries
&& shouldAddParenthesesToMemberExpressionObject(iterableObject, sourceCode)
);

@@ -118,3 +125,3 @@ text += shouldAddParenthesesToObject ? `(${objectText})` : objectText;

const getForOfLoopHeadRange = () => {
const [start] = callExpression.range;
const [start] = sourceCode.getRange(callExpression);
const [end] = getParenthesizedRange(callback.body, sourceCode);

@@ -261,3 +268,3 @@ return [start, end];

// Prevent possible variable conflicts
yield * extendFixRange(fixer, callExpression.parent.range);
yield * extendFixRange(fixer, sourceCode.getRange(callExpression.parent));
};

@@ -290,5 +297,6 @@ }

const variableName = definition.name.name;
const [callExpressionStart, callExpressionEnd] = callExpression.range;
const [callExpressionStart, callExpressionEnd] = sourceCode.getRange(callExpression);
for (const identifier of allIdentifiers) {
const {name, range: [start, end]} = identifier;
const {name} = identifier;
const [start, end] = sourceCode.getRange(identifier);
if (

@@ -477,3 +485,3 @@ name !== variableName

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -491,1 +499,3 @@ meta: {

};
export default config;

@@ -1,9 +0,8 @@

'use strict';
const {hasSideEffect} = require('@eslint-community/eslint-utils');
const {removeArgument} = require('./fix/index.js');
const {getParentheses, getParenthesizedText} = require('./utils/parentheses.js');
const shouldAddParenthesesToMemberExpressionObject = require('./utils/should-add-parentheses-to-member-expression-object.js');
const {isNodeMatches} = require('./utils/is-node-matches.js');
const {isNodeValueNotFunction} = require('./utils/index.js');
const {isMethodCall} = require('./ast/index.js');
import {hasSideEffect} from '@eslint-community/eslint-utils';
import {removeArgument} from './fix/index.js';
import {getParentheses, getParenthesizedText} from './utils/parentheses.js';
import shouldAddParenthesesToMemberExpressionObject from './utils/should-add-parentheses-to-member-expression-object.js';
import {isNodeMatches} from './utils/is-node-matches.js';
import {isNodeValueNotFunction} from './utils/index.js';
import {isMethodCall} from './ast/index.js';

@@ -213,3 +212,3 @@ const ERROR_PROTOTYPE_METHOD = 'error-prototype-method';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -227,1 +226,3 @@ meta: {

};
export default config;

@@ -1,11 +0,7 @@

'use strict';
const {hasSideEffect, isSemicolonToken} = require('@eslint-community/eslint-utils');
const {
getCallExpressionTokens,
getCallExpressionArgumentsText,
} = require('./utils/index.js');
const isSameReference = require('./utils/is-same-reference.js');
const {isNodeMatches} = require('./utils/is-node-matches.js');
const getPreviousNode = require('./utils/get-previous-node.js');
const {isMethodCall} = require('./ast/index.js');
import {hasSideEffect, isSemicolonToken} from '@eslint-community/eslint-utils';
import {getCallExpressionTokens, getCallExpressionArgumentsText} from './utils/index.js';
import isSameReference from './utils/is-same-reference.js';
import {isNodeMatches} from './utils/is-node-matches.js';
import getPreviousNode from './utils/get-previous-node.js';
import {isMethodCall} from './ast/index.js';

@@ -102,7 +98,6 @@ const ERROR = 'error';

&& isSemicolonToken(sourceCode.getLastToken(secondExpression));
const [, start] = sourceCode.getRange(firstExpression);
const [, end] = sourceCode.getRange(secondExpression);
yield fixer.replaceTextRange(
[firstExpression.range[1], secondExpression.range[1]],
shouldKeepSemicolon ? ';' : '',
);
yield fixer.replaceTextRange([start, end], shouldKeepSemicolon ? ';' : '');
};

@@ -140,3 +135,3 @@

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -152,4 +147,7 @@ meta: {

schema,
defaultOptions: [{}],
messages,
},
};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {isMethodCall} = require('./ast/index.js');
const {isNodeValueNotFunction, isArrayPrototypeProperty} = require('./utils/index.js');
import {isMethodCall} from './ast/index.js';
import {isNodeValueNotFunction, isArrayPrototypeProperty} from './utils/index.js';

@@ -85,3 +84,2 @@ const MESSAGE_ID_REDUCE = 'reduce';

type: 'boolean',
default: true,
},

@@ -118,3 +116,3 @@ },

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -128,4 +126,7 @@ meta: {

schema,
defaultOptions: [{allowSimpleOperations: true}],
messages,
},
};
export default config;

@@ -1,7 +0,3 @@

'use strict';
const {
removeParentheses,
removeMemberExpressionProperty,
} = require('./fix/index.js');
const {isLiteral} = require('./ast/index.js');
import {removeParentheses, removeMemberExpressionProperty} from './fix/index.js';
import {isLiteral} from './ast/index.js';

@@ -80,3 +76,3 @@ const MESSAGE_ID = 'no-await-expression-member';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -93,1 +89,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {isMethodCall} = require('./ast/index.js');
const {removeSpacesAfter} = require('./fix/index.js');
import {isMethodCall} from './ast/index.js';
import {removeSpacesAfter} from './fix/index.js';

@@ -58,3 +57,3 @@ const MESSAGE_ID_ERROR = 'no-await-in-promise-methods/error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -71,1 +70,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const toLocation = require('./utils/to-location.js');
const {isStringLiteral, isMethodCall} = require('./ast/index.js');
import toLocation from './utils/to-location.js';
import {isStringLiteral, isMethodCall} from './ast/index.js';

@@ -20,5 +19,6 @@ const MESSAGE_ID = 'no-console-spaces';

const getProblem = (node, method, position) => {
const [start, end] = sourceCode.getRange(node);
const index = position === 'leading'
? node.range[0] + 1
: node.range[1] - 2;
? start + 1
: end - 2;
const range = [index, index + 1];

@@ -77,3 +77,3 @@

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -90,1 +90,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {GlobalReferenceTracker} = require('./utils/global-reference-tracker.js');
import {GlobalReferenceTracker} from './utils/global-reference-tracker.js';

@@ -16,3 +15,3 @@ const MESSAGE_ID = 'no-document-cookie';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create: context => tracker.createListeners(context),

@@ -28,1 +27,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {isEmptyNode, isDirective} = require('./ast/index.js');
import {isEmptyNode, isDirective} from './ast/index.js';

@@ -47,3 +46,3 @@ const MESSAGE_ID = 'no-empty-file';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -59,1 +58,3 @@ meta: {

};
export default config;

@@ -1,9 +0,10 @@

'use strict';
const {isClosingParenToken, getStaticValue} = require('@eslint-community/eslint-utils');
const avoidCapture = require('./utils/avoid-capture.js');
const getScopes = require('./utils/get-scopes.js');
const singular = require('./utils/singular.js');
const toLocation = require('./utils/to-location.js');
const getReferences = require('./utils/get-references.js');
const {isLiteral} = require('./ast/index.js');
import {isClosingParenToken, getStaticValue} from '@eslint-community/eslint-utils';
import {
getAvailableVariableName,
getScopes,
singular,
toLocation,
getReferences,
} from './utils/index.js';
import {isLiteral} from './ast/index.js';

@@ -166,3 +167,3 @@ const MESSAGE_ID = 'no-for-loop';

if (declarationNode.declarations.length === 1) {
const {line} = declarationNode.loc.start;
const {line} = sourceCode.getLoc(declarationNode).start;
const lineText = sourceCode.lines[line - 1];

@@ -172,6 +173,8 @@

return isOnlyNodeOnLine ? [
sourceCode.getIndexFromLoc({line, column: 0}),
sourceCode.getIndexFromLoc({line: line + 1, column: 0}),
] : declarationNode.range;
return isOnlyNodeOnLine
? [
sourceCode.getIndexFromLoc({line, column: 0}),
sourceCode.getIndexFromLoc({line: line + 1, column: 0}),
]
: sourceCode.getRange(declarationNode);
}

@@ -183,4 +186,4 @@

return [
node.range[0],
declarationNode.declarations[1].range[0],
sourceCode.getRange(node)[0],
sourceCode.getRange(declarationNode.declarations[1])[0],
];

@@ -190,4 +193,4 @@ }

return [
declarationNode.declarations[index - 1].range[1],
node.range[1],
sourceCode.getRange(declarationNode.declarations[index - 1])[1],
sourceCode.getRange(node)[1],
];

@@ -325,4 +328,5 @@ };

const [start] = node.range;
const [, end] = sourceCode.getTokenBefore(node.body, isClosingParenToken).range;
const [start] = sourceCode.getRange(node);
const closingParenthesisToken = sourceCode.getTokenBefore(node.body, isClosingParenToken);
const [, end] = sourceCode.getRange(closingParenthesisToken);

@@ -355,3 +359,3 @@ const problem = {

const element = elementIdentifierName
|| avoidCapture(singular(arrayIdentifierName) || defaultElementName, getScopes(bodyScope));
|| getAvailableVariableName(singular(arrayIdentifierName) || defaultElementName, getScopes(bodyScope));
const array = arrayIdentifierName;

@@ -382,7 +386,6 @@

const replacement = parts.join('');
const [start] = sourceCode.getRange(node.init);
const [, end] = sourceCode.getRange(node.update);
yield fixer.replaceTextRange([
node.init.range[0],
node.update.range[1],
], replacement);
yield fixer.replaceTextRange([start, end], replacement);

@@ -409,3 +412,3 @@ for (const reference of arrayReferences) {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -423,1 +426,3 @@ meta: {

};
export default config;

@@ -1,8 +0,3 @@

'use strict';
const {replaceTemplateElement} = require('./fix/index.js');
const {
isStringLiteral,
isRegexLiteral,
isTaggedTemplateLiteral,
} = require('./ast/index.js');
import {replaceTemplateElement} from './fix/index.js';
import {isStringLiteral, isRegexLiteral, isTaggedTemplateLiteral} from './ast/index.js';

@@ -46,3 +41,3 @@ const MESSAGE_ID = 'no-hex-escape';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -59,1 +54,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {getStaticValue} = require('@eslint-community/eslint-utils');
const {
import {getStaticValue} from '@eslint-community/eslint-utils';
import {
isCallExpression,

@@ -8,3 +7,3 @@ isNewExpression,

isNullLiteral,
} = require('./ast/index.js');
} from './ast/index.js';

@@ -102,3 +101,3 @@ const MESSAGE_ID_ERROR = 'no-invalid-fetch-options';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -114,1 +113,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {getFunctionHeadLocation} = require('@eslint-community/eslint-utils');
const {isMethodCall} = require('./ast/index.js');
import {getFunctionHeadLocation} from '@eslint-community/eslint-utils';
import {isMethodCall} from './ast/index.js';

@@ -51,3 +50,3 @@ const MESSAGE_ID = 'no-invalid-remove-event-listener';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -63,1 +62,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const isShorthandPropertyAssignmentPatternLeft = require('./utils/is-shorthand-property-assignment-pattern-left.js');
import isShorthandPropertyAssignmentPatternLeft from './utils/is-shorthand-property-assignment-pattern-left.js';

@@ -189,3 +188,3 @@ const MESSAGE_ID = 'noKeywordPrefix';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -199,4 +198,7 @@ meta: {

schema,
defaultOptions: [{}],
messages,
},
};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {isMethodCall, isMemberExpression} = require('./ast/index.js');
const {removeArgument} = require('./fix/index.js');
const {isSameReference} = require('./utils/index.js');
import {isMethodCall, isMemberExpression} from './ast/index.js';
import {removeArgument} from './fix/index.js';
import {isSameReference} from './utils/index.js';

@@ -42,3 +41,3 @@ const MESSAGE_ID = 'no-length-as-slice-end';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -55,1 +54,3 @@ meta: {

};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {isParenthesized, isNotSemicolonToken} = require('@eslint-community/eslint-utils');
const {needsSemicolon} = require('./utils/index.js');
const {removeSpacesAfter} = require('./fix/index.js');
import {isParenthesized, isNotSemicolonToken} from '@eslint-community/eslint-utils';
import {needsSemicolon} from './utils/index.js';
import {removeSpacesAfter} from './fix/index.js';

@@ -141,3 +140,3 @@ const MESSAGE_ID = 'no-lonely-if';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -154,1 +153,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {isMethodCall, isNumberLiteral} = require('./ast/index.js');
const {getCallExpressionTokens} = require('./utils/index.js');
import {isMethodCall, isNumberLiteral} from './ast/index.js';
import {getCallExpressionTokens} from './utils/index.js';

@@ -44,3 +43,3 @@ const MESSAGE_ID = 'no-magic-array-flat-depth';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -56,1 +55,3 @@ meta: {

};
export default config;

@@ -5,14 +5,10 @@ /*

*/
'use strict';
const {
import {
removeParentheses,
fixSpaceAroundKeyword,
addParenthesizesToReturnOrThrowExpression,
} = require('./fix/index.js');
const {
getParenthesizedRange,
isParenthesized,
} = require('./utils/parentheses.js');
const isOnSameLine = require('./utils/is-on-same-line.js');
const needsSemicolon = require('./utils/needs-semicolon.js');
} from './fix/index.js';
import {getParenthesizedRange, isParenthesized} from './utils/parentheses.js';
import isOnSameLine from './utils/is-on-same-line.js';
import needsSemicolon from './utils/needs-semicolon.js';

@@ -68,4 +64,4 @@ const MESSAGE_ID = 'no-negated-condition';

yield fixer.replaceTextRange(consequent.range, alternate.text);
yield fixer.replaceTextRange(alternate.range, consequent.text);
yield fixer.replaceTextRange(sourceCode.getRange(consequent), alternate.text);
yield fixer.replaceTextRange(sourceCode.getRange(alternate), consequent.text);
}

@@ -136,3 +132,3 @@

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -149,1 +145,3 @@ meta: {

};
export default config;

@@ -1,11 +0,3 @@

'use strict';
const {
fixSpaceAroundKeyword,
addParenthesizesToReturnOrThrowExpression,
} = require('./fix/index.js');
const {
needsSemicolon,
isParenthesized,
isOnSameLine,
} = require('./utils/index.js');
import {fixSpaceAroundKeyword, addParenthesizesToReturnOrThrowExpression} from './fix/index.js';
import {needsSemicolon, isParenthesized, isOnSameLine} from './utils/index.js';

@@ -93,3 +85,3 @@ const MESSAGE_ID_ERROR = 'no-negation-in-equality-check/error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -107,1 +99,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {isParenthesized} = require('@eslint-community/eslint-utils');
import {isParenthesized} from '@eslint-community/eslint-utils';

@@ -48,3 +47,3 @@ const MESSAGE_ID_TOO_DEEP = 'too-deep';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -61,1 +60,3 @@ meta: {

};
export default config;

@@ -1,6 +0,5 @@

'use strict';
const {isParenthesized, getStaticValue} = require('@eslint-community/eslint-utils');
const needsSemicolon = require('./utils/needs-semicolon.js');
const isNumber = require('./utils/is-number.js');
const {isNewExpression} = require('./ast/index.js');
import {isParenthesized, getStaticValue} from '@eslint-community/eslint-utils';
import needsSemicolon from './utils/needs-semicolon.js';
import isNumber from './utils/is-number.js';
import {isNewExpression} from './ast/index.js';

@@ -93,3 +92,3 @@ const MESSAGE_ID_ERROR = 'error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -107,1 +106,3 @@ meta: {

};
export default config;

@@ -1,6 +0,5 @@

'use strict';
const {getStaticValue} = require('@eslint-community/eslint-utils');
const {switchNewExpressionToCallExpression} = require('./fix/index.js');
const isNumber = require('./utils/is-number.js');
const {isNewExpression} = require('./ast/index.js');
import {getStaticValue} from '@eslint-community/eslint-utils';
import {switchNewExpressionToCallExpression} from './fix/index.js';
import isNumber from './utils/is-number.js';
import {isNewExpression} from './ast/index.js';

@@ -87,3 +86,3 @@ const ERROR = 'error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -101,1 +100,3 @@ meta: {

};
export default config;

@@ -1,7 +0,2 @@

'use strict';
const {
isMethodCall,
isCallExpression,
isLiteral,
} = require('./ast/index.js');
import {isMethodCall, isCallExpression, isLiteral} from './ast/index.js';

@@ -111,6 +106,9 @@ const ERROR_MESSAGE_ID = 'error';

if (parent.type === 'VariableDeclarator' && parent.init === node && parent.parent.kind !== 'const') {
const {sourceCode} = context;
const [, start] = sourceCode.getRange(parent.id);
const [, end] = sourceCode.getRange(node);
problem.suggest = [
{
messageId: SUGGESTION_REMOVE_MESSAGE_ID,
fix: fixer => fixer.removeRange([parent.id.range[1], node.range[1]]),
fix: fixer => fixer.removeRange([start, end]),
},

@@ -135,3 +133,2 @@ useUndefinedSuggestion,

type: 'boolean',
default: false,
},

@@ -143,3 +140,3 @@ },

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -155,4 +152,7 @@ meta: {

schema,
defaultOptions: [{checkStrictEquality: false}],
messages,
},
};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {isFunction} = require('./ast/index.js');
import {isFunction} from './ast/index.js';

@@ -41,3 +40,3 @@ const MESSAGE_ID_IDENTIFIER = 'identifier';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -53,1 +52,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {isStaticRequire, isMethodCall, isLiteral} = require('./ast/index.js');
import {isStaticRequire, isMethodCall, isLiteral} from './ast/index.js';

@@ -95,3 +94,3 @@ const MESSAGE_ID = 'no-process-exit';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -107,1 +106,3 @@ meta: {

};
export default config;

@@ -1,10 +0,4 @@

'use strict';
const {
isCommaToken,
} = require('@eslint-community/eslint-utils');
const {
isMethodCall,
isExpressionStatement,
} = require('./ast/index.js');
const {
import {isCommaToken} from '@eslint-community/eslint-utils';
import {isMethodCall, isExpressionStatement} from './ast/index.js';
import {
getParenthesizedText,

@@ -14,3 +8,3 @@ isParenthesized,

shouldAddParenthesesToAwaitExpressionArgument,
} = require('./utils/index.js');
} from './utils/index.js';

@@ -170,3 +164,3 @@ const MESSAGE_ID_ERROR = 'no-single-promise-in-promise-methods/error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -184,1 +178,3 @@ meta: {

};
export default config;

@@ -1,6 +0,5 @@

'use strict';
const {isSemicolonToken} = require('@eslint-community/eslint-utils');
const getClassHeadLocation = require('./utils/get-class-head-location.js');
const assertToken = require('./utils/assert-token.js');
const {removeSpacesAfter} = require('./fix/index.js');
import {isSemicolonToken} from '@eslint-community/eslint-utils';
import getClassHeadLocation from './utils/get-class-head-location.js';
import assertToken from './utils/assert-token.js';
import {removeSpacesAfter} from './fix/index.js';

@@ -156,3 +155,3 @@ const MESSAGE_ID = 'no-static-only-class';

&& parent.type === 'ReturnStatement'
&& body.loc.start.line !== parent.loc.start.line
&& sourceCode.getLoc(body).start.line !== sourceCode.getLoc(parent).start.line
&& sourceCode.text.slice(classToken.range[1], body.range[0]).trim()

@@ -215,3 +214,3 @@ ) {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -228,1 +227,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {getStaticValue, getPropertyName} = require('@eslint-community/eslint-utils');
const {isMethodCall} = require('./ast/index.js');
import {getStaticValue, getPropertyName} from '@eslint-community/eslint-utils';
import {isMethodCall} from './ast/index.js';

@@ -16,2 +15,3 @@ const MESSAGE_ID_OBJECT = 'no-thenable-object';

getStaticValue(node, context.sourceCode.getScope(node))?.value === 'then';
const isPropertyThen = (node, context) => {

@@ -190,3 +190,3 @@ // `getPropertyName` throws on `({[Symbol.prototype]: 0})`

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -202,1 +202,3 @@ meta: {

};
export default config;

@@ -1,2 +0,1 @@

'use strict';
const MESSAGE_ID = 'no-this-assignment';

@@ -29,3 +28,3 @@ const messages = {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -41,1 +40,3 @@ meta: {

};
export default config;

@@ -1,8 +0,7 @@

'use strict';
const {isLiteral} = require('./ast/index.js');
const {
import {isLiteral} from './ast/index.js';
import {
addParenthesizesToReturnOrThrowExpression,
removeSpacesAfter,
} = require('./fix/index.js');
const {
} from './fix/index.js';
import {
needsSemicolon,

@@ -12,3 +11,3 @@ isParenthesized,

isShadowed,
} = require('./utils/index.js');
} from './utils/index.js';

@@ -30,2 +29,3 @@ const MESSAGE_ID_ERROR = 'no-typeof-undefined/error';

};
const {sourceCode} = context;

@@ -98,3 +98,3 @@

node: binaryExpression,
loc: typeofToken.loc,
loc: sourceCode.getLoc(typeofToken),
messageId: MESSAGE_ID_ERROR,

@@ -127,3 +127,2 @@ };

type: 'boolean',
default: false,
},

@@ -135,3 +134,3 @@ },

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -147,4 +146,7 @@ meta: {

schema,
defaultOptions: [{checkGlobalVariables: false}],
messages,
},
};
export default config;

@@ -1,9 +0,5 @@

'use strict';
const {
addParenthesizesToReturnOrThrowExpression,
removeSpacesAfter,
} = require('./fix/index.js');
const {isParenthesized} = require('./utils/parentheses.js');
const needsSemicolon = require('./utils/needs-semicolon.js');
const isOnSameLine = require('./utils/is-on-same-line.js');
import {addParenthesizesToReturnOrThrowExpression, removeSpacesAfter} from './fix/index.js';
import {isParenthesized} from './utils/parentheses.js';
import needsSemicolon from './utils/needs-semicolon.js';
import isOnSameLine from './utils/is-on-same-line.js';

@@ -53,3 +49,3 @@ const MESSAGE_ID = 'no-unnecessary-await';

node,
loc: awaitToken.loc,
loc: sourceCode.getLoc(awaitToken),
messageId: MESSAGE_ID,

@@ -97,3 +93,3 @@ };

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -111,1 +107,3 @@ meta: {

};
export default config;

@@ -1,7 +0,6 @@

'use strict';
const path = require('node:path');
const readPkgUp = require('read-pkg-up');
const coreJsCompat = require('core-js-compat');
const {camelCase} = require('./utils/lodash.js');
const isStaticRequire = require('./ast/is-static-require.js');
import path from 'node:path';
import {readPackageUpSync} from 'read-package-up';
import coreJsCompat from 'core-js-compat';
import {camelCase} from './utils/lodash.js';
import isStaticRequire from './ast/is-static-require.js';

@@ -65,3 +64,3 @@ const {data: compatData, entries: coreJsEntries} = coreJsCompat;

// It can fail if, for example, the package.json file has comments.
packageResult = readPkgUp.sync({normalize: false, cwd: dirname});
packageResult = readPackageUpSync({normalize: false, cwd: dirname});
} catch {}

@@ -167,3 +166,3 @@

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -177,4 +176,8 @@ meta: {

schema,
// eslint-disable-next-line eslint-plugin/require-meta-default-options
defaultOptions: [],
messages,
},
};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {isParenthesized} = require('@eslint-community/eslint-utils');
const shouldAddParenthesesToMemberExpressionObject = require('./utils/should-add-parentheses-to-member-expression-object.js');
const {fixSpaceAroundKeyword} = require('./fix/index.js');
import {isParenthesized} from '@eslint-community/eslint-utils';
import shouldAddParenthesesToMemberExpressionObject from './utils/should-add-parentheses-to-member-expression-object.js';
import {fixSpaceAroundKeyword} from './fix/index.js';

@@ -73,3 +72,3 @@ const MESSAGE_ID = 'no-unreadable-array-destructuring';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -86,1 +85,3 @@ meta: {

};
export default config;

@@ -1,7 +0,2 @@

'use strict';
const {
isParenthesized,
getParenthesizedRange,
toLocation,
} = require('./utils/index.js');
import {isParenthesized, getParenthesizedRange, toLocation} from './utils/index.js';

@@ -35,3 +30,3 @@ const MESSAGE_ID_ERROR = 'no-unreadable-iife';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -48,1 +43,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const getScopes = require('./utils/get-scopes.js');
import getScopes from './utils/get-scopes.js';

@@ -229,3 +228,3 @@ const MESSAGE_ID = 'no-unused-properties';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -241,1 +240,3 @@ meta: {

};
export default config;

@@ -1,7 +0,3 @@

'use strict';
const {
isParenthesized,
getParenthesizedRange,
} = require('./utils/parentheses.js');
const {removeParentheses} = require('./fix/index.js');
import {isParenthesized, getParenthesizedRange} from './utils/parentheses.js';
import {removeParentheses} from './fix/index.js';

@@ -40,4 +36,4 @@ const MESSAGE_ID = 'no-useless-fallback-in-spread';

? getParenthesizedRange(left, sourceCode)
: left.range;
const [, end] = logicalExpression.range;
: sourceCode.getRange(left);
const [, end] = sourceCode.getRange(logicalExpression);

@@ -58,3 +54,3 @@ yield fixer.removeRange([start, end]);

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -71,1 +67,3 @@ meta: {

};
export default config;

@@ -1,8 +0,3 @@

'use strict';
const {isMethodCall, isMemberExpression} = require('./ast/index.js');
const {
getParenthesizedRange,
isSameReference,
isLogicalExpression,
} = require('./utils/index.js');
import {isMethodCall, isMemberExpression} from './ast/index.js';
import {getParenthesizedRange, isSameReference, isLogicalExpression} from './utils/index.js';

@@ -110,2 +105,3 @@ const messages = {

);
const {sourceCode} = context;

@@ -115,4 +111,4 @@ for (const node of nodes) {

loc: {
start: node.left.property.loc.start,
end: node.loc.end,
start: sourceCode.getLoc(node.left.property).start,
end: sourceCode.getLoc(node).end,
},

@@ -122,3 +118,2 @@ messageId: zeroLengthChecks.has(node) ? 'zero' : 'non-zero',

fix(fixer) {
const {sourceCode} = context;
const {left, right} = node.parent;

@@ -145,3 +140,3 @@ const leftRange = getParenthesizedRange(left, sourceCode);

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -158,1 +153,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {getParenthesizedRange} = require('./utils/index.js');
const {isFunction, isMethodCall} = require('./ast/index.js');
import {getParenthesizedRange} from './utils/index.js';
import {isFunction, isMethodCall} from './ast/index.js';

@@ -202,3 +201,3 @@ const MESSAGE_ID_RESOLVE = 'resolve';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -215,1 +214,3 @@ meta: {

};
export default config;

@@ -1,14 +0,6 @@

'use strict';
const {isCommaToken} = require('@eslint-community/eslint-utils');
const typedArray = require('./shared/typed-array.js');
const {
removeParentheses,
fixSpaceAroundKeyword,
addParenthesizesToReturnOrThrowExpression,
} = require('./fix/index.js');
const {
isParenthesized,
isOnSameLine,
} = require('./utils/index.js');
const {isNewExpression, isMethodCall, isCallOrNewExpression} = require('./ast/index.js');
import {isCommaToken} from '@eslint-community/eslint-utils';
import typedArray from './shared/typed-array.js';
import {removeParentheses, fixSpaceAroundKeyword, addParenthesizesToReturnOrThrowExpression} from './fix/index.js';
import {isParenthesized, isOnSameLine} from './utils/index.js';
import {isNewExpression, isMethodCall, isCallOrNewExpression} from './ast/index.js';

@@ -371,3 +363,3 @@ const SPREAD_IN_LIST = 'spread-in-list';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -384,1 +376,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {isEmptyNode} = require('./ast/index.js');
const getSwitchCaseHeadLocation = require('./utils/get-switch-case-head-location.js');
import {isEmptyNode} from './ast/index.js';
import getSwitchCaseHeadLocation from './utils/get-switch-case-head-location.js';

@@ -47,3 +46,3 @@ const MESSAGE_ID_ERROR = 'no-useless-switch-case/error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -60,1 +59,3 @@ meta: {

};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {isCommaToken} = require('@eslint-community/eslint-utils');
const {replaceNodeOrTokenAndSpacesBefore} = require('./fix/index.js');
const {isUndefined, isFunction} = require('./ast/index.js');
import {isCommaToken} from '@eslint-community/eslint-utils';
import {replaceNodeOrTokenAndSpacesBefore} from './fix/index.js';
import {isUndefined, isFunction} from './ast/index.js';

@@ -175,5 +174,7 @@ const messageId = 'no-useless-undefined';

) {
const [, start] = sourceCode.getRange(node.parent.id);
const [, end] = sourceCode.getRange(node);
return getProblem(
node,
fixer => fixer.removeRange([node.parent.id.range[1], node.range[1]]),
fixer => fixer.removeRange([start, end]),
/* CheckFunctionReturnType */ true,

@@ -196,4 +197,6 @@ );

const {left} = assignmentPattern;
const [, start] = sourceCode.getRange(left);
const [, end] = sourceCode.getRange(node);
yield fixer.removeRange([left.range[1], node.range[1]]);
yield fixer.removeRange([start, end]);
if (

@@ -253,8 +256,8 @@ (left.typeAnnotation || isTypeScriptFile(context))

loc: {
start: firstUndefined.loc.start,
end: lastUndefined.loc.end,
start: sourceCode.getLoc(firstUndefined).start,
end: sourceCode.getLoc(lastUndefined).end,
},
fix(fixer) {
let start = firstUndefined.range[0];
let end = lastUndefined.range[1];
let [start] = sourceCode.getRange(firstUndefined);
let [, end] = sourceCode.getRange(lastUndefined);

@@ -264,3 +267,3 @@ const previousArgument = argumentNodes[argumentNodes.length - undefinedArguments.length - 1];

if (previousArgument) {
start = previousArgument.range[1];
[, start] = sourceCode.getRange(previousArgument);
} else {

@@ -270,3 +273,3 @@ // If all arguments removed, and there is trailing comma, we need remove it.

if (isCommaToken(tokenAfter)) {
end = tokenAfter.range[1];
[, end] = sourceCode.getRange(tokenAfter);
}

@@ -297,3 +300,3 @@ }

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -308,4 +311,7 @@ meta: {

schema,
defaultOptions: [{}],
messages,
},
};
export default config;

@@ -1,8 +0,7 @@

'use strict';
const {isParenthesized} = require('@eslint-community/eslint-utils');
const needsSemicolon = require('./utils/needs-semicolon.js');
const {isDecimalInteger} = require('./utils/numeric.js');
const toLocation = require('./utils/to-location.js');
const {fixSpaceAroundKeyword} = require('./fix/index.js');
const {isNumberLiteral} = require('./ast/index.js');
import {isParenthesized} from '@eslint-community/eslint-utils';
import needsSemicolon from './utils/needs-semicolon.js';
import {isDecimalInteger} from './utils/numeric.js';
import toLocation from './utils/to-location.js';
import {fixSpaceAroundKeyword} from './fix/index.js';
import {isNumberLiteral} from './ast/index.js';

@@ -39,6 +38,6 @@ const MESSAGE_ZERO_FRACTION = 'zero-fraction';

const isDanglingDot = dotAndFractions === '.';
const {sourceCode} = context;
// End of fractions
const end = node.range[0] + before.length + dotAndFractions.length;
const end = sourceCode.getRange(node)[0] + before.length + dotAndFractions.length;
const start = end - (raw.length - formatted.length);
const {sourceCode} = context;
return {

@@ -70,3 +69,3 @@ loc: toLocation([start, end], sourceCode),

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -83,1 +82,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {checkVueTemplate} = require('./utils/rule.js');
const {isNumberLiteral, isBigIntLiteral} = require('./ast/index.js');
import {checkVueTemplate} from './utils/rule.js';
import {isNumberLiteral, isBigIntLiteral} from './ast/index.js';

@@ -42,3 +41,3 @@ const MESSAGE_ID = 'number-literal-case';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create: checkVueTemplate(create),

@@ -55,1 +54,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const numeric = require('./utils/numeric.js');
const {isBigIntLiteral} = require('./ast/index.js');
import * as numeric from './utils/numeric.js';
import {isBigIntLiteral} from './ast/index.js';

@@ -135,3 +134,3 @@ const MESSAGE_ID = 'numeric-separators-style';

const formatOptionsSchema = ({minimumDigits, groupLength}) => ({
const formatOptionsSchema = () => ({
type: 'object',

@@ -146,3 +145,2 @@ additionalProperties: false,

minimum: 0,
default: minimumDigits,
},

@@ -152,3 +150,2 @@ groupLength: {

minimum: 1,
default: groupLength,
},

@@ -163,7 +160,6 @@ },

...Object.fromEntries(
Object.entries(defaultOptions).map(([type, options]) => [type, formatOptionsSchema(options)]),
Object.entries(defaultOptions).map(([type]) => [type, formatOptionsSchema()]),
),
onlyIfContainsSeparator: {
type: 'boolean',
default: false,
},

@@ -174,3 +170,3 @@ },

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -185,4 +181,15 @@ meta: {

schema,
defaultOptions: [
{
onlyIfContainsSeparator: false,
binary: defaultOptions.binary,
octal: defaultOptions.octal,
hexadecimal: defaultOptions.hexadecimal,
number: defaultOptions.number,
},
],
messages,
},
};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {isParenthesized} = require('@eslint-community/eslint-utils');
const eventTypes = require('./shared/dom-events.js');
const {isUndefined, isNullLiteral, isStaticRequire} = require('./ast/index.js');
import {isParenthesized} from '@eslint-community/eslint-utils';
import eventTypes from './shared/dom-events.js';
import {isUndefined, isNullLiteral, isStaticRequire} from './ast/index.js';

@@ -177,3 +176,3 @@ const MESSAGE_ID = 'prefer-add-event-listener';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -188,4 +187,7 @@ meta: {

schema,
defaultOptions: [{}],
messages,
},
};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {isParenthesized, findVariable} = require('@eslint-community/eslint-utils');
const {
import {isParenthesized, findVariable} from '@eslint-community/eslint-utils';
import {
extendFixRange,

@@ -8,11 +7,11 @@ removeMemberExpressionProperty,

renameVariable,
} = require('./fix/index.js');
const {
} from './fix/index.js';
import {
isLeftHandSide,
singular,
getScopes,
avoidCapture,
getAvailableVariableName,
getVariableIdentifiers,
} = require('./utils/index.js');
const {isMethodCall} = require('./ast/index.js');
} from './utils/index.js';
import {isMethodCall} from './ast/index.js';

@@ -321,7 +320,7 @@ const ERROR_ZERO_INDEX = 'error-zero-index';

// Rename variable to be singularized now that it refers to a single item in the array instead of the entire array.
const singularizedName = avoidCapture(singularName, getScopes(scope));
const singularizedName = getAvailableVariableName(singularName, getScopes(scope));
yield * renameVariable(variable, singularizedName, fixer);
// Prevent possible variable conflicts
yield * extendFixRange(fixer, sourceCode.ast.range);
yield * extendFixRange(fixer, sourceCode.getRange(sourceCode.ast));
}

@@ -433,4 +432,2 @@

type: 'boolean',
// TODO: Remove the option at some point.
default: true,
},

@@ -442,3 +439,3 @@ },

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -454,4 +451,7 @@ meta: {

schema,
defaultOptions: [{checkFromLast: true}],
messages,
},
};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {isNodeMatches} = require('./utils/is-node-matches.js');
const {isMethodCall} = require('./ast/index.js');
const {removeMethodCall} = require('./fix/index.js');
import {isNodeMatches} from './utils/is-node-matches.js';
import {isMethodCall} from './ast/index.js';
import {removeMethodCall} from './fix/index.js';

@@ -50,3 +49,6 @@ const MESSAGE_ID = 'prefer-array-flat-map';

node: flatCallExpression,
loc: {start: mapProperty.loc.start, end: flatCallExpression.loc.end},
loc: {
start: sourceCode.getLoc(mapProperty).start,
end: sourceCode.getLoc(flatCallExpression).end,
},
messageId: MESSAGE_ID,

@@ -73,3 +75,3 @@ * fix(fixer) {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -86,1 +88,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {
import {
getParenthesizedText,

@@ -11,8 +10,5 @@ isArrayPrototypeProperty,

shouldAddParenthesesToMemberExpressionObject,
} = require('./utils/index.js');
const {fixSpaceAroundKeyword} = require('./fix/index.js');
const {
isMethodCall,
isCallExpression,
} = require('./ast/index.js');
} from './utils/index.js';
import {fixSpaceAroundKeyword} from './fix/index.js';
import {isMethodCall, isCallExpression} from './ast/index.js';

@@ -269,3 +265,3 @@ const MESSAGE_ID = 'prefer-array-flat';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -280,4 +276,7 @@ meta: {

schema,
defaultOptions: [{}],
messages,
},
};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const simpleArraySearchRule = require('./shared/simple-array-search-rule.js');
import simpleArraySearchRule from './shared/simple-array-search-rule.js';

@@ -15,3 +14,3 @@ const indexOfOverFindIndexRule = simpleArraySearchRule({

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create(context) {

@@ -35,1 +34,3 @@ indexOfOverFindIndexRule.listen(context);

};
export default config;

@@ -1,10 +0,10 @@

'use strict';
const {checkVueTemplate} = require('./utils/rule.js');
const {
isBooleanNode,
getParenthesizedRange,
isNodeValueNotFunction,
} = require('./utils/index.js');
const {removeMemberExpressionProperty} = require('./fix/index.js');
const {isLiteral, isUndefined, isMethodCall, isMemberExpression} = require('./ast/index.js');
import {checkVueTemplate} from './utils/rule.js';
import {isBooleanNode, getParenthesizedRange, isNodeValueNotFunction} from './utils/index.js';
import {removeMemberExpressionProperty} from './fix/index.js';
import {
isLiteral,
isUndefined,
isMethodCall,
isMemberExpression,
} from './ast/index.js';

@@ -81,4 +81,5 @@ const ERROR_ID_ARRAY_SOME = 'some';

const parenthesizedRange = getParenthesizedRange(callExpression, context.sourceCode);
yield fixer.replaceTextRange([parenthesizedRange[1], callExpression.parent.range[1]], '');
const {sourceCode} = context;
const parenthesizedRange = getParenthesizedRange(callExpression, sourceCode);
yield fixer.removeRange([parenthesizedRange[1], sourceCode.getRange(callExpression.parent)[1]]);

@@ -134,8 +135,9 @@ if (callExpression.parent.operator === '!=' || callExpression.parent.operator === '!==') {

const operatorToken = context.sourceCode.getTokenAfter(
const {sourceCode} = context;
const operatorToken = sourceCode.getTokenAfter(
left,
token => token.type === 'Punctuator' && token.value === operator,
);
const [start] = operatorToken.range;
const [, end] = binaryExpression.range;
const [start] = sourceCode.getRange(operatorToken);
const [, end] = sourceCode.getRange(binaryExpression);

@@ -195,3 +197,3 @@ yield fixer.removeRange([start, end]);

getParenthesizedRange(lengthNode, sourceCode)[1],
binaryExpression.range[1],
sourceCode.getRange(binaryExpression)[1],
]);

@@ -206,3 +208,3 @@

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create: checkVueTemplate(create),

@@ -220,1 +222,3 @@ meta: {

};
export default config;

@@ -1,4 +0,7 @@

'use strict';
const {isOpeningBracketToken, isClosingBracketToken, getStaticValue} = require('@eslint-community/eslint-utils');
const {
import {
isOpeningBracketToken,
isClosingBracketToken,
getStaticValue,
} from '@eslint-community/eslint-utils';
import {
isParenthesized,

@@ -11,9 +14,9 @@ getParenthesizedRange,

isLeftHandSide,
} = require('./utils/index.js');
const {
} from './utils/index.js';
import {
getNegativeIndexLengthNode,
removeLengthNode,
} = require('./shared/negative-index.js');
const {removeMemberExpressionProperty, removeMethodCall} = require('./fix/index.js');
const {isLiteral, isCallExpression, isMethodCall} = require('./ast/index.js');
} from './shared/negative-index.js';
import {removeMemberExpressionProperty, removeMethodCall} from './fix/index.js';
import {isLiteral, isCallExpression, isMethodCall} from './ast/index.js';

@@ -100,5 +103,8 @@ const MESSAGE_ID_NEGATIVE_INDEX = 'negative-index';

if (
firstElementGetMethod === 'zero-index'
|| firstElementGetMethod === 'shift'
|| (startIndex === -1 && firstElementGetMethod === 'pop')
startIndexNode.argument.value === 1
&& (
firstElementGetMethod === 'zero-index'
|| firstElementGetMethod === 'shift'
|| (startIndex === -1 && firstElementGetMethod === 'pop')
)
) {

@@ -357,3 +363,2 @@ return {safeToFix: true, firstElementGetMethod};

type: 'boolean',
default: false,
},

@@ -365,3 +370,3 @@ },

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -377,4 +382,7 @@ meta: {

schema,
defaultOptions: [{getLastElementFunctions: [], checkAllIndexAccess: false}],
messages,
},
};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {isMethodCall} = require('./ast/index.js');
import {isMethodCall} from './ast/index.js';

@@ -36,3 +35,3 @@ const MESSAGE_ID = 'error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -48,1 +47,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {isMethodCall} = require('./ast/index.js');
import {isMethodCall} from './ast/index.js';

@@ -57,3 +56,3 @@ const messages = {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -70,1 +69,3 @@ meta: {

};
export default config;

@@ -1,8 +0,3 @@

'use strict';
const {
isMethodCall,
isCallExpression,
isNewExpression,
} = require('./ast/index.js');
const {fixSpaceAroundKeyword} = require('./fix/index.js');
import {isMethodCall, isCallExpression, isNewExpression} from './ast/index.js';
import {fixSpaceAroundKeyword} from './fix/index.js';

@@ -125,3 +120,3 @@ const MESSAGE_ID_DEFAULT = 'prefer-date';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -138,1 +133,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {findVariable} = require('@eslint-community/eslint-utils');
const {functionTypes} = require('./ast/index.js');
import {findVariable} from '@eslint-community/eslint-utils';
import {functionTypes} from './ast/index.js';

@@ -95,4 +94,4 @@ const MESSAGE_ID = 'preferDefaultParameters';

const fixDefaultExpression = (fixer, sourceCode, node) => {
const {line} = node.loc.start;
const {column} = node.loc.end;
const {line} = sourceCode.getLoc(node).start;
const {column} = sourceCode.getLoc(node).end;
const nodeText = sourceCode.getText(node);

@@ -111,6 +110,4 @@ const lineText = sourceCode.lines[line - 1];

if (endsWithWhitespace) {
return fixer.removeRange([
node.range[0],
node.range[1] + 1,
]);
const [start, end] = sourceCode.getRange(node);
return fixer.removeRange([start, end + 1]);
}

@@ -207,3 +204,3 @@

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -224,1 +221,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {isMethodCall} = require('./ast/index.js');
const {isNodeValueNotDomNode, isValueNotUsable} = require('./utils/index.js');
import {isMethodCall} from './ast/index.js';
import {isNodeValueNotDomNode, isValueNotUsable} from './utils/index.js';

@@ -38,3 +37,3 @@ const MESSAGE_ID = 'prefer-dom-node-append';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -51,1 +50,3 @@ meta: {

};
export default config;

@@ -1,10 +0,6 @@

'use strict';
const {isIdentifierName} = require('@babel/helper-validator-identifier');
const {
escapeString,
hasOptionalChainElement,
isValueNotUsable,
} = require('./utils/index.js');
const {isMethodCall, isStringLiteral, isExpressionStatement} = require('./ast/index.js');
import helperValidatorIdentifier from '@babel/helper-validator-identifier';
import {escapeString, hasOptionalChainElement, isValueNotUsable} from './utils/index.js';
import {isMethodCall, isStringLiteral, isExpressionStatement} from './ast/index.js';
const {isIdentifierName} = helperValidatorIdentifier;
const MESSAGE_ID = 'prefer-dom-node-dataset';

@@ -121,3 +117,3 @@ const messages = {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -134,1 +130,3 @@ meta: {

};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {isParenthesized, hasSideEffect} = require('@eslint-community/eslint-utils');
const {isMethodCall} = require('./ast/index.js');
const {
import {isParenthesized, hasSideEffect} from '@eslint-community/eslint-utils';
import {isMethodCall} from './ast/index.js';
import {
getParenthesizedText,

@@ -10,3 +9,3 @@ isNodeValueNotDomNode,

shouldAddParenthesesToMemberExpressionObject,
} = require('./utils/index.js');
} from './utils/index.js';

@@ -112,3 +111,3 @@ const ERROR_MESSAGE_ID = 'error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -126,1 +125,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {isMemberExpression} = require('./ast/index.js');
import {isMemberExpression} from './ast/index.js';

@@ -65,3 +64,3 @@ const ERROR = 'error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -78,1 +77,3 @@ meta: {

};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {findVariable} = require('@eslint-community/eslint-utils');
const {getAncestor} = require('./utils/index.js');
const {isStaticRequire, isStringLiteral, isMemberExpression} = require('./ast/index.js');
import {findVariable} from '@eslint-community/eslint-utils';
import {getAncestor} from './utils/index.js';
import {isStaticRequire, isStringLiteral, isMemberExpression} from './ast/index.js';

@@ -108,3 +107,3 @@ const MESSAGE_ID = 'prefer-event-target';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -120,1 +119,3 @@ meta: {

};
export default config;

@@ -1,10 +0,4 @@

'use strict';
const {
isCommaToken,
isOpeningBraceToken,
isClosingBraceToken,
} = require('@eslint-community/eslint-utils');
const {
isStringLiteral,
} = require('./ast/index.js');
import {isOpeningBraceToken} from '@eslint-community/eslint-utils';
import {isStringLiteral} from './ast/index.js';
import {removeSpecifier} from './fix/index.js';

@@ -39,44 +33,2 @@ const MESSAGE_ID_ERROR = 'error';

function * removeSpecifier(node, fixer, sourceCode) {
const {parent} = node;
const {specifiers} = parent;
if (specifiers.length === 1) {
yield * removeImportOrExport(parent, fixer, sourceCode);
return;
}
switch (node.type) {
case 'ImportSpecifier': {
const hasOtherSpecifiers = specifiers.some(specifier => specifier !== node && specifier.type === node.type);
if (!hasOtherSpecifiers) {
const closingBraceToken = sourceCode.getTokenAfter(node, isClosingBraceToken);
// If there are other specifiers, they have to be the default import specifier
// And the default import has to write before the named import specifiers
// So there must be a comma before
const commaToken = sourceCode.getTokenBefore(node, isCommaToken);
yield fixer.replaceTextRange([commaToken.range[0], closingBraceToken.range[1]], '');
return;
}
// Fallthrough
}
case 'ExportSpecifier':
case 'ImportNamespaceSpecifier':
case 'ImportDefaultSpecifier': {
yield fixer.remove(node);
const tokenAfter = sourceCode.getTokenAfter(node);
if (isCommaToken(tokenAfter)) {
yield fixer.remove(tokenAfter);
}
break;
}
// No default
}
}
function * removeImportOrExport(node, fixer, sourceCode) {

@@ -107,4 +59,4 @@ switch (node.type) {

);
const [start] = keywordFromToken.range;
const [, end] = declaration.range;
const [start] = sourceCode.getRange(keywordFromToken);
const [, end] = sourceCode.getRange(declaration);
return sourceCode.text.slice(start, end);

@@ -310,3 +262,2 @@ }

type: 'boolean',
default: false,
},

@@ -402,3 +353,3 @@ },

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -414,4 +365,7 @@ meta: {

schema,
defaultOptions: [{ignoreUsedVariables: false}],
messages,
},
};
export default config;

@@ -1,9 +0,11 @@

'use strict';
const MESSAGE_ID_ERROR = 'prefer-global-this/error';
const messages = {
[MESSAGE_ID_ERROR]: 'Prefer `globalThis` over `{{value}}`.',
[MESSAGE_ID_ERROR]: 'Prefer `{{replacement}}` over `{{value}}`.',
};
const globalIdentifier = new Set(['window', 'self', 'global']);
const globalIdentifier = new Set([
'window',
'self',
'global',
]);

@@ -85,2 +87,4 @@ const windowSpecificEvents = new Set([

'innerHeight',
'outerWidth',
'outerHeight',
'scrollX',

@@ -188,7 +192,12 @@ 'pageXOffset',

// Skip the fix for `typeof window` and `typeof self`
const isTypeofLegacyGlobal = identifier.parent.type === 'UnaryExpression' && identifier.parent.operator === 'typeof' && identifier.parent.argument === identifier;
const replacement = isTypeofLegacyGlobal ? 'globalThis.' + identifier.name : 'globalThis';
yield {
node: identifier,
messageId: MESSAGE_ID_ERROR,
data: {value: identifier.name},
fix: fixer => fixer.replaceText(identifier, 'globalThis'),
data: {replacement, value: identifier.name},
fix: fixer => fixer.replaceText(identifier, replacement),
};

@@ -200,3 +209,3 @@ }

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -214,1 +223,3 @@ meta: {

};
export default config;

@@ -1,5 +0,5 @@

'use strict';
const isMethodNamed = require('./utils/is-method-named.js');
const simpleArraySearchRule = require('./shared/simple-array-search-rule.js');
const {isLiteral, isNegativeOne} = require('./ast/index.js');
import {checkVueTemplate} from './utils/rule.js';
import isMethodNamed from './utils/is-method-named.js';
import simpleArraySearchRule from './shared/simple-array-search-rule.js';
import {isLiteral, isNegativeOne} from './ast/index.js';

@@ -18,5 +18,10 @@ const MESSAGE_ID = 'prefer-includes';

const {sourceCode} = context;
const tokenStore = sourceCode.parserServices.getTemplateBodyTokenStore?.() ?? sourceCode;
const memberExpressionNode = target.parent;
const dotToken = sourceCode.getTokenBefore(memberExpressionNode.property);
const targetSource = sourceCode.getText().slice(memberExpressionNode.range[0], dotToken.range[0]);
const dotToken = tokenStore.getTokenBefore(memberExpressionNode.property);
const targetSource = sourceCode.getText().slice(
sourceCode.getRange(memberExpressionNode)[0],
sourceCode.getRange(dotToken)[0],
);

@@ -87,4 +92,4 @@ // Strip default `fromIndex`

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
create,
const config = {
create: checkVueTemplate(create),
meta: {

@@ -104,1 +109,3 @@ type: 'suggestion',

};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {findVariable, getStaticValue, getPropertyName} = require('@eslint-community/eslint-utils');
const {isMethodCall} = require('./ast/index.js');
const {removeArgument} = require('./fix/index.js');
import {findVariable, getStaticValue, getPropertyName} from '@eslint-community/eslint-utils';
import {isMethodCall} from './ast/index.js';
import {removeArgument} from './fix/index.js';

@@ -149,3 +148,3 @@ const MESSAGE_ID = 'prefer-json-parse-buffer';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -162,1 +161,3 @@ meta: {

};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const escapeString = require('./utils/escape-string.js');
const translateToKey = require('./shared/event-keys.js');
const {isNumberLiteral} = require('./ast/index.js');
import escapeString from './utils/escape-string.js';
import translateToKey from './shared/event-keys.js';
import {isNumberLiteral} from './ast/index.js';

@@ -176,3 +175,3 @@ const MESSAGE_ID = 'prefer-keyboard-event-key';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -189,1 +188,3 @@ meta: {

};
export default config;

@@ -1,6 +0,5 @@

'use strict';
const {isParenthesized, getParenthesizedText} = require('./utils/parentheses.js');
const isSameReference = require('./utils/is-same-reference.js');
const shouldAddParenthesesToLogicalExpressionChild = require('./utils/should-add-parentheses-to-logical-expression-child.js');
const needsSemicolon = require('./utils/needs-semicolon.js');
import {isParenthesized, getParenthesizedText} from './utils/parentheses.js';
import isSameReference from './utils/is-same-reference.js';
import shouldAddParenthesesToLogicalExpressionChild from './utils/should-add-parentheses-to-logical-expression-child.js';
import needsSemicolon from './utils/needs-semicolon.js';

@@ -148,3 +147,3 @@ const MESSAGE_ID_ERROR = 'prefer-logical-operator-over-ternary/error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -162,1 +161,3 @@ meta: {

};
export default config;

@@ -1,3 +0,3 @@

'use strict';
const {fixSpaceAroundKeyword} = require('./fix/index.js');
import {isBigIntLiteral, isCallExpression} from './ast/index.js';
import {fixSpaceAroundKeyword} from './fix/index.js';

@@ -9,2 +9,28 @@ const MESSAGE_ID = 'prefer-math-min-max';

const isNumberTypeAnnotation = typeAnnotation => {
if (typeAnnotation.type === 'TSNumberKeyword') {
return true;
}
if (typeAnnotation.type === 'TSTypeAnnotation' && typeAnnotation.typeAnnotation.type === 'TSNumberKeyword') {
return true;
}
if (typeAnnotation.type === 'TSTypeReference' && typeAnnotation.typeName.name === 'Number') {
return true;
}
return false;
};
const getExpressionText = (node, sourceCode) => {
const expressionNode = node.type === 'TSAsExpression' ? node.expression : node;
if (node.type === 'TSAsExpression') {
return getExpressionText(expressionNode, sourceCode);
}
return sourceCode.getText(expressionNode);
};
/** @param {import('eslint').Rule.RuleContext} context */

@@ -21,4 +47,19 @@ const create = context => ({

const {operator, left, right} = test;
const [leftText, rightText, alternateText, consequentText] = [left, right, alternate, consequent].map(node => context.sourceCode.getText(node));
const hasBigInt = [left, right].some(
node =>
isBigIntLiteral(node)
|| isCallExpression(node, {
name: 'BigInt',
argumentsLength: 1,
optional: false,
}),
);
if (hasBigInt) {
return;
}
const [leftText, rightText, alternateText, consequentText] = [left, right, alternate, consequent].map(node => getExpressionText(node, context.sourceCode));
const isGreaterOrEqual = operator === '>' || operator === '>=';

@@ -50,2 +91,83 @@ const isLessOrEqual = operator === '<' || operator === '<=';

for (const node of [left, right]) {
let expressionNode = node;
if (expressionNode.typeAnnotation && expressionNode.type === 'TSAsExpression') {
// Ignore if the test is not a number comparison operator
if (!isNumberTypeAnnotation(expressionNode.typeAnnotation)) {
return;
}
expressionNode = expressionNode.expression;
}
// Find variable declaration
if (expressionNode.type === 'Identifier') {
const variable = context.sourceCode.getScope(expressionNode).variables.find(variable => variable.name === expressionNode.name);
for (const definition of variable?.defs ?? []) {
switch (definition.type) {
case 'Parameter': {
const identifier = definition.name;
/**
Capture the following statement
```js
function foo(a: number) {}
```
*/
if (identifier.typeAnnotation?.type === 'TSTypeAnnotation' && !isNumberTypeAnnotation(identifier.typeAnnotation)) {
return;
}
/**
Capture the following statement
```js
function foo(a = 10) {}
```
*/
if (identifier.parent.type === 'AssignmentPattern' && identifier.parent.right.type === 'Literal' && typeof identifier.parent.right.value !== 'number') {
return;
}
break;
}
case 'Variable': {
/** @type {import('estree').VariableDeclarator} */
const variableDeclarator = definition.node;
/**
Capture the following statement
```js
var foo: number
```
*/
if (variableDeclarator.id.typeAnnotation?.type === 'TSTypeAnnotation' && !isNumberTypeAnnotation(variableDeclarator.id.typeAnnotation)) {
return;
}
/**
Capture the following statement
```js
var foo = 10
```
*/
if (variableDeclarator.init?.type === 'Literal' && typeof variableDeclarator.init.value !== 'number') {
return;
}
break;
}
default:
}
}
}
}
return {

@@ -72,3 +194,3 @@ node: conditionalExpression,

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -85,1 +207,3 @@ meta: {

};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {hasSideEffect} = require('@eslint-community/eslint-utils');
const {fixSpaceAroundKeyword} = require('./fix/index.js');
const {isLiteral} = require('./ast/index.js');
import {hasSideEffect} from '@eslint-community/eslint-utils';
import {fixSpaceAroundKeyword} from './fix/index.js';
import {isLiteral} from './ast/index.js';

@@ -98,3 +97,3 @@ const ERROR_BITWISE = 'error-bitwise';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -112,1 +111,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {isValueNotUsable} = require('./utils/index.js');
const {isMethodCall} = require('./ast/index.js');
import {isValueNotUsable} from './utils/index.js';
import {isMethodCall} from './ast/index.js';

@@ -131,3 +130,3 @@ const messages = {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -144,1 +143,3 @@ meta: {

};
export default config;

@@ -1,9 +0,4 @@

'use strict';
const {
getParenthesizedText,
getParenthesizedRange,
isSameReference,
} = require('./utils/index.js');
const {isLiteral, isMethodCall} = require('./ast/index.js');
const {replaceNodeOrTokenAndSpacesBefore, removeParentheses} = require('./fix/index.js');
import {getParenthesizedText, getParenthesizedRange, isSameReference} from './utils/index.js';
import {isLiteral, isMethodCall} from './ast/index.js';
import {replaceNodeOrTokenAndSpacesBefore, removeParentheses} from './fix/index.js';

@@ -177,3 +172,3 @@ const MESSAGE_ID = 'prefer-modern-math-apis';

getParenthesizedRange(expression.left, sourceCode)[1],
expression.range[1],
sourceCode.getRange(expression)[1],
]);

@@ -203,3 +198,3 @@ }

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -216,1 +211,3 @@ meta: {

};
export default config;

@@ -1,11 +0,6 @@

'use strict';
const isShadowed = require('./utils/is-shadowed.js');
const assertToken = require('./utils/assert-token.js');
const {getCallExpressionTokens} = require('./utils/index.js');
const {isStaticRequire, isReferenceIdentifier, isFunction} = require('./ast/index.js');
const {
removeParentheses,
replaceReferenceIdentifier,
removeSpacesAfter,
} = require('./fix/index.js');
import isShadowed from './utils/is-shadowed.js';
import assertToken from './utils/assert-token.js';
import {getCallExpressionTokens} from './utils/index.js';
import {isStaticRequire, isReferenceIdentifier, isFunction} from './ast/index.js';
import {removeParentheses, replaceReferenceIdentifier, removeSpacesAfter} from './fix/index.js';

@@ -369,3 +364,3 @@ const ERROR_USE_STRICT_DIRECTIVE = 'error/use-strict-directive';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -383,1 +378,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {getFunctionHeadLocation, getFunctionNameWithKind} = require('@eslint-community/eslint-utils');
const {functionTypes} = require('./ast/index.js');
import {getFunctionHeadLocation, getFunctionNameWithKind} from '@eslint-community/eslint-utils';
import {functionTypes} from './ast/index.js';

@@ -175,3 +174,3 @@ const MESSAGE_ID = 'prefer-native-coercion-functions';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -188,1 +187,3 @@ meta: {

};
export default config;

@@ -1,8 +0,4 @@

'use strict';
const {
getNegativeIndexLengthNode,
removeLengthNode,
} = require('./shared/negative-index.js');
const typedArray = require('./shared/typed-array.js');
const {isLiteral} = require('./ast/index.js');
import {getNegativeIndexLengthNode, removeLengthNode} from './shared/negative-index.js';
import typedArray from './shared/typed-array.js';
import {isLiteral} from './ast/index.js';

@@ -203,3 +199,3 @@ const MESSAGE_ID = 'prefer-negative-index';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -216,1 +212,3 @@ meta: {

};
export default config;

@@ -1,5 +0,3 @@

'use strict';
const isBuiltinModule = require('is-builtin-module');
const {replaceStringLiteral} = require('./fix/index.js');
const isStaticRequire = require('./ast/is-static-require.js');
import isBuiltinModule from 'is-builtin-module';
import isStaticRequire from './ast/is-static-require.js';

@@ -11,3 +9,3 @@ const MESSAGE_ID = 'prefer-node-protocol';

const create = () => ({
const create = context => ({
Literal(node) {

@@ -42,2 +40,3 @@ if (!(

const insertPosition = context.sourceCode.getRange(node)[0] + 1; // After quote
return {

@@ -48,3 +47,3 @@ node,

/** @param {import('eslint').Rule.RuleFixer} fixer */
fix: fixer => replaceStringLiteral(fixer, node, 'node:', 0, 0),
fix: fixer => fixer.insertTextAfterRange([insertPosition, insertPosition], 'node:'),
};

@@ -55,3 +54,3 @@ },

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -68,1 +67,3 @@ meta: {

};
export default config;

@@ -1,6 +0,4 @@

'use strict';
const {GlobalReferenceTracker} = require('./utils/global-reference-tracker.js');
const {replaceReferenceIdentifier} = require('./fix/index.js');
const {fixSpaceAroundKeyword} = require('./fix/index.js');
const isLeftHandSide = require('./utils/is-left-hand-side.js');
import {GlobalReferenceTracker} from './utils/global-reference-tracker.js';
import {replaceReferenceIdentifier, fixSpaceAroundKeyword} from './fix/index.js';
import isLeftHandSide from './utils/is-left-hand-side.js';

@@ -116,7 +114,5 @@ const MESSAGE_ID_ERROR = 'error';

type: 'boolean',
default: false,
},
checkNaN: {
type: 'boolean',
default: true,
},

@@ -128,3 +124,3 @@ },

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -140,4 +136,12 @@ meta: {

schema,
defaultOptions: [
{
checkInfinity: false,
checkNaN: true,
},
],
messages,
},
};
export default config;

@@ -1,6 +0,5 @@

'use strict';
const {isCommaToken, isArrowToken, isClosingParenToken} = require('@eslint-community/eslint-utils');
const {isMethodCall, isLiteral} = require('./ast/index.js');
const {removeParentheses} = require('./fix/index.js');
const {
import {isCommaToken, isArrowToken, isClosingParenToken} from '@eslint-community/eslint-utils';
import {isMethodCall, isLiteral} from './ast/index.js';
import {removeParentheses} from './fix/index.js';
import {
getParentheses,

@@ -10,4 +9,4 @@ getParenthesizedText,

isSameIdentifier,
} = require('./utils/index.js');
const {isCallExpression} = require('./ast/call-or-new-expression.js');
} from './utils/index.js';
import {isCallExpression} from './ast/call-or-new-expression.js';

@@ -105,5 +104,5 @@ const MESSAGE_ID_REDUCE = 'reduce';

const startToken = sourceCode.getTokenBefore(firstToken);
const [start] = startToken.range;
const [, end] = lastToken.range;
return fixer.replaceTextRange([start, end], '');
const [start] = sourceCode.getRange(startToken);
const [, end] = sourceCode.getRange(lastToken);
return fixer.removeRange([start, end]);
};

@@ -243,3 +242,3 @@

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -254,4 +253,7 @@ meta: {

schema,
defaultOptions: [{}],
messages,
},
};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {isOpeningParenToken, isClosingParenToken} = require('@eslint-community/eslint-utils');
const assertToken = require('./utils/assert-token.js');
import {isOpeningParenToken, isClosingParenToken} from '@eslint-community/eslint-utils';
import assertToken from './utils/assert-token.js';

@@ -52,4 +51,4 @@ const MESSAGE_ID_WITH_NAME = 'with-name';

const [, endOfClosingParenthesis] = tokenAfter.range;
const [startOfCatchClauseBody] = parent.body.range;
const [, endOfClosingParenthesis] = sourceCode.getRange(tokenAfter);
const [startOfCatchClauseBody] = sourceCode.getRange(parent.body);
const text = sourceCode.text.slice(endOfClosingParenthesis, startOfCatchClauseBody);

@@ -66,3 +65,3 @@ const leadingSpacesLength = text.length - text.trimStart().length;

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -79,1 +78,3 @@ meta: {

};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {getPropertyName, ReferenceTracker} = require('@eslint-community/eslint-utils');
const {fixSpaceAroundKeyword} = require('./fix/index.js');
const {isMemberExpression, isMethodCall} = require('./ast/index.js');
import {getPropertyName, ReferenceTracker} from '@eslint-community/eslint-utils';
import {fixSpaceAroundKeyword} from './fix/index.js';
import {isMemberExpression, isMethodCall} from './ast/index.js';

@@ -150,3 +149,3 @@ const messages = {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -163,1 +162,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {isNodeValueNotDomNode} = require('./utils/index.js');
const {isMethodCall, isStringLiteral, isNullLiteral} = require('./ast/index.js');
import {isNodeValueNotDomNode} from './utils/index.js';
import {isMethodCall, isStringLiteral, isNullLiteral} from './ast/index.js';

@@ -158,3 +157,3 @@ const MESSAGE_ID = 'prefer-query-selector';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -171,1 +170,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {getPropertyName} = require('@eslint-community/eslint-utils');
const {isNullLiteral, isMethodCall} = require('./ast/index.js');
import {getPropertyName} from '@eslint-community/eslint-utils';
import {isNullLiteral, isMethodCall} from './ast/index.js';

@@ -87,3 +86,3 @@ const MESSAGE_ID = 'prefer-reflect-apply';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -100,1 +99,3 @@ meta: {

};
export default config;

@@ -1,9 +0,5 @@

'use strict';
const {isParenthesized, getStaticValue} = require('@eslint-community/eslint-utils');
const {checkVueTemplate} = require('./utils/rule.js');
const {isRegexLiteral, isNewExpression, isMethodCall} = require('./ast/index.js');
const {
isBooleanNode,
shouldAddParenthesesToMemberExpressionObject,
} = require('./utils/index.js');
import {isParenthesized, getStaticValue} from '@eslint-community/eslint-utils';
import {checkVueTemplate} from './utils/rule.js';
import {isRegexLiteral, isNewExpression, isMethodCall} from './ast/index.js';
import {isBooleanNode, shouldAddParenthesesToMemberExpressionObject} from './utils/index.js';

@@ -145,3 +141,3 @@ const REGEXP_EXEC = 'regexp-exec';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create: checkVueTemplate(create),

@@ -159,1 +155,3 @@ meta: {

};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {findVariable} = require('@eslint-community/eslint-utils');
const {getVariableIdentifiers} = require('./utils/index.js');
const {isCallOrNewExpression, isMethodCall} = require('./ast/index.js');
import {findVariable} from '@eslint-community/eslint-utils';
import {getVariableIdentifiers} from './utils/index.js';
import {isCallOrNewExpression, isMethodCall} from './ast/index.js';

@@ -175,3 +174,3 @@ const MESSAGE_ID_ERROR = 'error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -189,1 +188,3 @@ meta: {

};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {findVariable} = require('@eslint-community/eslint-utils');
const {fixSpaceAroundKeyword} = require('./fix/index.js');
const {isNewExpression, isMemberExpression} = require('./ast/index.js');
import {findVariable} from '@eslint-community/eslint-utils';
import {fixSpaceAroundKeyword} from './fix/index.js';
import {isNewExpression, isMemberExpression} from './ast/index.js';

@@ -93,3 +92,3 @@ const MESSAGE_ID = 'prefer-set-size';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -106,1 +105,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {getStaticValue, isCommaToken, hasSideEffect} = require('@eslint-community/eslint-utils');
const {
import {getStaticValue, isCommaToken, hasSideEffect} from '@eslint-community/eslint-utils';
import {
getParenthesizedRange,

@@ -10,5 +9,5 @@ getParenthesizedText,

hasOptionalChainElement,
} = require('./utils/index.js');
const {removeMethodCall} = require('./fix/index.js');
const {isLiteral, isMethodCall} = require('./ast/index.js');
} from './utils/index.js';
import {removeMethodCall} from './fix/index.js';
import {isLiteral, isMethodCall} from './ast/index.js';

@@ -67,4 +66,4 @@ const ERROR_ARRAY_FROM = 'array-from';

) {
const start = node.range[0] + 1;
const end = sourceCode.getLastToken(node, 1).range[0];
const start = sourceCode.getRange(node)[0] + 1;
const [end] = sourceCode.getRange(sourceCode.getLastToken(node, 1));
return sourceCode.text.slice(start, end);

@@ -132,3 +131,3 @@ }

const [start] = getParenthesizedRange(firstArgument, sourceCode);
let [, end] = sourceCode.getTokenAfter(lastArgument, isCommaToken).range;
let [, end] = sourceCode.getRange(sourceCode.getTokenAfter(lastArgument, isCommaToken));

@@ -139,3 +138,3 @@ const textAfter = sourceCode.text.slice(end);

return fixer.replaceTextRange([start, end], '');
return fixer.removeRange([start, end]);
}

@@ -509,3 +508,3 @@

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -523,1 +522,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {isStringLiteral, isDirective} = require('./ast/index.js');
const {fixSpaceAroundKeyword} = require('./fix/index.js');
import {isStringLiteral, isDirective} from './ast/index.js';
import {fixSpaceAroundKeyword} from './fix/index.js';

@@ -44,4 +43,4 @@ const MESSAGE_ID = 'prefer-string-raw';

node.parent.type === 'ImportDeclaration'
|| node.parent.type === 'ExportNamedDeclaration'
|| node.parent.type === 'ExportAllDeclaration'
|| node.parent.type === 'ExportNamedDeclaration'
|| node.parent.type === 'ExportAllDeclaration'
) && node.parent.source === node

@@ -52,2 +51,3 @@ )

|| (node.parent.type === 'TSEnumMember' && (node.parent.initializer === node || node.parent.id === node))
|| (node.parent.type === 'ImportAttribute' && (node.parent.key === node || node.parent.value === node))
) {

@@ -57,2 +57,3 @@ return;

const {sourceCode} = context;
const {raw} = node;

@@ -64,3 +65,3 @@ if (

|| raw.includes('${')
|| node.loc.start.line !== node.loc.end.line
|| sourceCode.getLoc(node).start.line !== sourceCode.getLoc(node).end.line
) {

@@ -80,3 +81,3 @@ return;

yield fixer.replaceText(node, `String.raw\`${unescaped}\``);
yield * fixSpaceAroundKeyword(fixer, node, context.sourceCode);
yield * fixSpaceAroundKeyword(fixer, node, sourceCode);
},

@@ -88,3 +89,3 @@ };

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -101,1 +102,3 @@ meta: {

};
export default config;

@@ -1,7 +0,7 @@

'use strict';
const {getStaticValue} = require('@eslint-community/eslint-utils');
const {parse: parseRegExp} = require('regjsparser');
const escapeString = require('./utils/escape-string.js');
const {isRegexLiteral, isNewExpression, isMethodCall} = require('./ast/index.js');
import {getStaticValue} from '@eslint-community/eslint-utils';
import regjsparser from 'regjsparser';
import escapeString from './utils/escape-string.js';
import {isRegexLiteral, isNewExpression, isMethodCall} from './ast/index.js';
const {parse: parseRegExp} = regjsparser;
const MESSAGE_ID_USE_REPLACE_ALL = 'method';

@@ -135,3 +135,3 @@ const MESSAGE_ID_USE_STRING = 'pattern';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -148,1 +148,3 @@ meta: {

};
export default config;

@@ -1,6 +0,5 @@

'use strict';
const {getStaticValue} = require('@eslint-community/eslint-utils');
const {getParenthesizedText, getParenthesizedRange} = require('./utils/parentheses.js');
const {replaceArgument} = require('./fix/index.js');
const {isNumberLiteral, isMethodCall} = require('./ast/index.js');
import {getStaticValue} from '@eslint-community/eslint-utils';
import {getParenthesizedText, getParenthesizedRange} from './utils/parentheses.js';
import {replaceArgument} from './fix/index.js';
import {isNumberLiteral, isMethodCall} from './ast/index.js';

@@ -169,3 +168,3 @@ const MESSAGE_ID_SUBSTR = 'substr';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -182,1 +181,3 @@ meta: {

};
export default config;

@@ -1,8 +0,7 @@

'use strict';
const {isParenthesized, getStaticValue} = require('@eslint-community/eslint-utils');
const escapeString = require('./utils/escape-string.js');
const shouldAddParenthesesToMemberExpressionObject = require('./utils/should-add-parentheses-to-member-expression-object.js');
const shouldAddParenthesesToLogicalExpressionChild = require('./utils/should-add-parentheses-to-logical-expression-child.js');
const {getParenthesizedText, getParenthesizedRange} = require('./utils/parentheses.js');
const {isMethodCall, isRegexLiteral} = require('./ast/index.js');
import {isParenthesized, getStaticValue} from '@eslint-community/eslint-utils';
import escapeString from './utils/escape-string.js';
import shouldAddParenthesesToMemberExpressionObject from './utils/should-add-parentheses-to-member-expression-object.js';
import shouldAddParenthesesToLogicalExpressionChild from './utils/should-add-parentheses-to-logical-expression-child.js';
import {getParenthesizedText, getParenthesizedRange} from './utils/parentheses.js';
import {isMethodCall, isRegexLiteral} from './ast/index.js';

@@ -188,3 +187,3 @@ const MESSAGE_STARTS_WITH = 'prefer-starts-with';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -202,1 +201,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {isMethodCall} = require('./ast/index.js');
import {isMethodCall} from './ast/index.js';

@@ -34,3 +33,3 @@ const MESSAGE_ID = 'prefer-string-trim-start-end';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -47,1 +46,3 @@ meta: {

};
export default config;

@@ -1,8 +0,4 @@

'use strict';
const {isCallExpression, isMethodCall} = require('./ast/index.js');
const {removeParentheses} = require('./fix/index.js');
const {
isNodeMatchesNameOrPath,
getCallExpressionTokens,
} = require('./utils/index.js');
import {isCallExpression, isMethodCall} from './ast/index.js';
import {removeParentheses} from './fix/index.js';
import {isNodeMatchesNameOrPath, getCallExpressionTokens} from './utils/index.js';

@@ -54,2 +50,3 @@ const MESSAGE_ID_ERROR = 'prefer-structured-clone/error';

const jsonStringify = callExpression.arguments[0];
const {sourceCode} = context;

@@ -59,4 +56,4 @@ return {

loc: {
start: jsonParse.loc.start,
end: jsonStringify.callee.loc.end,
start: sourceCode.getLoc(jsonParse).start,
end: sourceCode.getLoc(jsonStringify.callee).end,
},

@@ -73,4 +70,2 @@ messageId: MESSAGE_ID_ERROR,

const {sourceCode} = context;
yield fixer.remove(jsonStringify.callee);

@@ -142,3 +137,3 @@ yield * removeParentheses(jsonStringify.callee, fixer, sourceCode);

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -153,4 +148,7 @@ meta: {

schema,
defaultOptions: [{}],
messages,
},
};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {hasSideEffect} = require('@eslint-community/eslint-utils');
const isSameReference = require('./utils/is-same-reference.js');
const getIndentString = require('./utils/get-indent-string.js');
import {hasSideEffect} from '@eslint-community/eslint-utils';
import isSameReference from './utils/is-same-reference.js';
import getIndentString from './utils/get-indent-string.js';

@@ -227,12 +226,15 @@ const MESSAGE_ID = 'prefer-switch';

for (const {statement, compareExpressions} of ifStatements) {
const {consequent, alternate, range} = statement;
const headRange = [range[0], consequent.range[0]];
const {consequent, alternate} = statement;
if (alternate) {
const [, start] = consequent.range;
const [end] = alternate.range;
yield fixer.replaceTextRange([start, end], '');
const [, start] = sourceCode.getRange(consequent);
const [end] = sourceCode.getRange(alternate);
yield fixer.removeRange([start, end]);
}
yield fixer.replaceTextRange(headRange, '');
const headRange = [
sourceCode.getRange(statement)[0],
sourceCode.getRange(consequent)[0],
];
yield fixer.removeRange(headRange);
for (const {left, right} of compareExpressions) {

@@ -292,4 +294,4 @@ const node = isSame(left, discriminant) ? right : left;

loc: {
start: node.loc.start,
end: node.consequent.loc.start,
start: sourceCode.getLoc(node).start,
end: sourceCode.getLoc(node.consequent).start,
},

@@ -320,3 +322,2 @@ messageId: MESSAGE_ID,

minimum: 2,
default: 3,
},

@@ -329,3 +330,2 @@ emptyDefaultCase: {

],
default: 'no-default-comment',
},

@@ -337,3 +337,3 @@ },

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -348,4 +348,12 @@ meta: {

schema,
defaultOptions: [
{
minimumCases: 3,
emptyDefaultCase: 'no-default-comment',
},
],
messages,
},
};
export default config;

@@ -1,11 +0,12 @@

'use strict';
const {isParenthesized} = require('@eslint-community/eslint-utils');
const avoidCapture = require('./utils/avoid-capture.js');
const needsSemicolon = require('./utils/needs-semicolon.js');
const isSameReference = require('./utils/is-same-reference.js');
const getIndentString = require('./utils/get-indent-string.js');
const {getParenthesizedText} = require('./utils/parentheses.js');
const shouldAddParenthesesToConditionalExpressionChild = require('./utils/should-add-parentheses-to-conditional-expression-child.js');
const {extendFixRange} = require('./fix/index.js');
const getScopes = require('./utils/get-scopes.js');
import {isParenthesized} from '@eslint-community/eslint-utils';
import {
getAvailableVariableName,
needsSemicolon,
isSameReference,
getIndentString,
getParenthesizedText,
shouldAddParenthesesToConditionalExpressionChild,
getScopes,
} from './utils/index.js';
import {extendFixRange} from './fix/index.js';

@@ -36,2 +37,3 @@ const messageId = 'prefer-ternary';

// eslint-disable-next-line internal/no-restricted-property-access -- Need fix
const isSingleLineNode = node => node.loc.start.line === node.loc.end.line;

@@ -221,3 +223,3 @@

const scopes = getScopes(scope);
const errorName = avoidCapture('error', scopes, isSafeName);
const errorName = getAvailableVariableName('error', scopes, isSafeName);

@@ -254,3 +256,3 @@ for (const scope of scopes) {

if (generateNewVariables) {
yield * extendFixRange(fixer, sourceCode.ast.range);
yield * extendFixRange(fixer, sourceCode.getRange(sourceCode.ast));
}

@@ -267,3 +269,2 @@ };

enum: ['always', 'only-single-line'],
default: 'always',
},

@@ -273,3 +274,3 @@ ];

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -284,2 +285,3 @@ meta: {

schema,
defaultOptions: ['always'],
messages: {

@@ -290,1 +292,3 @@ [messageId]: 'This `if` statement can be replaced by a ternary expression.',

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {findVariable, getFunctionHeadLocation} = require('@eslint-community/eslint-utils');
const {isFunction, isMemberExpression, isMethodCall} = require('./ast/index.js');
import {findVariable, getFunctionHeadLocation} from '@eslint-community/eslint-utils';
import {isFunction, isMemberExpression, isMethodCall} from './ast/index.js';

@@ -142,3 +141,3 @@ const ERROR_PROMISE = 'promise';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -155,1 +154,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {isNewExpression} = require('./ast/index.js');
import {isNewExpression} from './ast/index.js';

@@ -141,3 +140,3 @@ const MESSAGE_ID = 'prefer-type-error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -154,1 +153,3 @@ meta: {

};
export default config;

@@ -1,13 +0,15 @@

'use strict';
const path = require('node:path');
const {defaultsDeep, upperFirst, lowerFirst} = require('./utils/lodash.js');
const avoidCapture = require('./utils/avoid-capture.js');
const cartesianProductSamples = require('./utils/cartesian-product-samples.js');
const isShorthandPropertyValue = require('./utils/is-shorthand-property-value.js');
const isShorthandImportLocal = require('./utils/is-shorthand-import-local.js');
const getVariableIdentifiers = require('./utils/get-variable-identifiers.js');
const {defaultReplacements, defaultAllowList, defaultIgnore} = require('./shared/abbreviations.js');
const {renameVariable} = require('./fix/index.js');
const getScopes = require('./utils/get-scopes.js');
const {isStaticRequire} = require('./ast/index.js');
import path from 'node:path';
import {isRegExp} from 'node:util/types';
import {defaultsDeep, upperFirst, lowerFirst} from './utils/lodash.js';
import {
getAvailableVariableName,
cartesianProductSamples,
isShorthandPropertyValue,
isShorthandImportLocal,
getVariableIdentifiers,
getScopes,
} from './utils/index.js';
import {defaultReplacements, defaultAllowList, defaultIgnore} from './shared/abbreviations.js';
import {renameVariable} from './fix/index.js';
import {isStaticRequire} from './ast/index.js';

@@ -54,3 +56,3 @@ const MESSAGE_ID_REPLACE = 'replace';

ignore = ignore.map(
pattern => pattern instanceof RegExp ? pattern : new RegExp(pattern, 'u'),
pattern => isRegExp(pattern) ? pattern : new RegExp(pattern, 'u'),
);

@@ -443,3 +445,3 @@

variableReplacements.samples = variableReplacements.samples.map(
name => avoidCapture(name, scopes, isSafeName),
name => getAvailableVariableName(name, scopes, isSafeName),
);

@@ -636,3 +638,3 @@

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -647,4 +649,7 @@ meta: {

schema,
defaultOptions: [{}],
messages,
},
};
export default config;

@@ -1,5 +0,3 @@

'use strict';
const {getStaticValue} = require('@eslint-community/eslint-utils');
const {isNewExpression, isStringLiteral} = require('./ast/index.js');
const {replaceStringLiteral} = require('./fix/index.js');
import {getStaticValue} from '@eslint-community/eslint-utils';
import {isNewExpression, isStringLiteral} from './ast/index.js';

@@ -74,3 +72,4 @@ const MESSAGE_ID_NEVER = 'never';

return fixer => replaceStringLiteral(fixer, node, DOT_SLASH, 0, 0);
const insertPosition = sourceCode.getRange(node)[0] + 1; // After quote
return fixer => fixer.insertTextAfterRange([insertPosition, insertPosition], DOT_SLASH);
}

@@ -83,3 +82,4 @@

return fixer => replaceStringLiteral(fixer, node, '', 0, 2);
const start = sourceCode.getRange(node)[0] + 1; // After quote
return fixer => fixer.removeRange([start, start + 2]);
}

@@ -115,4 +115,4 @@

fix(fixer) {
const start = firstPart.range[0] + 1;
return fixer.removeRange([start, start + 2]);
const start = context.sourceCode.getRange(firstPart)[0] + 1;
return fixer.removeRange([start, start + DOT_SLASH.length]);
},

@@ -154,3 +154,2 @@ },

enum: ['never', 'always'],
default: 'never',
},

@@ -160,3 +159,3 @@ ];

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -172,4 +171,7 @@ meta: {

schema,
defaultOptions: ['never'],
messages,
},
};
export default config;

@@ -1,5 +0,4 @@

'use strict';
const {appendArgument} = require('./fix/index.js');
const {isMethodCall} = require('./ast/index.js');
const {isArrayPrototypeProperty} = require('./utils/index.js');
import {appendArgument} from './fix/index.js';
import {isMethodCall} from './ast/index.js';
import {isArrayPrototypeProperty} from './utils/index.js';

@@ -42,4 +41,4 @@ const MESSAGE_ID = 'require-array-join-separator';

loc: {
start: penultimateToken.loc[isPrototypeMethod ? 'end' : 'start'],
end: lastToken.loc.end,
start: sourceCode.getLoc(penultimateToken)[isPrototypeMethod ? 'end' : 'start'],
end: sourceCode.getLoc(lastToken).end,
},

@@ -54,3 +53,3 @@ messageId: MESSAGE_ID,

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -67,1 +66,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {appendArgument} = require('./fix/index.js');
const {isMethodCall} = require('./ast/index.js');
import {appendArgument} from './fix/index.js';
import {isMethodCall} from './ast/index.js';

@@ -33,4 +32,4 @@ const MESSAGE_ID = 'require-number-to-fixed-digits-argument';

loc: {
start: openingParenthesis.loc.start,
end: closingParenthesis.loc.end,
start: sourceCode.getLoc(openingParenthesis).start,
end: sourceCode.getLoc(closingParenthesis).end,
},

@@ -45,3 +44,3 @@ messageId: MESSAGE_ID,

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -58,1 +57,3 @@ meta: {

};
export default config;

@@ -1,4 +0,3 @@

'use strict';
const {isMethodCall} = require('./ast/index.js');
const {appendArgument} = require('./fix/index.js');
import {isMethodCall} from './ast/index.js';
import {appendArgument} from './fix/index.js';

@@ -45,4 +44,4 @@ const ERROR = 'error';

loc: {
start: penultimateToken.loc.end,
end: lastToken.loc.end,
start: sourceCode.getLoc(penultimateToken).end,
end: sourceCode.getLoc(lastToken).end,
},

@@ -62,3 +61,3 @@ messageId: ERROR,

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -77,1 +76,3 @@ meta: {

};
export default config;
/* eslint sort-keys: ["error", "asc", {"caseSensitive": false}] */
'use strict';
module.exports.defaultReplacements = {
export const defaultReplacements = {
acc: {

@@ -217,2 +217,8 @@ accumulator: true,

},
util: {
utility: true,
},
utils: {
utilities: true,
},
val: {

@@ -232,3 +238,3 @@ value: true,

module.exports.defaultAllowList = {
export const defaultAllowList = {
// React.Component Class property

@@ -259,3 +265,3 @@ // https://reactjs.org/docs/react-component.html#defaultprops

module.exports.defaultIgnore = [
export const defaultIgnore = [
// Internationalization and localization

@@ -262,0 +268,0 @@ // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1188

@@ -1,3 +0,1 @@

'use strict';
const getVendorPrefixedName = eventName => [

@@ -10,3 +8,3 @@ `webkit${eventName}`,

// https://github.com/google/closure-library/blob/8782d8ba16ef2dd4a508d2081a6938f054fc60e8/closure/goog/events/eventtype.js#L44
module.exports = new Set([
const domEvents = new Set([
// Mouse events

@@ -277,1 +275,3 @@ 'click',

]);
export default domEvents;
/* eslint sort-keys: ["error", "asc", {natural: true}] */
'use strict';
// https://github.com/facebook/react/blob/b87aabd/packages/react-dom/src/events/getEventKey.js#L36
// Only meta characters which can't be deciphered from `String.fromCharCode()`
module.exports = {
const eventKeys = {
8: 'Backspace',

@@ -53,1 +53,3 @@ 9: 'Tab',

};
export default eventKeys;

@@ -1,5 +0,4 @@

'use strict';
const isSameReference = require('../utils/is-same-reference.js');
const {getParenthesizedRange} = require('../utils/parentheses.js');
const {isNumberLiteral} = require('../ast/index.js');
import isSameReference from '../utils/is-same-reference.js';
import {getParenthesizedRange} from '../utils/parentheses.js';
import {isNumberLiteral} from '../ast/index.js';

@@ -12,2 +11,3 @@ const isLengthMemberExpression = node =>

&& node.property.name === 'length';
const isLiteralPositiveNumber = node =>

@@ -17,3 +17,3 @@ isNumberLiteral(node)

function getNegativeIndexLengthNode(node, objectNode) {
export function getNegativeIndexLengthNode(node, objectNode) {
if (!node) {

@@ -37,3 +37,3 @@ return;

function removeLengthNode(node, fixer, sourceCode) {
export function removeLengthNode(node, fixer, sourceCode) {
const [start, end] = getParenthesizedRange(node, sourceCode);

@@ -46,5 +46,1 @@ return fixer.removeRange([

module.exports = {
getNegativeIndexLengthNode,
removeLengthNode,
};

@@ -1,7 +0,5 @@

'use strict';
import {hasSideEffect, isParenthesized, findVariable} from '@eslint-community/eslint-utils';
import {isMethodCall} from '../ast/index.js';
import {isSameIdentifier, isFunctionSelfUsedInside} from '../utils/index.js';
const {hasSideEffect, isParenthesized, findVariable} = require('@eslint-community/eslint-utils');
const {isMethodCall} = require('../ast/index.js');
const {isSameIdentifier, isFunctionSelfUsedInside} = require('../utils/index.js');
const isSimpleCompare = (node, compareNode) =>

@@ -36,3 +34,3 @@ node.type === 'BinaryExpression'

function simpleArraySearchRule({method, replacement}) {
export default function simpleArraySearchRule({method, replacement}) {
// Add prefix to avoid conflicts in `prefer-includes` rule

@@ -128,3 +126,1 @@ const MESSAGE_ID_PREFIX = `prefer-${replacement}-over-${method}/`;

}
module.exports = simpleArraySearchRule;

@@ -1,5 +0,3 @@

'use strict';
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#description
module.exports = [
const typedArrayTypes = [
'Int8Array',

@@ -17,1 +15,3 @@ 'Uint8Array',

];
export default typedArrayTypes;

@@ -1,5 +0,4 @@

'use strict';
const escapeString = require('./utils/escape-string.js');
const escapeTemplateElementRaw = require('./utils/escape-template-element-raw.js');
const {replaceTemplateElement} = require('./fix/index.js');
import escapeString from './utils/escape-string.js';
import escapeTemplateElementRaw from './utils/escape-template-element-raw.js';
import {replaceTemplateElement} from './fix/index.js';

@@ -176,3 +175,3 @@ const defaultMessage = 'Prefer `{{suggest}}` over `{{match}}`.';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -188,4 +187,7 @@ meta: {

schema,
defaultOptions: [{}],
messages,
},
};
export default config;

@@ -1,6 +0,5 @@

'use strict';
const {isColonToken} = require('@eslint-community/eslint-utils');
const getSwitchCaseHeadLocation = require('./utils/get-switch-case-head-location.js');
const getIndentString = require('./utils/get-indent-string.js');
const {replaceNodeOrTokenAndSpacesBefore} = require('./fix/index.js');
import {isColonToken} from '@eslint-community/eslint-utils';
import getSwitchCaseHeadLocation from './utils/get-switch-case-head-location.js';
import getIndentString from './utils/get-indent-string.js';
import {replaceNodeOrTokenAndSpacesBefore} from './fix/index.js';

@@ -56,3 +55,3 @@ const MESSAGE_ID_EMPTY_CLAUSE = 'switch-case-braces/empty';

node,
loc: sourceCode.getFirstToken(consequent[0]).loc,
loc: sourceCode.getLoc(sourceCode.getFirstToken(consequent[0])),
messageId: MESSAGE_ID_EMPTY_CLAUSE,

@@ -89,3 +88,3 @@ fix: fixer => removeBraces(fixer, node, sourceCode),

node,
loc: sourceCode.getFirstToken(consequent[0]).loc,
loc: sourceCode.getLoc(sourceCode.getFirstToken(consequent[0])),
messageId: MESSAGE_ID_UNNECESSARY_BRACES,

@@ -100,3 +99,3 @@ fix: fixer => removeBraces(fixer, node, sourceCode),

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -111,4 +110,7 @@ meta: {

schema: [{enum: ['always', 'avoid']}],
defaultOptions: ['always'],
messages,
},
};
export default config;

@@ -1,12 +0,7 @@

'use strict';
const stripIndent = require('strip-indent');
const indentString = require('indent-string');
const esquery = require('esquery');
const {replaceTemplateElement} = require('./fix/index.js');
const {
isMethodCall,
isCallExpression,
isTaggedTemplateLiteral,
} = require('./ast/index.js');
const {isNodeMatches} = require('./utils/index.js');
import stripIndent from 'strip-indent';
import indentString from 'indent-string';
import esquery from 'esquery';
import {replaceTemplateElement} from './fix/index.js';
import {isMethodCall, isCallExpression, isTaggedTemplateLiteral} from './ast/index.js';
import {isNodeMatches} from './utils/index.js';

@@ -72,3 +67,3 @@ const MESSAGE_ID_IMPROPERLY_INDENTED_TEMPLATE = 'template-indent';

const startLine = sourceCode.lines[node.loc.start.line - 1];
const startLine = sourceCode.lines[sourceCode.getLoc(node).start.line - 1];
const marginMatch = startLine.match(/^(\s*)\S/);

@@ -92,5 +87,5 @@ const parentMargin = marginMatch ? marginMatch[1] : '';

= eol
+ indentString(trimmed, 1, {indent: parentMargin + indent})
+ eol
+ parentMargin;
+ indentString(trimmed, 1, {indent: parentMargin + indent})
+ eol
+ parentMargin;

@@ -211,3 +206,3 @@ if (fixed === joined) {

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -222,4 +217,7 @@ meta: {

schema,
defaultOptions: [{}],
messages,
},
};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {replaceStringLiteral} = require('./fix/index.js');
import {replaceStringRaw} from './fix/index.js';

@@ -69,3 +68,3 @@ const MESSAGE_ID_ERROR = 'text-encoding-identifier/error';

/** @param {import('eslint').Rule.RuleFixer} fixer */
const fix = fixer => replaceStringLiteral(fixer, node, replacement);
const fix = fixer => replaceStringRaw(fixer, node, replacement);

@@ -89,3 +88,3 @@ const problem = {

messageId: MESSAGE_ID_SUGGESTION,
fix: fixer => replaceStringLiteral(fixer, node, replacement),
fix: fixer => replaceStringRaw(fixer, node, replacement),
},

@@ -99,3 +98,3 @@ ];

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -113,1 +112,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {switchCallExpressionToNewExpression} = require('./fix/index.js');
import {switchCallExpressionToNewExpression} from './fix/index.js';

@@ -36,3 +35,3 @@ const messageId = 'throw-new-error';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
const config = {
create,

@@ -49,1 +48,3 @@ meta: {

};
export default config;

@@ -1,3 +0,2 @@

'use strict';
const {isMemberExpression} = require('../ast/index.js');
import {isMemberExpression} from '../ast/index.js';

@@ -57,8 +56,3 @@ /**

const isArrayPrototypeProperty = (node, options) => isPrototypeProperty(node, {...options, object: 'Array'});
const isObjectPrototypeProperty = (node, options) => isPrototypeProperty(node, {...options, object: 'Object'});
module.exports = {
isArrayPrototypeProperty,
isObjectPrototypeProperty,
};
export const isArrayPrototypeProperty = (node, options) => isPrototypeProperty(node, {...options, object: 'Array'});
export const isObjectPrototypeProperty = (node, options) => isPrototypeProperty(node, {...options, object: 'Object'});

@@ -1,5 +0,4 @@

'use strict';
const ISSUE_LINK_PREFIX = 'https://github.com/sindresorhus/eslint-plugin-unicorn/issues/new?';
const ISSUE_LINK_PREFIX = 'https://github.com/sindresorhus/eslint-plugin-unicorn/issues/new?';
function assertToken(token, {test, expected, ruleId}) {
export default function assertToken(token, {test, expected, ruleId}) {
if (test?.(token)) {

@@ -31,3 +30,1 @@ return;

}
module.exports = assertToken;

@@ -1,5 +0,3 @@

'use strict';
import isLogicalExpression from './is-logical-expression.js';
const isLogicalExpression = require('./is-logical-expression.js');
const isLogicNot = node => node?.type === 'UnaryExpression' && node.operator === '!';

@@ -32,3 +30,3 @@ const isLogicNotArgument = node => isLogicNot(node.parent) && node.parent.argument === node;

*/
function isBooleanNode(node) {
export function isBooleanNode(node) {
if (

@@ -76,5 +74,5 @@ isLogicNot(node)

*/
function getBooleanAncestor(node) {
export function getBooleanAncestor(node) {
let isNegative = false;
// eslint-disable-next-line no-constant-condition
while (true) {

@@ -93,3 +91,1 @@ if (isLogicNotArgument(node)) {

}
module.exports = {isBooleanNode, getBooleanAncestor};

@@ -1,5 +0,4 @@

'use strict';
const typedArray = require('../shared/typed-array.js');
import typedArray from '../shared/typed-array.js';
const enforceNew = [
export const enforceNew = [
'Object',

@@ -25,3 +24,3 @@ 'Array',

const disallowNew = [
export const disallowNew = [
'BigInt',

@@ -33,6 +32,1 @@ 'Boolean',

];
module.exports = {
enforceNew,
disallowNew,
};

@@ -1,4 +0,2 @@

'use strict';
module.exports = function cartesianProductSamples(combinations, length = Number.POSITIVE_INFINITY) {
export default function cartesianProductSamples(combinations, length = Number.POSITIVE_INFINITY) {
const total = combinations.reduce((total, {length}) => total * length, 1);

@@ -24,2 +22,2 @@

};
};
}

@@ -1,3 +0,2 @@

'use strict';
const packageJson = require('../../package.json');
import packageJson from '../../package.json' with {type: 'json'};

@@ -7,3 +6,3 @@ const repoUrl = 'https://github.com/sindresorhus/eslint-plugin-unicorn';

/** @returns {{ [ruleName: string]: import('eslint').Rule.RuleModule }} */
function createDeprecatedRules(data) {
export default function createDeprecatedRules(data) {
return Object.fromEntries(

@@ -25,3 +24,1 @@ Object.entries(data).map(([ruleId, replacedBy = []]) => [

}
module.exports = createDeprecatedRules;

@@ -1,5 +0,3 @@

'use strict';
import jsesc from 'jsesc';
const jsesc = require('jsesc');
/**

@@ -12,3 +10,3 @@ Escape string and wrap the result in quotes.

*/
module.exports = function escapeString(string, quote = '\'') {
export default function escapeString(string, quote = '\'') {
/* c8 ignore start */

@@ -27,2 +25,2 @@ if (typeof string !== 'string') {

});
};
}

@@ -1,3 +0,1 @@

'use strict';
const escapeTemplateElementRaw = string => string.replaceAll(

@@ -7,2 +5,3 @@ /(?<=(?:^|[^\\])(?:\\\\)*)(?<symbol>(?:`|\$(?={)))/g,

);
module.exports = escapeTemplateElementRaw;
export default escapeTemplateElementRaw;

@@ -1,3 +0,1 @@

'use strict';
// TODO: Support more types

@@ -10,6 +8,5 @@ function getPredicate(options) {

function getAncestor(node, options) {
export default function getAncestor(node, options) {
const predicate = getPredicate(options);
for (;node.parent; node = node.parent) {
for (; node.parent; node = node.parent) {
if (predicate(node)) {

@@ -20,3 +17,1 @@ return node;

}
module.exports = getAncestor;

@@ -1,7 +0,5 @@

'use strict';
import {builtinRules} from 'eslint/use-at-your-own-risk';
function getBuiltinRule(id) {
return require('eslint/use-at-your-own-risk').builtinRules.get(id);
export default function getBuiltinRule(id) {
return builtinRules.get(id);
}
module.exports = getBuiltinRule;

@@ -1,3 +0,2 @@

'use strict';
const getCallExpressionTokens = require('./get-call-expression-tokens.js');
import getCallExpressionTokens from './get-call-expression-tokens.js';

@@ -14,3 +13,3 @@ /** @typedef {import('estree').CallExpression} CallExpression */

*/
function getCallExpressionArgumentsText(sourceCode, callExpression) {
export default function getCallExpressionArgumentsText(sourceCode, callExpression) {
const {

@@ -21,8 +20,6 @@ openingParenthesisToken,

return sourceCode.text.slice(
openingParenthesisToken.range[1],
closingParenthesisToken.range[0],
);
const [, start] = sourceCode.getRange(openingParenthesisToken);
const [end] = sourceCode.getRange(closingParenthesisToken);
return sourceCode.text.slice(start, end);
}
module.exports = getCallExpressionArgumentsText;

@@ -1,8 +0,3 @@

'use strict';
import {isOpeningParenToken, isCommaToken} from '@eslint-community/eslint-utils';
const {
isOpeningParenToken,
isCommaToken,
} = require('@eslint-community/eslint-utils');
/** @typedef {import('estree').CallExpression} CallExpression */

@@ -22,3 +17,3 @@ /** @typedef {import('eslint').AST.Token} Token */

*/
function getCallExpressionTokens(sourceCode, callExpression) {
export default function getCallExpressionTokens(sourceCode, callExpression) {
const openingParenthesisToken = sourceCode.getTokenAfter(callExpression.callee, isOpeningParenToken);

@@ -37,3 +32,1 @@ const [

}
module.exports = getCallExpressionTokens;

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -12,12 +10,10 @@ @typedef {line: number, column: number} Position

*/
function getClassHeadLocation(node, sourceCode) {
const {loc, body} = node;
export default function getClassHeadLocation(node, sourceCode) {
const {body} = node;
const tokenBeforeBody = sourceCode.getTokenBefore(body);
const {start} = loc;
const {end} = tokenBeforeBody.loc;
const {start} = sourceCode.getLoc(node);
const {end} = sourceCode.getLoc(tokenBeforeBody);
return {start, end};
}
module.exports = getClassHeadLocation;

@@ -1,10 +0,9 @@

'use strict';
const path = require('node:path');
const packageJson = require('../../package.json');
import path from 'node:path';
import packageJson from '../../package.json' with {type: 'json'};
const repoUrl = 'https://github.com/sindresorhus/eslint-plugin-unicorn';
module.exports = function getDocumentationUrl(filename) {
export default function getDocumentationUrl(filename) {
const ruleName = path.basename(filename, '.js');
return `${repoUrl}/blob/v${packageJson.version}/docs/rules/${ruleName}.md`;
};
}

@@ -1,5 +0,3 @@

'use strict';
function getIndentString(node, sourceCode) {
const {line, column} = sourceCode.getLocFromIndex(node.range[0]);
export default function getIndentString(node, sourceCode) {
const {start: {line, column}} = sourceCode.getLoc(node);
const lines = sourceCode.getLines();

@@ -10,3 +8,1 @@ const before = lines[line - 1].slice(0, column);

}
module.exports = getIndentString;

@@ -1,4 +0,2 @@

'use strict';
function getPreviousNode(node, sourceCode) {
export default function getPreviousNode(node, sourceCode) {
const {parent} = node;

@@ -23,3 +21,1 @@ const visitorKeys = sourceCode.visitorKeys[parent.type] || Object.keys(parent);

}
module.exports = getPreviousNode;

@@ -1,9 +0,5 @@

'use strict';
import getScopes from './get-scopes.js';
const getScopes = require('./get-scopes.js');
const getReferences = scope => [...new Set(getScopes(scope).flatMap(({references}) => references))];
const getReferences = scope => [...new Set(
getScopes(scope).flatMap(({references}) => references),
)];
module.exports = getReferences;
export default getReferences;

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -14,2 +12,2 @@ Gather a list of all Scopes starting recursively from the input Scope.

module.exports = getScopes;
export default getScopes;

@@ -1,5 +0,3 @@

'use strict';
import {isColonToken} from '@eslint-community/eslint-utils';
const {isColonToken} = require('@eslint-community/eslint-utils');
/**

@@ -14,9 +12,6 @@ @typedef {line: number, column: number} Position

*/
function getSwitchCaseHeadLocation(node, sourceCode) {
export default function getSwitchCaseHeadLocation(node, sourceCode) {
const startToken = node.test || sourceCode.getFirstToken(node);
const colonToken = sourceCode.getTokenAfter(startToken, isColonToken);
return {start: node.loc.start, end: colonToken.loc.end};
return {start: sourceCode.getLoc(node).start, end: sourceCode.getLoc(colonToken).end};
}
module.exports = getSwitchCaseHeadLocation;

@@ -1,3 +0,1 @@

'use strict';
// Get identifiers of given variable

@@ -8,2 +6,3 @@ const getVariableIdentifiers = ({identifiers, references}) => [...new Set([

])];
module.exports = getVariableIdentifiers;
export default getVariableIdentifiers;

@@ -1,3 +0,2 @@

'use strict';
const {ReferenceTracker} = require('@eslint-community/eslint-utils');
import {ReferenceTracker} from '@eslint-community/eslint-utils';

@@ -15,3 +14,3 @@ const createTraceMap = (object, type) => {

class GlobalReferenceTracker {
export class GlobalReferenceTracker {
#traceMap = {};

@@ -70,5 +69,1 @@ #filter;

});
module.exports = {
GlobalReferenceTracker,
};

@@ -1,6 +0,4 @@

'use strict';
const isChainElement = node => node.type === 'MemberExpression' || node.type === 'CallExpression';
function hasOptionalChainElement(node) {
export default function hasOptionalChainElement(node) {
if (!isChainElement(node)) {

@@ -20,3 +18,1 @@ return false;

}
module.exports = hasOptionalChainElement;

@@ -1,3 +0,1 @@

'use strict';
const hasSameRange = (node1, node2) =>

@@ -8,2 +6,3 @@ node1

&& node1.range[1] === node2.range[1];
module.exports = hasSameRange;
export default hasSameRange;

@@ -1,4 +0,2 @@

'use strict';
const {
export {
isParenthesized,

@@ -9,49 +7,49 @@ getParenthesizedTimes,

getParenthesizedText,
} = require('./parentheses.js');
const {
} from './parentheses.js';
export {
isArrayPrototypeProperty,
isObjectPrototypeProperty,
} = require('./array-or-object-prototype-property.js');
const {isNodeMatches, isNodeMatchesNameOrPath} = require('./is-node-matches.js');
const {isBooleanNode, getBooleanAncestor} = require('./boolean.js');
} from './array-or-object-prototype-property.js';
module.exports = {
avoidCapture: require('./avoid-capture.js'),
escapeString: require('./escape-string.js'),
getBooleanAncestor,
getCallExpressionArgumentsText: require('./get-call-expression-arguments-text.js'),
getCallExpressionTokens: require('./get-call-expression-tokens.js'),
getParentheses,
getParenthesizedRange,
getParenthesizedText,
getParenthesizedTimes,
getReferences: require('./get-references.js'),
getScopes: require('./get-scopes.js'),
getVariableIdentifiers: require('./get-variable-identifiers.js'),
hasOptionalChainElement: require('./has-optional-chain-element.js'),
isArrayPrototypeProperty,
isBooleanNode,
isFunctionSelfUsedInside: require('./is-function-self-used-inside.js'),
isLeftHandSide: require('./is-left-hand-side.js'),
isLogicalExpression: require('./is-logical-expression.js'),
isMethodNamed: require('./is-method-named.js'),
export {
isNodeMatches,
isNodeMatchesNameOrPath,
isNodeValueNotDomNode: require('./is-node-value-not-dom-node.js'),
isNodeValueNotFunction: require('./is-node-value-not-function.js'),
isObjectPrototypeProperty,
isOnSameLine: require('./is-on-same-line.js'),
isParenthesized,
isSameIdentifier: require('./is-same-identifier.js'),
isSameReference: require('./is-same-reference.js'),
isShadowed: require('./is-shadowed.js'),
isValueNotUsable: require('./is-value-not-usable.js'),
needsSemicolon: require('./needs-semicolon.js'),
shouldAddParenthesesToMemberExpressionObject: require('./should-add-parentheses-to-member-expression-object.js'),
shouldAddParenthesesToCallExpressionCallee: require('./should-add-parentheses-to-call-expression-callee.js'),
shouldAddParenthesesToAwaitExpressionArgument: require('./should-add-parentheses-to-await-expression-argument.js'),
singular: require('./singular.js'),
toLocation: require('./to-location.js'),
getAncestor: require('./get-ancestor.js'),
};
} from './is-node-matches.js';
export {
isBooleanNode,
getBooleanAncestor,
} from './boolean.js';
export {default as cartesianProductSamples} from './cartesian-product-samples.js';
export {default as escapeString} from './escape-string.js';
export {default as getAvailableVariableName} from './get-available-variable-name.js';
export {default as getCallExpressionArgumentsText} from './get-call-expression-arguments-text.js';
export {default as getCallExpressionTokens} from './get-call-expression-tokens.js';
export {default as getIndentString} from './get-indent-string.js';
export {default as getReferences} from './get-references.js';
export {default as getScopes} from './get-scopes.js';
export {default as getVariableIdentifiers} from './get-variable-identifiers.js';
export {default as hasOptionalChainElement} from './has-optional-chain-element.js';
export {default as isFunctionSelfUsedInside} from './is-function-self-used-inside.js';
export {default as isLeftHandSide} from './is-left-hand-side.js';
export {default as isLogicalExpression} from './is-logical-expression.js';
export {default as isMethodNamed} from './is-method-named.js';
export {default as isNodeValueNotDomNode} from './is-node-value-not-dom-node.js';
export {default as isNodeValueNotFunction} from './is-node-value-not-function.js';
export {default as isOnSameLine} from './is-on-same-line.js';
export {default as isSameIdentifier} from './is-same-identifier.js';
export {default as isSameReference} from './is-same-reference.js';
export {default as isShadowed} from './is-shadowed.js';
export {default as isShorthandImportLocal} from './is-shorthand-import-local.js';
export {default as isShorthandPropertyValue} from './is-shorthand-property-value.js';
export {default as isValueNotUsable} from './is-value-not-usable.js';
export {default as needsSemicolon} from './needs-semicolon.js';
export {default as shouldAddParenthesesToAwaitExpressionArgument} from './should-add-parentheses-to-await-expression-argument.js';
export {default as shouldAddParenthesesToCallExpressionCallee} from './should-add-parentheses-to-call-expression-callee.js';
export {default as shouldAddParenthesesToConditionalExpressionChild} from './should-add-parentheses-to-conditional-expression-child.js';
export {default as shouldAddParenthesesToMemberExpressionObject} from './should-add-parentheses-to-member-expression-object.js';
export {default as singular} from './singular.js';
export {default as toLocation} from './to-location.js';
export {default as getAncestor} from './get-ancestor.js';

@@ -1,3 +0,2 @@

'use strict';
const {findVariable} = require('@eslint-community/eslint-utils');
import {findVariable} from '@eslint-community/eslint-utils';

@@ -16,3 +15,3 @@ const getReferences = (scope, nodeOrName) => {

*/
function isFunctionSelfUsedInside(functionNode, functionScope) {
export default function isFunctionSelfUsedInside(functionNode, functionScope) {
/* c8 ignore next 3 */

@@ -24,3 +23,2 @@ if (functionScope.block !== functionNode) {

const {type, id} = functionNode;
if (type === 'ArrowFunctionExpression') {

@@ -44,3 +42,1 @@ return false;

}
module.exports = isFunctionSelfUsedInside;

@@ -1,3 +0,1 @@

'use strict';
const isLeftHandSide = node =>

@@ -22,2 +20,2 @@ (

module.exports = isLeftHandSide;
export default isLeftHandSide;

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -16,2 +14,2 @@ Check if the given node is a true logical expression or not.

module.exports = isLogicalExpression;
export default isLogicalExpression;

@@ -1,3 +0,1 @@

'use strict';
const isMethodNamed = (node, name) =>

@@ -9,2 +7,2 @@ node.type === 'CallExpression'

module.exports = isMethodNamed;
export default isMethodNamed;

@@ -1,5 +0,3 @@

'use strict';
import {isOpeningParenToken, isClosingParenToken} from '@eslint-community/eslint-utils';
const {isOpeningParenToken, isClosingParenToken} = require('@eslint-community/eslint-utils');
/**

@@ -14,3 +12,3 @@ Determine if a constructor function is newed-up with parens.

*/
function isNewExpressionWithParentheses(node, sourceCode) {
export default function isNewExpressionWithParentheses(node, sourceCode) {
if (node.arguments.length > 0) {

@@ -24,5 +22,3 @@ return true;

&& isClosingParenToken(lastToken)
&& node.callee.range[1] < node.range[1];
&& sourceCode.getRange(node.callee)[1] < sourceCode.getRange(node)[1];
}
module.exports = isNewExpressionWithParentheses;

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -10,3 +8,3 @@ Check if node matches object name or key path.

*/
function isNodeMatchesNameOrPath(node, nameOrPath) {
export function isNodeMatchesNameOrPath(node, nameOrPath) {
const names = nameOrPath.trim().split('.');

@@ -47,9 +45,4 @@ for (let index = names.length - 1; index >= 0; index--) {

*/
function isNodeMatches(node, nameOrPaths) {
export function isNodeMatches(node, nameOrPaths) {
return nameOrPaths.some(nameOrPath => isNodeMatchesNameOrPath(node, nameOrPath));
}
module.exports = {
isNodeMatchesNameOrPath,
isNodeMatches,
};

@@ -1,3 +0,2 @@

'use strict';
const {isUndefined} = require('../ast/index.js');
import {isUndefined} from '../ast/index.js';

@@ -21,2 +20,2 @@ // AST Types:

module.exports = isNodeValueNotDomNode;
export default isNodeValueNotDomNode;

@@ -1,3 +0,2 @@

'use strict';
const {isUndefined, isCallExpression, isMethodCall} = require('../ast/index.js');
import {isUndefined, isCallExpression, isMethodCall} from '../ast/index.js';

@@ -41,2 +40,2 @@ // AST Types:

module.exports = isNodeValueNotFunction;
export default isNodeValueNotFunction;

@@ -1,4 +0,3 @@

'use strict';
const {getStaticValue} = require('@eslint-community/eslint-utils');
const {isNumberLiteral} = require('../ast/index.js');
import {getStaticValue} from '@eslint-community/eslint-utils';
import {isNumberLiteral} from '../ast/index.js';

@@ -13,2 +12,3 @@ const isStaticProperties = (node, object, properties) =>

&& properties.has(node.property.name);
const isFunctionCall = (node, functionName) => node.type === 'CallExpression'

@@ -117,3 +117,4 @@ && !node.optional

const mathOperators = new Set(['-', '*', '/', '%', '**', '<<', '>>', '|', '^', '&']);
function isNumber(node, scope) {
export default function isNumber(node, scope) {
if (

@@ -225,3 +226,1 @@ isNumberLiteral(node)

}
module.exports = isNumber;

@@ -1,3 +0,2 @@

'use strict';
module.exports = function isObjectMethod(node, object, method) {
export default function isObjectMethod(node, object, method) {
const {callee} = node;

@@ -11,2 +10,2 @@ return (

);
};
}

@@ -1,7 +0,4 @@

'use strict';
function isOnSameLine(nodeOrTokenA, nodeOrTokenB) {
export default function isOnSameLine(nodeOrTokenA, nodeOrTokenB) {
// eslint-disable-next-line internal/no-restricted-property-access -- Need fix
return nodeOrTokenA.loc.start.line === nodeOrTokenB.loc.start.line;
}
module.exports = isOnSameLine;

@@ -1,8 +0,5 @@

'use strict';
const isSameIdentifier = (nodeA, nodeB) =>
nodeA.type === 'Identifier'
const isSameIdentifier = (nodeA, nodeB) => nodeA.type === 'Identifier'
&& nodeB.type === 'Identifier'
&& nodeA.name === nodeB.name;
module.exports = isSameIdentifier;
export default isSameIdentifier;

@@ -1,3 +0,2 @@

'use strict';
const {getStaticValue} = require('@eslint-community/eslint-utils');
import {getStaticValue} from '@eslint-community/eslint-utils';

@@ -111,3 +110,3 @@ // Copied from https://github.com/eslint/eslint/blob/94ba68d76a6940f68ff82eea7332c6505f93df76/lib/rules/utils/ast-utils.js#L392

*/
function isSameReference(left, right) {
export default function isSameReference(left, right) {
if (left.type !== right.type) {

@@ -173,3 +172,1 @@ // Handle `a.b` and `a?.b` are samely.

}
module.exports = isSameReference;

@@ -1,9 +0,8 @@

'use strict';
/**
Finds the eslint-scope reference in the given scope.
/**
* Finds the eslint-scope reference in the given scope.
* @param {Object} scope The scope to search.
* @param {ASTNode} node The identifier node.
* @returns {Reference|undefined} Returns the found reference or null if none were found.
*/
@param {Object} scope The scope to search.
@param {ASTNode} node The identifier node.
@returns {Reference|undefined} Returns the found reference or null if none were found.
*/
function findReference(scope, node) {

@@ -19,8 +18,9 @@ const references = scope.references

/**
* Checks if the given identifier node is shadowed in the given scope.
* @param {Object} scope The current scope.
* @param {string} node The identifier node to check
* @returns {boolean} Whether or not the name is shadowed.
*/
function isShadowed(scope, node) {
Checks if the given identifier node is shadowed in the given scope.
@param {Object} scope The current scope.
@param {string} node The identifier node to check
@returns {boolean} Whether or not the name is shadowed.
*/
export default function isShadowed(scope, node) {
const reference = findReference(scope, node);

@@ -33,3 +33,1 @@

}
module.exports = isShadowed;

@@ -1,3 +0,2 @@

'use strict';
const hasSameRange = require('./has-same-range.js');
import hasSameRange from './has-same-range.js';

@@ -9,2 +8,2 @@ const isShorthandExportLocal = node => {

module.exports = isShorthandExportLocal;
export default isShorthandExportLocal;

@@ -1,3 +0,2 @@

'use strict';
const hasSameRange = require('./has-same-range.js');
import hasSameRange from './has-same-range.js';

@@ -9,2 +8,2 @@ const isShorthandImportLocal = node => {

module.exports = isShorthandImportLocal;
export default isShorthandImportLocal;

@@ -1,5 +0,3 @@

'use strict';
import isShorthandPropertyValue from './is-shorthand-property-value.js';
const isShorthandPropertyValue = require('./is-shorthand-property-value.js');
const isShorthandPropertyAssignmentPatternLeft = identifier =>

@@ -10,2 +8,2 @@ identifier.parent.type === 'AssignmentPattern'

module.exports = isShorthandPropertyAssignmentPatternLeft;
export default isShorthandPropertyAssignmentPatternLeft;

@@ -1,3 +0,1 @@

'use strict';
const isShorthandPropertyValue = identifier =>

@@ -8,2 +6,2 @@ identifier.parent.type === 'Property'

module.exports = isShorthandPropertyValue;
export default isShorthandPropertyValue;

@@ -1,6 +0,5 @@

'use strict';
import {isExpressionStatement} from '../ast/index.js';
const {isExpressionStatement} = require('../ast/index.js');
const isValueNotUsable = node => isExpressionStatement(node.parent);
const isValueNotUsable = node => isExpressionStatement(node.parent);
module.exports = isValueNotUsable;
export default isValueNotUsable;

@@ -1,31 +0,1 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// <stdin>
var stdin_exports = {};
__export(stdin_exports, {
camelCase: () => camelCase_default,
defaultsDeep: () => defaultsDeep_default,
kebabCase: () => kebabCase_default,
lowerFirst: () => lowerFirst_default,
snakeCase: () => snakeCase_default,
upperFirst: () => upperFirst_default
});
module.exports = __toCommonJS(stdin_exports);
// node_modules/lodash-es/_freeGlobal.js

@@ -41,4 +11,4 @@ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;

// node_modules/lodash-es/_Symbol.js
var Symbol2 = root_default.Symbol;
var Symbol_default = Symbol2;
var Symbol = root_default.Symbol;
var Symbol_default = Symbol;

@@ -228,3 +198,3 @@ // node_modules/lodash-es/_getRawTag.js

var objectCreate = Object.create;
var baseCreate = function() {
var baseCreate = /* @__PURE__ */ function() {
function object() {

@@ -494,3 +464,3 @@ }

var propertyIsEnumerable = objectProto6.propertyIsEnumerable;
var isArguments = baseIsArguments_default(function() {
var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
return arguments;

@@ -512,4 +482,4 @@ }()) ? baseIsArguments_default : function(value) {

var moduleExports = freeModule && freeModule.exports === freeExports;
var Buffer2 = moduleExports ? root_default.Buffer : void 0;
var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
var Buffer = moduleExports ? root_default.Buffer : void 0;
var nativeIsBuffer = Buffer ? Buffer.isBuffer : void 0;
var isBuffer = nativeIsBuffer || stubFalse_default;

@@ -1388,4 +1358,4 @@ var isBuffer_default = isBuffer;

var moduleExports3 = freeModule3 && freeModule3.exports === freeExports3;
var Buffer3 = moduleExports3 ? root_default.Buffer : void 0;
var allocUnsafe = Buffer3 ? Buffer3.allocUnsafe : void 0;
var Buffer2 = moduleExports3 ? root_default.Buffer : void 0;
var allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : void 0;
function cloneBuffer(buffer, isDeep) {

@@ -1402,4 +1372,4 @@ if (isDeep) {

// node_modules/lodash-es/_Uint8Array.js
var Uint8Array2 = root_default.Uint8Array;
var Uint8Array_default = Uint8Array2;
var Uint8Array = root_default.Uint8Array;
var Uint8Array_default = Uint8Array;

@@ -1583,2 +1553,10 @@ // node_modules/lodash-es/_cloneArrayBuffer.js

var snakeCase_default = snakeCase;
export {
camelCase_default as camelCase,
defaultsDeep_default as defaultsDeep,
kebabCase_default as kebabCase,
lowerFirst_default as lowerFirst,
snakeCase_default as snakeCase,
upperFirst_default as upperFirst
};
/*! Bundled license information:

@@ -1585,0 +1563,0 @@

@@ -1,3 +0,1 @@

'use strict';
// https://github.com/eslint/espree/blob/6b7d0b8100537dcd5c84a7fb17bbe28edcabe05d/lib/token-translator.js#L20

@@ -32,4 +30,3 @@ const tokenTypesNeedsSemicolon = new Set([

*/
function needsSemicolon(tokenBefore, sourceCode, code) {
export default function needsSemicolon(tokenBefore, sourceCode, code) {
if (

@@ -46,3 +43,4 @@ code === ''

const {type, value, range} = tokenBefore;
const {type, value} = tokenBefore;
const range = sourceCode.getRange(tokenBefore);
const lastBlockNode = sourceCode.getNodeByRangeIndex(range[0]);

@@ -115,3 +113,1 @@ if (type === 'Punctuator') {

}
module.exports = needsSemicolon;

@@ -1,15 +0,16 @@

'use strict';
import {isNumberLiteral, isBigIntLiteral} from '../ast/index.js';
const {isNumberLiteral, isBigIntLiteral} = require('../ast/index.js');
// Determine whether this node is a decimal integer literal.
// Copied from https://github.com/eslint/eslint/blob/cc4871369645c3409dc56ded7a555af8a9f63d51/lib/rules/utils/ast-utils.js#L1237
const DECIMAL_INTEGER_PATTERN = /^(?:0|0[0-7]*[89]\d*|[1-9](?:_?\d)*)$/u;
const isDecimalInteger = text => DECIMAL_INTEGER_PATTERN.test(text);
const isDecimalIntegerNode = node => isNumberLiteral(node) && isDecimalInteger(node.raw);
const isNumeric = node => isNumberLiteral(node) || isBigIntLiteral(node);
const isLegacyOctal = node => isNumberLiteral(node) && /^0\d+$/.test(node.raw);
export const isDecimalInteger = text => DECIMAL_INTEGER_PATTERN.test(text);
function getPrefix(text) {
export const isDecimalIntegerNode = node => isNumberLiteral(node) && isDecimalInteger(node.raw);
export const isNumeric = node => isNumberLiteral(node) || isBigIntLiteral(node);
export const isLegacyOctal = node => isNumberLiteral(node) && /^0\d+$/.test(node.raw);
export function getPrefix(text) {
let prefix = '';

@@ -26,3 +27,3 @@ let data = text;

function parseNumber(text) {
export function parseNumber(text) {
const {

@@ -43,3 +44,3 @@ number,

function parseFloatNumber(text) {
export function parseFloatNumber(text) {
const parts = text.split('.');

@@ -51,11 +52,1 @@ const [integer, fractional = ''] = parts;

}
module.exports = {
isDecimalIntegerNode,
isDecimalInteger,
isNumeric,
isLegacyOctal,
getPrefix,
parseNumber,
parseFloatNumber,
};

@@ -1,3 +0,2 @@

'use strict';
const {isParenthesized, isOpeningParenToken, isClosingParenToken} = require('@eslint-community/eslint-utils');
import {isParenthesized, isOpeningParenToken, isClosingParenToken} from '@eslint-community/eslint-utils';

@@ -11,3 +10,3 @@ /*

*/
function getParenthesizedTimes(node, sourceCode) {
export function getParenthesizedTimes(node, sourceCode) {
let times = 0;

@@ -29,3 +28,3 @@

*/
function getParentheses(node, sourceCode) {
export function getParentheses(node, sourceCode) {
const count = getParenthesizedTimes(node, sourceCode);

@@ -50,3 +49,3 @@

*/
function getParenthesizedRange(node, sourceCode) {
export function getParenthesizedRange(node, sourceCode) {
const parentheses = getParentheses(node, sourceCode);

@@ -65,3 +64,3 @@ const [start] = (parentheses[0] || node).range;

*/
function getParenthesizedText(node, sourceCode) {
export function getParenthesizedText(node, sourceCode) {
const [start, end] = getParenthesizedRange(node, sourceCode);

@@ -71,8 +70,2 @@ return sourceCode.text.slice(start, end);

module.exports = {
isParenthesized,
getParenthesizedTimes,
getParentheses,
getParenthesizedRange,
getParenthesizedText,
};
export {isParenthesized} from '@eslint-community/eslint-utils';

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -10,3 +8,3 @@ Finds a variable named `name` in the scope `scope` (or it's parents).

*/
module.exports = function resolveVariableName(name, scope) {
export default function resolveVariableName(name, scope) {
while (scope) {

@@ -21,2 +19,2 @@ const variable = scope.set.get(name);

}
};
}

@@ -1,9 +0,11 @@

'use strict';
const path = require('node:path');
const fs = require('node:fs');
const getDocumentationUrl = require('./get-documentation-url.js');
import getDocumentationUrl from './get-documentation-url.js';
const isIterable = object => typeof object?.[Symbol.iterator] === 'function';
class FixAbortError extends Error {}
class FixAbortError extends Error {
constructor() {
super();
this.name = 'FixAbortError';
}
}
const fixOptions = {

@@ -128,3 +130,3 @@ abort() {

function checkVueTemplate(create, options) {
export function checkVueTemplate(create, options) {
const {

@@ -158,5 +160,3 @@ visitScriptBlock,

/** @returns {import('eslint').Rule.RuleModule} */
function loadRule(ruleId) {
const rule = require(`../${ruleId}`);
export function createRule(rule, ruleId) {
return {

@@ -176,18 +176,1 @@ meta: {

}
function loadRules() {
return Object.fromEntries(
fs.readdirSync(path.join(__dirname, '..'), {withFileTypes: true})
.filter(file => file.isFile())
.map(file => {
const ruleId = path.basename(file.name, '.js');
return [ruleId, loadRule(ruleId)];
}),
);
}
module.exports = {
loadRule,
loadRules,
checkVueTemplate,
};

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -9,3 +7,3 @@ Check if parentheses should be added to a `node` when it's used as `argument` of `AwaitExpression`.

*/
function shouldAddParenthesesToAwaitExpressionArgument(node) {
export default function shouldAddParenthesesToAwaitExpressionArgument(node) {
return (

@@ -21,3 +19,1 @@ node.type === 'SequenceExpression'

}
module.exports = shouldAddParenthesesToAwaitExpressionArgument;

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -9,3 +7,3 @@ Check if parentheses should be added to a `node` when it's used as `callee` of `CallExpression`.

*/
function shouldAddParenthesesToCallExpressionCallee(node) {
export default function shouldAddParenthesesToCallExpressionCallee(node) {
return node.type === 'SequenceExpression'

@@ -22,3 +20,1 @@ || node.type === 'YieldExpression'

}
module.exports = shouldAddParenthesesToCallExpressionCallee;

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -9,3 +7,3 @@ Check if parentheses should be added to a `node` when it's used as child of `ConditionalExpression`.

*/
function shouldAddParenthesesToConditionalExpressionChild(node) {
export default function shouldAddParenthesesToConditionalExpressionChild(node) {
return node.type === 'AwaitExpression'

@@ -17,3 +15,1 @@ // Lower precedence, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table

}
module.exports = shouldAddParenthesesToConditionalExpressionChild;

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -10,3 +8,3 @@ Check if parentheses should to be added to a `node` when it's used as an `expression` of `ExpressionStatement`.

*/
function shouldAddParenthesesToExpressionStatementExpression(node) {
export default function shouldAddParenthesesToExpressionStatementExpression(node) {
switch (node.type) {

@@ -26,3 +24,1 @@ case 'ObjectExpression': {

}
module.exports = shouldAddParenthesesToExpressionStatementExpression;

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -9,3 +7,3 @@ Check if parentheses should be added to a `node` when it's used as child of `LogicalExpression`.

*/
function shouldAddParenthesesToLogicalExpressionChild(node, {operator, property}) {
export default function shouldAddParenthesesToLogicalExpressionChild(node, {operator, property}) {
// We are not using this, but we can improve this function with it

@@ -47,3 +45,1 @@ /* c8 ignore next 3 */

}
module.exports = shouldAddParenthesesToLogicalExpressionChild;

@@ -1,6 +0,4 @@

'use strict';
import isNewExpressionWithParentheses from './is-new-expression-with-parentheses.js';
import {isDecimalIntegerNode} from './numeric.js';
const isNewExpressionWithParentheses = require('./is-new-expression-with-parentheses.js');
const {isDecimalIntegerNode} = require('./numeric.js');
/**

@@ -13,3 +11,3 @@ Check if parentheses should to be added to a `node` when it's used as an `object` of `MemberExpression`.

*/
function shouldAddParenthesesToMemberExpressionObject(node, sourceCode) {
export default function shouldAddParenthesesToMemberExpressionObject(node, sourceCode) {
switch (node.type) {

@@ -47,3 +45,1 @@ // This is not a full list. Some other nodes like `FunctionDeclaration` don't need parentheses,

}
module.exports = shouldAddParenthesesToMemberExpressionObject;

@@ -1,3 +0,1 @@

'use strict';
// Copied from https://github.com/eslint/eslint/blob/aa87329d919f569404ca573b439934552006572f/lib/rules/no-extra-parens.js#L448

@@ -28,6 +26,4 @@ /**

*/
function shouldAddParenthesesToNewExpressionCallee(node) {
export default function shouldAddParenthesesToNewExpressionCallee(node) {
return node.type === 'MemberExpression' && doesMemberExpressionContainCallExpression(node);
}
module.exports = shouldAddParenthesesToNewExpressionCallee;

@@ -1,5 +0,3 @@

'use strict';
import pluralize_ from 'pluralize';
const {singular: pluralizeSingular} = require('pluralize');
/**

@@ -12,3 +10,3 @@ Singularizes a word/name, i.e. `items` to `item`.

const singular = original => {
const singularized = pluralizeSingular(original);
const singularized = pluralize_.singular(original);
if (singularized !== original) {

@@ -19,2 +17,2 @@ return singularized;

module.exports = singular;
export default singular;

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -13,3 +11,3 @@ Get location info for the given node or range.

function toLocation(nodeOrRange, sourceCode, startOffset = 0, endOffset = 0) {
const [start, end] = Array.isArray(nodeOrRange) ? nodeOrRange : nodeOrRange.range;
const [start, end] = Array.isArray(nodeOrRange) ? nodeOrRange : sourceCode.getRange(nodeOrRange);

@@ -22,2 +20,2 @@ return {

module.exports = toLocation;
export default toLocation;