-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #17556 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information
1 parent
7fa140f
commit a84d145
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
|
||
const RuleTester = require('../../tools/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 }] | ||
} | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'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 | ||
}; | ||
}; |