This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 889
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no-null-keyword: Allow strict comparison (#2802)
Allows `x === null`, but disallows `x == null`. The latter will be automatically fixed to `x == undefined`. [new-fixer] `no-null-keyword`: fix `x == null` to `x == undefined` [enhancement] `no-null-keyword` allows strict comparison Fixes: #2782
- Loading branch information
Showing
3 changed files
with
39 additions
and
7 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,12 @@ | ||
var x = null; // error | ||
console.log(null, x); // error | ||
|
||
let match: string | null; | ||
interface foo { | ||
bar: [number, null, string]; | ||
} | ||
|
||
if (document.querySelector('.foo') === null) {} | ||
if (document.querySelector('.foo') == undefined) {} | ||
if (null !== document.querySelector('.foo')) {} | ||
if (undefined != document.querySelector('.foo')) {} |
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 |
---|---|---|
@@ -1,9 +1,18 @@ | ||
var x = null; // error | ||
~~~~ [Use 'undefined' instead of 'null'] | ||
~~~~ [0] | ||
console.log(null, x); // error | ||
~~~~ [Use 'undefined' instead of 'null'] | ||
~~~~ [0] | ||
|
||
let match(): string | null; | ||
let match: string | null; | ||
interface foo { | ||
bar: [number, null, string]; | ||
} | ||
|
||
if (document.querySelector('.foo') === null) {} | ||
if (document.querySelector('.foo') == null) {} | ||
~~~~ [0] | ||
if (null !== document.querySelector('.foo')) {} | ||
if (null != document.querySelector('.foo')) {} | ||
~~~~ [0] | ||
|
||
[0]: Use 'undefined' instead of 'null' |