prefer-array-index-of.js 535 B

123456789101112131415161718192021
  1. 'use strict';
  2. const simpleArraySearchRule = require('./shared/simple-array-search-rule.js');
  3. const {messages, createListeners} = simpleArraySearchRule({
  4. method: 'findIndex',
  5. replacement: 'indexOf',
  6. });
  7. /** @type {import('eslint').Rule.RuleModule} */
  8. module.exports = {
  9. create: context => createListeners(context),
  10. meta: {
  11. type: 'suggestion',
  12. docs: {
  13. description: 'Prefer `Array#indexOf()` over `Array#findIndex()` when looking for the index of an item.',
  14. },
  15. fixable: 'code',
  16. hasSuggestions: true,
  17. messages,
  18. },
  19. };