eslint-plugin-unicorn 45.0.2 β†’ 46.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-unicorn",
3
- "version": "45.0.2",
3
+ "version": "46.0.0",
4
4
  "description": "More than 100 powerful ESLint rules",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/eslint-plugin-unicorn",
@@ -16,7 +16,7 @@
16
16
  "scripts": {
17
17
  "create-rule": "node ./scripts/create-rule.mjs && npm run fix:eslint-docs",
18
18
  "fix": "run-p --continue-on-error fix:*",
19
- "fix:eslint-docs": "eslint-doc-generator --ignore-deprecated-rules --ignore-config all --rule-doc-title-format desc --url-configs \"https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs\"",
19
+ "fix:eslint-docs": "eslint-doc-generator",
20
20
  "fix:js": "npm run lint:js -- --fix",
21
21
  "fix:md": "npm run lint:md -- --fix",
22
22
  "integration": "node ./test/integration/test.mjs",
@@ -79,7 +79,7 @@
79
79
  "eslint-plugin-eslint-plugin": "^5.0.6",
80
80
  "eslint-plugin-internal-rules": "file:./scripts/internal-rules/",
81
81
  "eslint-remote-tester": "^3.0.0",
82
- "eslint-remote-tester-repositories": "^0.0.7",
82
+ "eslint-remote-tester-repositories": "^1.0.0",
83
83
  "execa": "^6.1.0",
84
84
  "listr": "^0.14.3",
85
85
  "lodash-es": "^4.17.21",
@@ -109,6 +109,9 @@
109
109
  ]
110
110
  },
111
111
  "xo": {
112
+ "extends": [
113
+ "plugin:internal-rules/all"
114
+ ],
112
115
  "ignores": [
113
116
  ".cache-eslint-remote-tester",
114
117
  "eslint-remote-tester-results",
@@ -160,14 +163,6 @@
160
163
  "eslint-plugin/require-meta-has-suggestions": "off",
161
164
  "eslint-plugin/require-meta-schema": "off"
162
165
  }
163
- },
164
- {
165
- "files": [
166
- "rules/**/*.js"
167
- ],
168
- "extends": [
169
- "plugin:internal-rules/all"
170
- ]
171
166
  }
172
167
  ]
173
168
  },
package/readme.md CHANGED
@@ -49,122 +49,121 @@ If you don't use the preset, ensure you use the same `env` and `parserOptions` c
49
49
  <!-- begin auto-generated rules list -->
50
50
 
51
51
  πŸ’Ό [Configurations](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs) enabled in.\
52
- 🚫 [Configurations](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs) disabled in.\
53
52
  βœ… Set in the `recommended` [configuration](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs).\
54
53
  πŸ”§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
55
54
  πŸ’‘ Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
56
55
 
