2020-08-25 23:57:08 +00:00
|
|
|
module.exports = {
|
|
|
|
meta: {
|
2022-11-10 10:43:16 +00:00
|
|
|
type: 'suggestion',
|
|
|
|
docs: {
|
|
|
|
description: 'enforce `for..of` loops over `Array.forEach`',
|
2024-03-28 02:00:41 +00:00
|
|
|
url: require('../url')(module),
|
2022-11-10 10:43:16 +00:00
|
|
|
},
|
2024-03-28 02:00:41 +00:00
|
|
|
schema: [],
|
2020-08-25 23:57:08 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
create(context) {
|
|
|
|
return {
|
|
|
|
CallExpression(node) {
|
|
|
|
if (node.callee.property && node.callee.property.name === 'forEach') {
|
2022-11-10 10:43:16 +00:00
|
|
|
context.report({node, message: 'Prefer for...of instead of Array.forEach'})
|
2020-08-25 23:57:08 +00:00
|
|
|
}
|
2024-03-28 02:00:41 +00:00
|
|
|
},
|
2020-08-25 23:57:08 +00:00
|
|
|
}
|
2024-03-28 02:00:41 +00:00
|
|
|
},
|
2020-08-25 23:57:08 +00:00
|
|
|
}
|