diff --git a/.eslintrc.js b/.eslintrc.js index 8acba223d986eb..59d585b9d355bd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -244,6 +244,10 @@ module.exports = { selector: "CallExpression[callee.property.name='strictEqual'][arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])", message: 'The first argument should be the `actual`, not the `expected` value.', }, + { + selector: "CallExpression[callee.name='isNaN']", + message: 'Use Number.isNaN() instead of the global isNaN() function.', + }, ], /* eslint-enable max-len */ 'no-return-await': 'error', diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 4344e4a461b701..717f7cca105b65 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -63,6 +63,8 @@ rules: message: "Please use `require('internal/errors').hideStackFrames()` instead." - selector: "AssignmentExpression:matches([left.name='prepareStackTrace'], [left.property.name='prepareStackTrace'])" message: "Use 'overrideStackTrace' from 'lib/internal/errors.js' instead of 'Error.prepareStackTrace'." + - selector: "CallExpression[callee.name='isNaN']" + message: "Use NumberIsNaN() primordial instead of the global isNaN() function." # Custom rules in tools/eslint-rules node-core/lowercase-name-for-primitive: error node-core/non-ascii-character: error diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index 81e470322052f9..86d4b595e7dc9a 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -18,7 +18,6 @@ rules: node-core/crypto-check: error node-core/eslint-check: error node-core/inspector-check: error - node-core/number-isnan: error ## common module is mandatory in tests node-core/required-modules: - error diff --git a/test/parallel/test-eslint-number-isnan.js b/test/parallel/test-eslint-number-isnan.js deleted file mode 100644 index 73359be3bcd37f..00000000000000 --- a/test/parallel/test-eslint-number-isnan.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -const common = require('../common'); -if (!common.hasCrypto) - common.skip('missing crypto'); - -common.skipIfEslintMissing(); - -const RuleTester = require('../../tools/node_modules/eslint').RuleTester; -const rule = require('../../tools/eslint-rules/number-isnan'); - -const message = 'Please use Number.isNaN instead of the global isNaN function'; - -new RuleTester().run('number-isnan', rule, { - valid: [ - 'Number.isNaN()' - ], - invalid: [ - { - code: 'isNaN()', - errors: [{ message }] - } - ] -}); diff --git a/test/root.status b/test/root.status index af4bc90e97c0fb..43e4aea29d9c4c 100644 --- a/test/root.status +++ b/test/root.status @@ -34,7 +34,6 @@ parallel/test-eslint-eslint-check: SLOW parallel/test-eslint-inspector-check: SLOW parallel/test-eslint-lowercase-name-for-primitive: SLOW parallel/test-eslint-no-unescaped-regexp-dot: SLOW -parallel/test-eslint-number-isnan: SLOW parallel/test-eslint-prefer-assert-iferror: SLOW parallel/test-eslint-prefer-assert-methods: SLOW parallel/test-eslint-prefer-common-mustnotcall: SLOW diff --git a/tools/eslint-rules/number-isnan.js b/tools/eslint-rules/number-isnan.js deleted file mode 100644 index 885c38be8b2384..00000000000000 --- a/tools/eslint-rules/number-isnan.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -const astSelector = "CallExpression[callee.name='isNaN']"; -const msg = 'Please use Number.isNaN instead of the global isNaN function'; - -module.exports = function(context) { - function report(node) { - context.report(node, msg); - } - - return { - [astSelector]: report - }; -};