57
- | NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  | Description | πŸ’Ό | 🚫 | πŸ”§ | πŸ’‘ |
58
- | :----------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :- | :- | :- | :- |
59
- | [better-regex](docs/rules/better-regex.md) | Improve regexes by making them shorter, consistent, and safer. | βœ… | | πŸ”§ | |
60
- | [catch-error-name](docs/rules/catch-error-name.md) | Enforce a specific parameter name in catch clauses. | βœ… | | πŸ”§ | |
61
- | [consistent-destructuring](docs/rules/consistent-destructuring.md) | Use destructured variables over properties. | βœ… | | πŸ”§ | πŸ’‘ |
62
- | [consistent-function-scoping](docs/rules/consistent-function-scoping.md) | Move function definitions to the highest possible scope. | βœ… | | | |
63
- | [custom-error-definition](docs/rules/custom-error-definition.md) | Enforce correct `Error` subclassing. | | βœ… | πŸ”§ | |
64
- | [empty-brace-spaces](docs/rules/empty-brace-spaces.md) | Enforce no spaces between braces. | βœ… | | πŸ”§ | |
65
- | [error-message](docs/rules/error-message.md) | Enforce passing a `message` value when creating a built-in error. | βœ… | | | |
66
- | [escape-case](docs/rules/escape-case.md) | Require escape sequences to use uppercase values. | βœ… | | πŸ”§ | |
67
- | [expiring-todo-comments](docs/rules/expiring-todo-comments.md) | Add expiration conditions to TODO comments. | βœ… | | | |
68
- | [explicit-length-check](docs/rules/explicit-length-check.md) | Enforce explicitly comparing the `length` or `size` property of a value. | βœ… | | πŸ”§ | πŸ’‘ |
69
- | [filename-case](docs/rules/filename-case.md) | Enforce a case style for filenames. | βœ… | | | |
70
- | [import-style](docs/rules/import-style.md) | Enforce specific import styles per module. | βœ… | | | |
71
- | [new-for-builtins](docs/rules/new-for-builtins.md) | Enforce the use of `new` for all builtins, except `String`, `Number`, `Boolean`, `Symbol` and `BigInt`. | βœ… | | πŸ”§ | |
72
- | [no-abusive-eslint-disable](docs/rules/no-abusive-eslint-disable.md) | Enforce specifying rules to disable in `eslint-disable` comments. | βœ… | | | |
73
- | [no-array-callback-reference](docs/rules/no-array-callback-reference.md) | Prevent passing a function reference directly to iterator methods. | βœ… | | | πŸ’‘ |
74
- | [no-array-for-each](docs/rules/no-array-for-each.md) | Prefer `for…of` over the `forEach` method. | βœ… | | πŸ”§ | πŸ’‘ |
75
- | [no-array-method-this-argument](docs/rules/no-array-method-this-argument.md) | Disallow using the `this` argument in array methods. | βœ… | | πŸ”§ | πŸ’‘ |
76
- | [no-array-push-push](docs/rules/no-array-push-push.md) | Enforce combining multiple `Array#push()` into one call. | βœ… | | πŸ”§ | πŸ’‘ |
77
- | [no-array-reduce](docs/rules/no-array-reduce.md) | Disallow `Array#reduce()` and `Array#reduceRight()`. | βœ… | | | |
78
- | [no-await-expression-member](docs/rules/no-await-expression-member.md) | Disallow member access from await expression. | βœ… | | πŸ”§ | |
79
- | [no-console-spaces](docs/rules/no-console-spaces.md) | Do not use leading/trailing space between `console.log` parameters. | βœ… | | πŸ”§ | |
80
- | [no-document-cookie](docs/rules/no-document-cookie.md) | Do not use `document.cookie` directly. | βœ… | | | |
81
- | [no-empty-file](docs/rules/no-empty-file.md) | Disallow empty files. | βœ… | | | |
82
- | [no-for-loop](docs/rules/no-for-loop.md) | Do not use a `for` loop that can be replaced with a `for-of` loop. | βœ… | | πŸ”§ | |
83
- | [no-hex-escape](docs/rules/no-hex-escape.md) | Enforce the use of Unicode escapes instead of hexadecimal escapes. | βœ… | | πŸ”§ | |
84
- | [no-instanceof-array](docs/rules/no-instanceof-array.md) | Require `Array.isArray()` instead of `instanceof Array`. | βœ… | | πŸ”§ | |
85
- | [no-invalid-remove-event-listener](docs/rules/no-invalid-remove-event-listener.md) | Prevent calling `EventTarget#removeEventListener()` with the result of an expression. | βœ… | | | |
86
- | [no-keyword-prefix](docs/rules/no-keyword-prefix.md) | Disallow identifiers starting with `new` or `class`. | | βœ… | | |
87
- | [no-lonely-if](docs/rules/no-lonely-if.md) | Disallow `if` statements as the only statement in `if` blocks without `else`. | βœ… | | πŸ”§ | |
88
- | [no-negated-condition](docs/rules/no-negated-condition.md) | Disallow negated conditions. | βœ… | | πŸ”§ | |
89
- | [no-nested-ternary](docs/rules/no-nested-ternary.md) | Disallow nested ternary expressions. | βœ… | | πŸ”§ | |
90
- | [no-new-array](docs/rules/no-new-array.md) | Disallow `new Array()`. | βœ… | | πŸ”§ | πŸ’‘ |
91
- | [no-new-buffer](docs/rules/no-new-buffer.md) | Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`. | βœ… | | πŸ”§ | πŸ’‘ |
92
- | [no-null](docs/rules/no-null.md) | Disallow the use of the `null` literal. | βœ… | | πŸ”§ | πŸ’‘ |
93
- | [no-object-as-default-parameter](docs/rules/no-object-as-default-parameter.md) | Disallow the use of objects as default parameters. | βœ… | | | |
94
- | [no-process-exit](docs/rules/no-process-exit.md) | Disallow `process.exit()`. | βœ… | | | |
95
- | [no-static-only-class](docs/rules/no-static-only-class.md) | Disallow classes that only have static members. | βœ… | | πŸ”§ | |
96
- | [no-thenable](docs/rules/no-thenable.md) | Disallow `then` property. | βœ… | | | |
97
- | [no-this-assignment](docs/rules/no-this-assignment.md) | Disallow assigning `this` to a variable. | βœ… | | | |
98
- | [no-typeof-undefined](docs/rules/no-typeof-undefined.md) | Disallow comparing `undefined` using `typeof`. | βœ… | | πŸ”§ | πŸ’‘ |
99
- | [no-unnecessary-await](docs/rules/no-unnecessary-await.md) | Disallow awaiting non-promise values. | βœ… | | πŸ”§ | |
100
- | [no-unreadable-array-destructuring](docs/rules/no-unreadable-array-destructuring.md) | Disallow unreadable array destructuring. | βœ… | | πŸ”§ | |
101
- | [no-unreadable-iife](docs/rules/no-unreadable-iife.md) | Disallow unreadable IIFEs. | βœ… | | | |
102
- | [no-unsafe-regex](docs/rules/no-unsafe-regex.md) | Disallow unsafe regular expressions. | | βœ… | | |
103
- | [no-unused-properties](docs/rules/no-unused-properties.md) | Disallow unused object properties. | | βœ… | | |
104
- | [no-useless-fallback-in-spread](docs/rules/no-useless-fallback-in-spread.md) | Disallow useless fallback when spreading in object literals. | βœ… | | πŸ”§ | |
105
- | [no-useless-length-check](docs/rules/no-useless-length-check.md) | Disallow useless array length check. | βœ… | | πŸ”§ | |
106
- | [no-useless-promise-resolve-reject](docs/rules/no-useless-promise-resolve-reject.md) | Disallow returning/yielding `Promise.resolve/reject()` in async functions or promise callbacks | βœ… | | πŸ”§ | |
107
- | [no-useless-spread](docs/rules/no-useless-spread.md) | Disallow unnecessary spread. | βœ… | | πŸ”§ | |
108
- | [no-useless-switch-case](docs/rules/no-useless-switch-case.md) | Disallow useless case in switch statements. | βœ… | | | πŸ’‘ |
109
- | [no-useless-undefined](docs/rules/no-useless-undefined.md) | Disallow useless `undefined`. | βœ… | | πŸ”§ | |
110
- | [no-zero-fractions](docs/rules/no-zero-fractions.md) | Disallow number literals with zero fractions or dangling dots. | βœ… | | πŸ”§ | |
111
- | [number-literal-case](docs/rules/number-literal-case.md) | Enforce proper case for numeric literals. | βœ… | | πŸ”§ | |
112
- | [numeric-separators-style](docs/rules/numeric-separators-style.md) | Enforce the style of numeric separators by correctly grouping digits. | βœ… | | πŸ”§ | |
113
- | [prefer-add-event-listener](docs/rules/prefer-add-event-listener.md) | Prefer `.addEventListener()` and `.removeEventListener()` over `on`-functions. | βœ… | | πŸ”§ | |
114
- | [prefer-array-find](docs/rules/prefer-array-find.md) | Prefer `.find(…)` and `.findLast(…)` over the first or last element from `.filter(…)`. | βœ… | | πŸ”§ | πŸ’‘ |
115
- | [prefer-array-flat](docs/rules/prefer-array-flat.md) | Prefer `Array#flat()` over legacy techniques to flatten arrays. | βœ… | | πŸ”§ | |
116
- | [prefer-array-flat-map](docs/rules/prefer-array-flat-map.md) | Prefer `.flatMap(…)` over `.map(…).flat()`. | βœ… | | πŸ”§ | |
117
- | [prefer-array-index-of](docs/rules/prefer-array-index-of.md) | Prefer `Array#{indexOf,lastIndexOf}()` over `Array#{findIndex,findLastIndex}()` when looking for the index of an item. | βœ… | | πŸ”§ | πŸ’‘ |
118
- | [prefer-array-some](docs/rules/prefer-array-some.md) | Prefer `.some(…)` over `.filter(…).length` check and `.{find,findLast}(…)`. | βœ… | | πŸ”§ | πŸ’‘ |
119
- | [prefer-at](docs/rules/prefer-at.md) | Prefer `.at()` method for index access and `String#charAt()`. | | βœ… | πŸ”§ | πŸ’‘ |
120
- | [prefer-code-point](docs/rules/prefer-code-point.md) | Prefer `String#codePointAt(…)` over `String#charCodeAt(…)` and `String.fromCodePoint(…)` over `String.fromCharCode(…)`. | βœ… | | | πŸ’‘ |
121
- | [prefer-date-now](docs/rules/prefer-date-now.md) | Prefer `Date.now()` to get the number of milliseconds since the Unix Epoch. | βœ… | | πŸ”§ | |
122
- | [prefer-default-parameters](docs/rules/prefer-default-parameters.md) | Prefer default parameters over reassignment. | βœ… | | πŸ”§ | πŸ’‘ |
123
- | [prefer-dom-node-append](docs/rules/prefer-dom-node-append.md) | Prefer `Node#append()` over `Node#appendChild()`. | βœ… | | πŸ”§ | |
124
- | [prefer-dom-node-dataset](docs/rules/prefer-dom-node-dataset.md) | Prefer using `.dataset` on DOM elements over calling attribute methods. | βœ… | | πŸ”§ | |
125
- | [prefer-dom-node-remove](docs/rules/prefer-dom-node-remove.md) | Prefer `childNode.remove()` over `parentNode.removeChild(childNode)`. | βœ… | | πŸ”§ | πŸ’‘ |
126
- | [prefer-dom-node-text-content](docs/rules/prefer-dom-node-text-content.md) | Prefer `.textContent` over `.innerText`. | βœ… | | | πŸ’‘ |
127
- | [prefer-event-target](docs/rules/prefer-event-target.md) | Prefer `EventTarget` over `EventEmitter`. | | βœ… | | |
128
- | [prefer-export-from](docs/rules/prefer-export-from.md) | Prefer `export…from` when re-exporting. | βœ… | | πŸ”§ | πŸ’‘ |
129
- | [prefer-includes](docs/rules/prefer-includes.md) | Prefer `.includes()` over `.indexOf()` and `Array#some()` when checking for existence or non-existence. | βœ… | | πŸ”§ | πŸ’‘ |
130
- | [prefer-json-parse-buffer](docs/rules/prefer-json-parse-buffer.md) | Prefer reading a JSON file as a buffer. | | βœ… | πŸ”§ | |
131
- | [prefer-keyboard-event-key](docs/rules/prefer-keyboard-event-key.md) | Prefer `KeyboardEvent#key` over `KeyboardEvent#keyCode`. | βœ… | | πŸ”§ | |
132
- | [prefer-logical-operator-over-ternary](docs/rules/prefer-logical-operator-over-ternary.md) | Prefer using a logical operator over a ternary. | βœ… | | | πŸ’‘ |
133
- | [prefer-math-trunc](docs/rules/prefer-math-trunc.md) | Enforce the use of `Math.trunc` instead of bitwise operators. | βœ… | | πŸ”§ | πŸ’‘ |
134
- | [prefer-modern-dom-apis](docs/rules/prefer-modern-dom-apis.md) | Prefer `.before()` over `.insertBefore()`, `.replaceWith()` over `.replaceChild()`, prefer one of `.before()`, `.after()`, `.append()` or `.prepend()` over `insertAdjacentText()` and `insertAdjacentElement()`. | βœ… | | πŸ”§ | |
135
- | [prefer-modern-math-apis](docs/rules/prefer-modern-math-apis.md) | Prefer modern `Math` APIs over legacy patterns. | βœ… | | πŸ”§ | |
136
- | [prefer-module](docs/rules/prefer-module.md) | Prefer JavaScript modules (ESM) over CommonJS. | βœ… | | πŸ”§ | πŸ’‘ |
137
- | [prefer-native-coercion-functions](docs/rules/prefer-native-coercion-functions.md) | Prefer using `String`, `Number`, `BigInt`, `Boolean`, and `Symbol` directly. | βœ… | | πŸ”§ | |
138
- | [prefer-negative-index](docs/rules/prefer-negative-index.md) | Prefer negative index over `.length - index` for `{String,Array,TypedArray}#{slice,at}()` and `Array#splice()`. | βœ… | | πŸ”§ | |
139
- | [prefer-node-protocol](docs/rules/prefer-node-protocol.md) | Prefer using the `node:` protocol when importing Node.js builtin modules. | βœ… | | πŸ”§ | |
140
- | [prefer-number-properties](docs/rules/prefer-number-properties.md) | Prefer `Number` static properties over global ones. | βœ… | | πŸ”§ | πŸ’‘ |
141
- | [prefer-object-from-entries](docs/rules/prefer-object-from-entries.md) | Prefer using `Object.fromEntries(…)` to transform a list of key-value pairs into an object. | βœ… | | πŸ”§ | |
142
- | [prefer-optional-catch-binding](docs/rules/prefer-optional-catch-binding.md) | Prefer omitting the `catch` binding parameter. | βœ… | | πŸ”§ | |
143
- | [prefer-prototype-methods](docs/rules/prefer-prototype-methods.md) | Prefer borrowing methods from the prototype instead of the instance. | βœ… | | πŸ”§ | |
144
- | [prefer-query-selector](docs/rules/prefer-query-selector.md) | Prefer `.querySelector()` over `.getElementById()`, `.querySelectorAll()` over `.getElementsByClassName()` and `.getElementsByTagName()`. | βœ… | | πŸ”§ | |
145
- | [prefer-reflect-apply](docs/rules/prefer-reflect-apply.md) | Prefer `Reflect.apply()` over `Function#apply()`. | βœ… | | πŸ”§ | |
146
- | [prefer-regexp-test](docs/rules/prefer-regexp-test.md) | Prefer `RegExp#test()` over `String#match()` and `RegExp#exec()`. | βœ… | | πŸ”§ | πŸ’‘ |
147
- | [prefer-set-has](docs/rules/prefer-set-has.md) | Prefer `Set#has()` over `Array#includes()` when checking for existence or non-existence. | βœ… | | πŸ”§ | πŸ’‘ |
148
- | [prefer-set-size](docs/rules/prefer-set-size.md) | Prefer using `Set#size` instead of `Array#length`. | βœ… | | πŸ”§ | |
149
- | [prefer-spread](docs/rules/prefer-spread.md) | Prefer the spread operator over `Array.from(…)`, `Array#concat(…)`, `Array#slice()` and `String#split('')`. | βœ… | | πŸ”§ | πŸ’‘ |
150
- | [prefer-string-replace-all](docs/rules/prefer-string-replace-all.md) | Prefer `String#replaceAll()` over regex searches with the global flag. | | βœ… | πŸ”§ | |
151
- | [prefer-string-slice](docs/rules/prefer-string-slice.md) | Prefer `String#slice()` over `String#substr()` and `String#substring()`. | βœ… | | πŸ”§ | |
152
- | [prefer-string-starts-ends-with](docs/rules/prefer-string-starts-ends-with.md) | Prefer `String#startsWith()` & `String#endsWith()` over `RegExp#test()`. | βœ… | | πŸ”§ | πŸ’‘ |
153
- | [prefer-string-trim-start-end](docs/rules/prefer-string-trim-start-end.md) | Prefer `String#trimStart()` / `String#trimEnd()` over `String#trimLeft()` / `String#trimRight()`. | βœ… | | πŸ”§ | |
154
- | [prefer-switch](docs/rules/prefer-switch.md) | Prefer `switch` over multiple `else-if`. | βœ… | | πŸ”§ | |
155
- | [prefer-ternary](docs/rules/prefer-ternary.md) | Prefer ternary expressions over simple `if-else` statements. | βœ… | | πŸ”§ | |
156
- | [prefer-top-level-await](docs/rules/prefer-top-level-await.md) | Prefer top-level await over top-level promises and async function calls. | βœ… | | | πŸ’‘ |
157
- | [prefer-type-error](docs/rules/prefer-type-error.md) | Enforce throwing `TypeError` in type checking conditions. | βœ… | | πŸ”§ | |
158
- | [prevent-abbreviations](docs/rules/prevent-abbreviations.md) | Prevent abbreviations. | βœ… | | πŸ”§ | |
159
- | [relative-url-style](docs/rules/relative-url-style.md) | Enforce consistent relative URL style. | βœ… | | πŸ”§ | πŸ’‘ |
160
- | [require-array-join-separator](docs/rules/require-array-join-separator.md) | Enforce using the separator argument with `Array#join()`. | βœ… | | πŸ”§ | |
161
- | [require-number-to-fixed-digits-argument](docs/rules/require-number-to-fixed-digits-argument.md) | Enforce using the digits argument with `Number#toFixed()`. | βœ… | | πŸ”§ | |
162
- | [require-post-message-target-origin](docs/rules/require-post-message-target-origin.md) | Enforce using the `targetOrigin` argument with `window.postMessage()`. | | βœ… | | πŸ’‘ |
163
- | [string-content](docs/rules/string-content.md) | Enforce better string content. | | βœ… | πŸ”§ | πŸ’‘ |
164
- | [switch-case-braces](docs/rules/switch-case-braces.md) | Enforce consistent brace style for `case` clauses. | βœ… | | πŸ”§ | |
165
- | [template-indent](docs/rules/template-indent.md) | Fix whitespace-insensitive template indentation. | βœ… | | πŸ”§ | |
166
- | [text-encoding-identifier-case](docs/rules/text-encoding-identifier-case.md) | Enforce consistent case for text encoding identifiers. | βœ… | | πŸ”§ | πŸ’‘ |
167
- | [throw-new-error](docs/rules/throw-new-error.md) | Require `new` when throwing an error. | βœ… | | πŸ”§ | |
56
+ | NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  | Description | πŸ’Ό | πŸ”§ | πŸ’‘ |
57
+ | :----------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :- | :- | :- |
58
+ | [better-regex](docs/rules/better-regex.md) | Improve regexes by making them shorter, consistent, and safer. | βœ… | πŸ”§ | |
59
+ | [catch-error-name](docs/rules/catch-error-name.md) | Enforce a specific parameter name in catch clauses. | βœ… | πŸ”§ | |
60
+ | [consistent-destructuring](docs/rules/consistent-destructuring.md) | Use destructured variables over properties. | βœ… | πŸ”§ | πŸ’‘ |
61
+ | [consistent-function-scoping](docs/rules/consistent-function-scoping.md) | Move function definitions to the highest possible scope. | βœ… | | |
62
+ | [custom-error-definition](docs/rules/custom-error-definition.md) | Enforce correct `Error` subclassing. | | πŸ”§ | |
63
+ | [empty-brace-spaces](docs/rules/empty-brace-spaces.md) | Enforce no spaces between braces. | βœ… | πŸ”§ | |
64
+ | [error-message](docs/rules/error-message.md) | Enforce passing a `message` value when creating a built-in error. | βœ… | | |
65
+ | [escape-case](docs/rules/escape-case.md) | Require escape sequences to use uppercase values. | βœ… | πŸ”§ | |
66
+ | [expiring-todo-comments](docs/rules/expiring-todo-comments.md) | Add expiration conditions to TODO comments. | βœ… | | |
67
+ | [explicit-length-check](docs/rules/explicit-length-check.md) | Enforce explicitly comparing the `length` or `size` property of a value. | βœ… | πŸ”§ | πŸ’‘ |
68
+ | [filename-case](docs/rules/filename-case.md) | Enforce a case style for filenames. | βœ… | | |
69
+ | [import-style](docs/rules/import-style.md) | Enforce specific import styles per module. | βœ… | | |
70
+ | [new-for-builtins](docs/rules/new-for-builtins.md) | Enforce the use of `new` for all builtins, except `String`, `Number`, `Boolean`, `Symbol` and `BigInt`. | βœ… | πŸ”§ | |
71
+ | [no-abusive-eslint-disable](docs/rules/no-abusive-eslint-disable.md) | Enforce specifying rules to disable in `eslint-disable` comments. | βœ… | | |
72
+ | [no-array-callback-reference](docs/rules/no-array-callback-reference.md) | Prevent passing a function reference directly to iterator methods. | βœ… | | πŸ’‘ |
73
+ | [no-array-for-each](docs/rules/no-array-for-each.md) | Prefer `for…of` over the `forEach` method. | βœ… | πŸ”§ | πŸ’‘ |
74
+ | [no-array-method-this-argument](docs/rules/no-array-method-this-argument.md) | Disallow using the `this` argument in array methods. | βœ… | πŸ”§ | πŸ’‘ |
75
+ | [no-array-push-push](docs/rules/no-array-push-push.md) | Enforce combining multiple `Array#push()` into one call. | βœ… | πŸ”§ | πŸ’‘ |
76
+ | [no-array-reduce](docs/rules/no-array-reduce.md) | Disallow `Array#reduce()` and `Array#reduceRight()`. | βœ… | | |
77
+ | [no-await-expression-member](docs/rules/no-await-expression-member.md) | Disallow member access from await expression. | βœ… | πŸ”§ | |
78
+ | [no-console-spaces](docs/rules/no-console-spaces.md) | Do not use leading/trailing space between `console.log` parameters. | βœ… | πŸ”§ | |
79
+ | [no-document-cookie](docs/rules/no-document-cookie.md) | Do not use `document.cookie` directly. | βœ… | | |
80
+ | [no-empty-file](docs/rules/no-empty-file.md) | Disallow empty files. | βœ… | | |
81
+ | [no-for-loop](docs/rules/no-for-loop.md) | Do not use a `for` loop that can be replaced with a `for-of` loop. | βœ… | πŸ”§ | |
82
+ | [no-hex-escape](docs/rules/no-hex-escape.md) | Enforce the use of Unicode escapes instead of hexadecimal escapes. | βœ… | πŸ”§ | |
83
+ | [no-instanceof-array](docs/rules/no-instanceof-array.md) | Require `Array.isArray()` instead of `instanceof Array`. | βœ… | πŸ”§ | |
84
+ | [no-invalid-remove-event-listener](docs/rules/no-invalid-remove-event-listener.md) | Prevent calling `EventTarget#removeEventListener()` with the result of an expression. | βœ… | | |
85
+ | [no-keyword-prefix](docs/rules/no-keyword-prefix.md) | Disallow identifiers starting with `new` or `class`. | | | |
86
+ | [no-lonely-if](docs/rules/no-lonely-if.md) | Disallow `if` statements as the only statement in `if` blocks without `else`. | βœ… | πŸ”§ | |
87
+ | [no-negated-condition](docs/rules/no-negated-condition.md) | Disallow negated conditions. | βœ… | πŸ”§ | |
88
+ | [no-nested-ternary](docs/rules/no-nested-ternary.md) | Disallow nested ternary expressions. | βœ… | πŸ”§ | |
89
+ | [no-new-array](docs/rules/no-new-array.md) | Disallow `new Array()`. | βœ… | πŸ”§ | πŸ’‘ |
90
+ | [no-new-buffer](docs/rules/no-new-buffer.md) | Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`. | βœ… | πŸ”§ | πŸ’‘ |
91
+ | [no-null](docs/rules/no-null.md) | Disallow the use of the `null` literal. | βœ… | πŸ”§ | πŸ’‘ |
92
+ | [no-object-as-default-parameter](docs/rules/no-object-as-default-parameter.md) | Disallow the use of objects as default parameters. | βœ… | | |
93
+ | [no-process-exit](docs/rules/no-process-exit.md) | Disallow `process.exit()`. | βœ… | | |
94
+ | [no-static-only-class](docs/rules/no-static-only-class.md) | Disallow classes that only have static members. | βœ… | πŸ”§ | |
95
+ | [no-thenable](docs/rules/no-thenable.md) | Disallow `then` property. | βœ… | | |
96
+ | [no-this-assignment](docs/rules/no-this-assignment.md) | Disallow assigning `this` to a variable. | βœ… | | |
97
+ | [no-typeof-undefined](docs/rules/no-typeof-undefined.md) | Disallow comparing `undefined` using `typeof`. | βœ… | πŸ”§ | πŸ’‘ |
98
+ | [no-unnecessary-await](docs/rules/no-unnecessary-await.md) | Disallow awaiting non-promise values. | βœ… | πŸ”§ | |
99
+ | [no-unreadable-array-destructuring](docs/rules/no-unreadable-array-destructuring.md) | Disallow unreadable array destructuring. | βœ… | πŸ”§ | |
100
+ | [no-unreadable-iife](docs/rules/no-unreadable-iife.md) | Disallow unreadable IIFEs. | βœ… | | |
101
+ | [no-unsafe-regex](docs/rules/no-unsafe-regex.md) | Disallow unsafe regular expressions. | | | |
102
+ | [no-unused-properties](docs/rules/no-unused-properties.md) | Disallow unused object properties. | | | |
103
+ | [no-useless-fallback-in-spread](docs/rules/no-useless-fallback-in-spread.md) | Disallow useless fallback when spreading in object literals. | βœ… | πŸ”§ | |
104
+ | [no-useless-length-check](docs/rules/no-useless-length-check.md) | Disallow useless array length check. | βœ… | πŸ”§ | |
105
+ | [no-useless-promise-resolve-reject](docs/rules/no-useless-promise-resolve-reject.md) | Disallow returning/yielding `Promise.resolve/reject()` in async functions or promise callbacks | βœ… | πŸ”§ | |
106
+ | [no-useless-spread](docs/rules/no-useless-spread.md) | Disallow unnecessary spread. | βœ… | πŸ”§ | |
107
+ | [no-useless-switch-case](docs/rules/no-useless-switch-case.md) | Disallow useless case in switch statements. | βœ… | | πŸ’‘ |
108
+ | [no-useless-undefined](docs/rules/no-useless-undefined.md) | Disallow useless `undefined`. | βœ… | πŸ”§ | |
109
+ | [no-zero-fractions](docs/rules/no-zero-fractions.md) | Disallow number literals with zero fractions or dangling dots. | βœ… | πŸ”§ | |
110
+ | [number-literal-case](docs/rules/number-literal-case.md) | Enforce proper case for numeric literals. | βœ… | πŸ”§ | |
111
+ | [numeric-separators-style](docs/rules/numeric-separators-style.md) | Enforce the style of numeric separators by correctly grouping digits. | βœ… | πŸ”§ | |
112
+ | [prefer-add-event-listener](docs/rules/prefer-add-event-listener.md) | Prefer `.addEventListener()` and `.removeEventListener()` over `on`-functions. | βœ… | πŸ”§ | |
113
+ | [prefer-array-find](docs/rules/prefer-array-find.md) | Prefer `.find(…)` and `.findLast(…)` over the first or last element from `.filter(…)`. | βœ… | πŸ”§ | πŸ’‘ |
114
+ | [prefer-array-flat](docs/rules/prefer-array-flat.md) | Prefer `Array#flat()` over legacy techniques to flatten arrays. | βœ… | πŸ”§ | |
115
+ | [prefer-array-flat-map](docs/rules/prefer-array-flat-map.md) | Prefer `.flatMap(…)` over `.map(…).flat()`. | βœ… | πŸ”§ | |
116
+ | [prefer-array-index-of](docs/rules/prefer-array-index-of.md) | Prefer `Array#{indexOf,lastIndexOf}()` over `Array#{findIndex,findLastIndex}()` when looking for the index of an item. | βœ… | πŸ”§ | πŸ’‘ |
117
+ | [prefer-array-some](docs/rules/prefer-array-some.md) | Prefer `.some(…)` over `.filter(…).length` check and `.{find,findLast}(…)`. | βœ… | πŸ”§ | πŸ’‘ |
118
+ | [prefer-at](docs/rules/prefer-at.md) | Prefer `.at()` method for index access and `String#charAt()`. | | πŸ”§ | πŸ’‘ |
119
+ | [prefer-code-point](docs/rules/prefer-code-point.md) | Prefer `String#codePointAt(…)` over `String#charCodeAt(…)` and `String.fromCodePoint(…)` over `String.fromCharCode(…)`. | βœ… | | πŸ’‘ |
120
+ | [prefer-date-now](docs/rules/prefer-date-now.md) | Prefer `Date.now()` to get the number of milliseconds since the Unix Epoch. | βœ… | πŸ”§ | |
121
+ | [prefer-default-parameters](docs/rules/prefer-default-parameters.md) | Prefer default parameters over reassignment. | βœ… | πŸ”§ | πŸ’‘ |
122
+ | [prefer-dom-node-append](docs/rules/prefer-dom-node-append.md) | Prefer `Node#append()` over `Node#appendChild()`. | βœ… | πŸ”§ | |
123
+ | [prefer-dom-node-dataset](docs/rules/prefer-dom-node-dataset.md) | Prefer using `.dataset` on DOM elements over calling attribute methods. | βœ… | πŸ”§ | |
124
+ | [prefer-dom-node-remove](docs/rules/prefer-dom-node-remove.md) | Prefer `childNode.remove()` over `parentNode.removeChild(childNode)`. | βœ… | πŸ”§ | πŸ’‘ |
125
+ | [prefer-dom-node-text-content](docs/rules/prefer-dom-node-text-content.md) | Prefer `.textContent` over `.innerText`. | βœ… | | πŸ’‘ |
126
+ | [prefer-event-target](docs/rules/prefer-event-target.md) | Prefer `EventTarget` over `EventEmitter`. | | | |
127
+ | [prefer-export-from](docs/rules/prefer-export-from.md) | Prefer `export…from` when re-exporting. | βœ… | πŸ”§ | πŸ’‘ |
128
+ | [prefer-includes](docs/rules/prefer-includes.md) | Prefer `.includes()` over `.indexOf()` and `Array#some()` when checking for existence or non-existence. | βœ… | πŸ”§ | πŸ’‘ |
129
+ | [prefer-json-parse-buffer](docs/rules/prefer-json-parse-buffer.md) | Prefer reading a JSON file as a buffer. | | πŸ”§ | |
130
+ | [prefer-keyboard-event-key](docs/rules/prefer-keyboard-event-key.md) | Prefer `KeyboardEvent#key` over `KeyboardEvent#keyCode`. | βœ… | πŸ”§ | |
131
+ | [prefer-logical-operator-over-ternary](docs/rules/prefer-logical-operator-over-ternary.md) | Prefer using a logical operator over a ternary. | βœ… | | πŸ’‘ |
132
+ | [prefer-math-trunc](docs/rules/prefer-math-trunc.md) | Enforce the use of `Math.trunc` instead of bitwise operators. | βœ… | πŸ”§ | πŸ’‘ |
133
+ | [prefer-modern-dom-apis](docs/rules/prefer-modern-dom-apis.md) | Prefer `.before()` over `.insertBefore()`, `.replaceWith()` over `.replaceChild()`, prefer one of `.before()`, `.after()`, `.append()` or `.prepend()` over `insertAdjacentText()` and `insertAdjacentElement()`. | βœ… | πŸ”§ | |
134
+ | [prefer-modern-math-apis](docs/rules/prefer-modern-math-apis.md) | Prefer modern `Math` APIs over legacy patterns. | βœ… | πŸ”§ | |
135
+ | [prefer-module](docs/rules/prefer-module.md) | Prefer JavaScript modules (ESM) over CommonJS. | βœ… | πŸ”§ | πŸ’‘ |
136
+ | [prefer-native-coercion-functions](docs/rules/prefer-native-coercion-functions.md) | Prefer using `String`, `Number`, `BigInt`, `Boolean`, and `Symbol` directly. | βœ… | πŸ”§ | |
137
+ | [prefer-negative-index](docs/rules/prefer-negative-index.md) | Prefer negative index over `.length - index` when possible. | βœ… | πŸ”§ | |
138
+ | [prefer-node-protocol](docs/rules/prefer-node-protocol.md) | Prefer using the `node:` protocol when importing Node.js builtin modules. | βœ… | πŸ”§ | |
139
+ | [prefer-number-properties](docs/rules/prefer-number-properties.md) | Prefer `Number` static properties over global ones. | βœ… | πŸ”§ | πŸ’‘ |
140
+ | [prefer-object-from-entries](docs/rules/prefer-object-from-entries.md) | Prefer using `Object.fromEntries(…)` to transform a list of key-value pairs into an object. | βœ… | πŸ”§ | |
141
+ | [prefer-optional-catch-binding](docs/rules/prefer-optional-catch-binding.md) | Prefer omitting the `catch` binding parameter. | βœ… | πŸ”§ | |
142
+ | [prefer-prototype-methods](docs/rules/prefer-prototype-methods.md) | Prefer borrowing methods from the prototype instead of the instance. | βœ… | πŸ”§ | |
143
+ | [prefer-query-selector](docs/rules/prefer-query-selector.md) | Prefer `.querySelector()` over `.getElementById()`, `.querySelectorAll()` over `.getElementsByClassName()` and `.getElementsByTagName()`. | βœ… | πŸ”§ | |
144
+ | [prefer-reflect-apply](docs/rules/prefer-reflect-apply.md) | Prefer `Reflect.apply()` over `Function#apply()`. | βœ… | πŸ”§ | |
145
+ | [prefer-regexp-test](docs/rules/prefer-regexp-test.md) | Prefer `RegExp#test()` over `String#match()` and `RegExp#exec()`. | βœ… | πŸ”§ | πŸ’‘ |
146
+ | [prefer-set-has](docs/rules/prefer-set-has.md) | Prefer `Set#has()` over `Array#includes()` when checking for existence or non-existence. | βœ… | πŸ”§ | πŸ’‘ |
147
+ | [prefer-set-size](docs/rules/prefer-set-size.md) | Prefer using `Set#size` instead of `Array#length`. | βœ… | πŸ”§ | |
148
+ | [prefer-spread](docs/rules/prefer-spread.md) | Prefer the spread operator over `Array.from(…)`, `Array#concat(…)`, `Array#{slice,toSpliced}()` and `String#split('')`. | βœ… | πŸ”§ | πŸ’‘ |
149
+ | [prefer-string-replace-all](docs/rules/prefer-string-replace-all.md) | Prefer `String#replaceAll()` over regex searches with the global flag. | | πŸ”§ | |
150
+ | [prefer-string-slice](docs/rules/prefer-string-slice.md) | Prefer `String#slice()` over `String#substr()` and `String#substring()`. | βœ… | πŸ”§ | |
151
+ | [prefer-string-starts-ends-with](docs/rules/prefer-string-starts-ends-with.md) | Prefer `String#startsWith()` & `String#endsWith()` over `RegExp#test()`. | βœ… | πŸ”§ | πŸ’‘ |
152
+ | [prefer-string-trim-start-end](docs/rules/prefer-string-trim-start-end.md) | Prefer `String#trimStart()` / `String#trimEnd()` over `String#trimLeft()` / `String#trimRight()`. | βœ… | πŸ”§ | |
153
+ | [prefer-switch](docs/rules/prefer-switch.md) | Prefer `switch` over multiple `else-if`. | βœ… | πŸ”§ | |
154
+ | [prefer-ternary](docs/rules/prefer-ternary.md) | Prefer ternary expressions over simple `if-else` statements. | βœ… | πŸ”§ | |
155
+ | [prefer-top-level-await](docs/rules/prefer-top-level-await.md) | Prefer top-level await over top-level promises and async function calls. | βœ… | | πŸ’‘ |
156
+ | [prefer-type-error](docs/rules/prefer-type-error.md) | Enforce throwing `TypeError` in type checking conditions. | βœ… | πŸ”§ | |
157
+ | [prevent-abbreviations](docs/rules/prevent-abbreviations.md) | Prevent abbreviations. | βœ… | πŸ”§ | |
158
+ | [relative-url-style](docs/rules/relative-url-style.md) | Enforce consistent relative URL style. | βœ… | πŸ”§ | πŸ’‘ |
159
+ | [require-array-join-separator](docs/rules/require-array-join-separator.md) | Enforce using the separator argument with `Array#join()`. | βœ… | πŸ”§ | |
160
+ | [require-number-to-fixed-digits-argument](docs/rules/require-number-to-fixed-digits-argument.md) | Enforce using the digits argument with `Number#toFixed()`. | βœ… | πŸ”§ | |
161
+ | [require-post-message-target-origin](docs/rules/require-post-message-target-origin.md) | Enforce using the `targetOrigin` argument with `window.postMessage()`. | | | πŸ’‘ |
162
+ | [string-content](docs/rules/string-content.md) | Enforce better string content. | | πŸ”§ | πŸ’‘ |
163
+ | [switch-case-braces](docs/rules/switch-case-braces.md) | Enforce consistent brace style for `case` clauses. | βœ… | πŸ”§ | |
164
+ | [template-indent](docs/rules/template-indent.md) | Fix whitespace-insensitive template indentation. | βœ… | πŸ”§ | |
165
+ | [text-encoding-identifier-case](docs/rules/text-encoding-identifier-case.md) | Enforce consistent case for text encoding identifiers. | βœ… | πŸ”§ | πŸ’‘ |
166
+ | [throw-new-error](docs/rules/throw-new-error.md) | Require `new` when throwing an error. | βœ… | πŸ”§ | |
168
167
 
