Skip to content

Commit b87c8a9

Browse files
authored
Rename no-array-for-each rule to no-for-each (#3216)
1 parent d0945e0 commit b87c8a9

9 files changed

Lines changed: 10 additions & 10 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ Use a clear prefix that signals intent (see [ESLint built-in rules](https://esli
181181
- **`consistent-`** - Enforce a single consistent style: `consistent-destructuring`
182182
- **No prefix** - Enforce a specific pattern: `error-message`, `filename-case`, `throw-new-error`
183183

184-
Name after the target construct, not the fix. Be specific: `no-array-for-each` not `no-foreach`.
184+
Name after the target construct, not the fix. Be specific: `no-array-method-this-argument` not `no-this-argument`.
185185

186186
## Creating a new rule
187187

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# no-array-for-each
1+
# no-for-each
22

33
📝 Prefer `for…of` over the `forEach` method.
44

eslint.dogfooding.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const config = [
6363
files: [
6464
'rules/comment-content.js',
6565
'rules/consistent-assert.js',
66-
'rules/no-array-for-each.js',
66+
'rules/no-for-each.js',
6767
'rules/no-array-reduce.js',
6868
'rules/no-declarations-before-early-exit.js',
6969
'rules/no-error-property-assignment.js',

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export default [
9494
| [no-anonymous-default-export](docs/rules/no-anonymous-default-export.md) | Disallow anonymous functions and classes as the default export. | ✅ ☑️ | | 💡 |
9595
| [no-array-callback-reference](docs/rules/no-array-callback-reference.md) | Prevent passing a function reference directly to iterator methods. || | 💡 |
9696
| [no-array-fill-with-reference-type](docs/rules/no-array-fill-with-reference-type.md) | Disallow using reference values as `Array#fill()` values. | ✅ ☑️ | | |
97-
| [no-array-for-each](docs/rules/no-array-for-each.md) | Prefer `for…of` over the `forEach` method. | ✅ ☑️ | 🔧 | 💡 |
9897
| [no-array-from-fill](docs/rules/no-array-from-fill.md) | Disallow `.fill()` after `Array.from({length: …})`. | ✅ ☑️ | | |
9998
| [no-array-method-this-argument](docs/rules/no-array-method-this-argument.md) | Disallow using the `this` argument in array methods. | ✅ ☑️ | 🔧 | 💡 |
10099
| [no-array-reduce](docs/rules/no-array-reduce.md) | Disallow `Array#reduce()` and `Array#reduceRight()`. || 🔧 | |
@@ -117,6 +116,7 @@ export default [
117116
| [no-empty-file](docs/rules/no-empty-file.md) | Disallow empty files. | ✅ ☑️ | | |
118117
| [no-error-property-assignment](docs/rules/no-error-property-assignment.md) | Disallow assigning to built-in error properties. | ✅ ☑️ | | |
119118
| [no-exports-in-scripts](docs/rules/no-exports-in-scripts.md) | Disallow exports in scripts. | ✅ ☑️ | | |
119+
| [no-for-each](docs/rules/no-for-each.md) | Prefer `for…of` over the `forEach` method. | ✅ ☑️ | 🔧 | 💡 |
120120
| [no-for-loop](docs/rules/no-for-loop.md) | Do not use a `for` loop that can be replaced with a `for-of` loop. || 🔧 | |
121121
| [no-global-object-property-assignment](docs/rules/no-global-object-property-assignment.md) | Disallow assigning properties on the global object. | ✅ ☑️ | | |
122122
| [no-immediate-mutation](docs/rules/no-immediate-mutation.md) | Disallow immediate mutation after variable assignment. || 🔧 | 💡 |

rules/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export {default as 'no-accessor-recursion'} from './no-accessor-recursion.js';
3535
export {default as 'no-anonymous-default-export'} from './no-anonymous-default-export.js';
3636
export {default as 'no-array-callback-reference'} from './no-array-callback-reference.js';
3737
export {default as 'no-array-fill-with-reference-type'} from './no-array-fill-with-reference-type.js';
38-
export {default as 'no-array-for-each'} from './no-array-for-each.js';
3938
export {default as 'no-array-from-fill'} from './no-array-from-fill.js';
4039
export {default as 'no-array-method-this-argument'} from './no-array-method-this-argument.js';
4140
export {default as 'no-array-reduce'} from './no-array-reduce.js';
@@ -58,6 +57,7 @@ export {default as 'no-duplicate-set-values'} from './no-duplicate-set-values.js
5857
export {default as 'no-empty-file'} from './no-empty-file.js';
5958
export {default as 'no-error-property-assignment'} from './no-error-property-assignment.js';
6059
export {default as 'no-exports-in-scripts'} from './no-exports-in-scripts.js';
60+
export {default as 'no-for-each'} from './no-for-each.js';
6161
export {default as 'no-for-loop'} from './no-for-loop.js';
6262
export {default as 'no-global-object-property-assignment'} from './no-global-object-property-assignment.js';
6363
export {default as 'no-immediate-mutation'} from './no-immediate-mutation.js';
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import {
3030
assertToken,
3131
} from './utils/index.js';
3232

33-
const MESSAGE_ID_ERROR = 'no-array-for-each/error';
34-
const MESSAGE_ID_SUGGESTION = 'no-array-for-each/suggestion';
33+
const MESSAGE_ID_ERROR = 'no-for-each/error';
34+
const MESSAGE_ID_SUGGESTION = 'no-for-each/suggestion';
3535
const messages = {
3636
[MESSAGE_ID_ERROR]: 'Use `for…of` instead of `.forEach(…)`.',
3737
[MESSAGE_ID_SUGGESTION]: 'Switch to `for…of`.',
@@ -134,7 +134,7 @@ function getFixFunction(callExpression, functionInfo, context) {
134134
const returnToken = sourceCode.getFirstToken(returnStatement);
135135
assertToken(returnToken, {
136136
expected: 'return',
137-
ruleId: 'no-array-for-each',
137+
ruleId: 'no-for-each',
138138
});
139139

140140
if (!returnStatement.argument) {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Snapshot report for `test/no-array-for-each.js`
1+
# Snapshot report for `test/no-for-each.js`
22

3-
The actual snapshot is saved in `no-array-for-each.js.snap`.
3+
The actual snapshot is saved in `no-for-each.js.snap`.
44

55
Generated by [AVA](https://avajs.dev).
66

0 commit comments

Comments
 (0)