169
168
  <!-- end auto-generated rules list -->
170
169
 
@@ -47,7 +47,10 @@ const messages = {
47
47
  'Unexpected \'{{matchedTerm}}\' comment without any conditions: \'{{comment}}\'.',
48
48
  };
49
49
 
50
- const packageResult = readPkgUp.sync();
50
+ // We don't need to normalize the package.json data, because we are only using 2 properties and those 2 properties
51
+ // aren't validated by the normalization. But when this plugin is used in a monorepo, the name field in the
52
+ // package.json is invalid and would make this plugin throw an error. See also #1871
53
+ const packageResult = readPkgUp.sync({normalize: false});
51
54
  const hasPackage = Boolean(packageResult);
52
55
  const packageJson = hasPackage ? packageResult.packageJson : {};
53
56
 
@@ -17,9 +17,9 @@ const hasTripeSlashDirectives = comments =>
17
17
 
18
18
  /** @param {import('eslint').Rule.RuleContext} context */
19
19
  const create = context => {
20
- const filename = context.getPhysicalFilename().toLowerCase();
20
+ const filename = context.getPhysicalFilename();
21
21
 
22
- if (!/\.(?:js|mjs|cjs|ts|mts|cts)$/.test(filename)) {
22
+ if (!/\.(?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$/i.test(filename)) {
23
23
  return;
24
24
  }
25
25
 
@@ -79,6 +79,10 @@ const uselessArrayCloneSelector = [
79
79
  'map',
80
80
  'slice',
81
81
  'splice',
82
+ 'toReversed',
83
+ 'toSorted',
84
+ 'toSpliced',
85
+ 'with',
82
86
  ]),
83
87
  // `String#split()`
84
88
  methodCallSelector('split'),
@@ -148,11 +152,11 @@ function * unwrapSingleArraySpread(fixer, arrayExpression, sourceCode) {
148
152
  ] = sourceCode.getLastTokens(arrayExpression, 2);
149
153
 
150
154
  // `[...value]`
151
- // ^
155
+ // ^
152
156
  yield fixer.remove(closingBracketToken);
153
157
 
154
158
  // `[...value,]`
155
- // ^
159
+ // ^
156
160
  if (isCommaToken(commaToken)) {
157
161
  yield fixer.remove(commaToken);
158
162
  }
@@ -36,6 +36,15 @@ const methods = new Map([
36
36
  ]),
37
37
  },
38
38
  ],
39
+ [
40
+ 'toSpliced',
41
+ {
42
+ argumentsIndexes: [0],
43
+ supportObjects: new Set([
44
+ 'Array',
45
+ ]),
46
+ },
47
+ ],
39
48
  [
40
49
  'at',
41
50
  {
@@ -47,6 +56,16 @@ const methods = new Map([
47
56
  ]),
48
57
  },
49
58
  ],
59
+ [
60
+ 'with',
61
+ {
62
+ argumentsIndexes: [0],
63
+ supportObjects: new Set([
64
+ 'Array',
65
+ ...typedArray,
66
+ ]),
67
+ },
68
+ ],
50
69
  ]);
51
70
 
52
71
  const getMemberName = node => {
@@ -92,12 +111,12 @@ function parse(node) {
92
111
  const parentCallee = callee.object.object;
93
112
 
94
113
  if (
95
- // [].{slice,splice}
114
+ // `[].{slice,splice,toSpliced,at,with}`
96
115
  (
97
116
  parentCallee.type === 'ArrayExpression'
98
117
  && parentCallee.elements.length === 0
99
118
  )
100
- // ''.slice
119
+ // `''.slice`
101
120
  || (
102
121
  method === 'slice'
103
122
  && isLiteral(parentCallee, '')
@@ -175,7 +194,7 @@ module.exports = {
175
194
  meta: {
176
195
  type: 'suggestion',
177
196
  docs: {
178
- description: 'Prefer negative index over `.length - index` for `{String,Array,TypedArray}#{slice,at}()` and `Array#splice()`.',
197
+ description: 'Prefer negative index over `.length - index` when possible.',
179
198
  },
180
199
  fixable: 'code',
181
200
  messages,
@@ -30,17 +30,7 @@ const arrayStaticMethodSelector = methodCallSelector({
30
30
  path: 'init',
31
31
  });
32
32
 
33
- // `array.concat()`
34
- // `array.copyWithin()`
35
- // `array.fill()`
36
- // `array.filter()`
37
- // `array.flat()`
38
- // `array.flatMap()`
39
- // `array.map()`
40
- // `array.reverse()`
41
- // `array.slice()`
42
- // `array.sort()`
43
- // `array.splice()`
33
+ // Array methods that return an array
44
34
  const arrayMethodSelector = methodCallSelector({
45
35
  methods: [
46
36
  'concat',
@@ -54,6 +44,10 @@ const arrayMethodSelector = methodCallSelector({
54
44
  'slice',
55
45
  'sort',
56
46
  'splice',
47
+ 'toReversed',
48
+ 'toSorted',
49
+ 'toSpliced',
50
+ 'with',
57
51
  ],
58
52
  path: 'init',
59
53
  });
@@ -16,6 +16,7 @@ const isMethodNamed = require('./utils/is-method-named.js');
16
16
  const ERROR_ARRAY_FROM = 'array-from';
17
17
  const ERROR_ARRAY_CONCAT = 'array-concat';
18
18
  const ERROR_ARRAY_SLICE = 'array-slice';
19
+ const ERROR_ARRAY_TO_SPLICED = 'array-to-spliced';
19
20
  const ERROR_STRING_SPLIT = 'string-split';
20
21
  const SUGGESTION_CONCAT_ARGUMENT_IS_SPREADABLE = 'argument-is-spreadable';
21
22
  const SUGGESTION_CONCAT_ARGUMENT_IS_NOT_SPREADABLE = 'argument-is-not-spreadable';
@@ -26,6 +27,7 @@ const messages = {
26
27
  [ERROR_ARRAY_FROM]: 'Prefer the spread operator over `Array.from(…)`.',
27
28
  [ERROR_ARRAY_CONCAT]: 'Prefer the spread operator over `Array#concat(…)`.',
28
29
  [ERROR_ARRAY_SLICE]: 'Prefer the spread operator over `Array#slice()`.',
30
+ [ERROR_ARRAY_TO_SPLICED]: 'Prefer the spread operator over `Array#toSpliced()`.',
29
31
  [ERROR_STRING_SPLIT]: 'Prefer the spread operator over `String#split(\'\')`.',
30
32
  [SUGGESTION_CONCAT_ARGUMENT_IS_SPREADABLE]: 'First argument is an `array`.',
31
33
  [SUGGESTION_CONCAT_ARGUMENT_IS_NOT_SPREADABLE]: 'First argument is not an `array`.',
@@ -56,6 +58,14 @@ const arraySliceCallSelector = [
56
58
  '[callee.object.type!="ArrayExpression"]',
57
59
  ].join('');
58
60
 
61
+ const arrayToSplicedCallSelector = [
62
+ methodCallSelector({
63
+ method: 'toSpliced',
64
+ argumentsLength: 0,
65
+ }),
66
+ '[callee.object.type!="ArrayExpression"]',
67
+ ].join('');
68
+
59
69
  const ignoredSliceCallee = [
60
70
  'arrayBuffer',
61
71
  'blob',
@@ -444,6 +454,13 @@ const create = context => {
444
454
  fix: methodCallToSpread(node, sourceCode),
445
455
  };
446
456
  },
457
+ [arrayToSplicedCallSelector](node) {
458
+ return {
459
+ node: node.callee.property,
460
+ messageId: ERROR_ARRAY_TO_SPLICED,
461
+ fix: methodCallToSpread(node, sourceCode),
462
+ };
463
+ },
447
464
  [stringSplitCallSelector](node) {
448
465
  const [separator] = node.arguments;
449
466
  if (!isLiteral(separator, '')) {
@@ -495,7 +512,7 @@ module.exports = {
495
512
  meta: {
496
513
  type: 'suggestion',
497
514
  docs: {
498
- description: 'Prefer the spread operator over `Array.from(…)`, `Array#concat(…)`, `Array#slice()` and `String#split(\'\')`.',
515
+ description: 'Prefer the spread operator over `Array.from(…)`, `Array#concat(…)`, `Array#{slice,toSpliced}()` and `String#split(\'\')`.',
499
516
  },
500
517
  fixable: 'code',
501
518
  hasSuggestions: true,
@@ -84,6 +84,9 @@ module.exports.defaultReplacements = {
84
84
  elem: {
85
85
  element: true,
86
86
  },
87
+ elems: {
88
+ elements: true,
89
+ },
87
90
  env: {
88
91
  environment: true,
89
92
  },