Skip to content

Commit bc32a7f

Browse files
committed
review eslint core rules: disallow null comparisons without type-checking operators
1 parent e98027d commit bc32a7f

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

packages/core-js-builder/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = async function ({
3636
if (!['bundle', 'cjs', 'esm'].includes(format)) throw TypeError('Incorrect output type');
3737
summary = { comment: normalizeSummary(summary.comment), console: normalizeSummary(summary.console) };
3838

39-
const TITLE = filename != null ? filename : '`core-js`';
39+
const TITLE = filename !== null || filename !== undefined ? filename : '`core-js`';
4040
let script = banner;
4141
let code = '\n';
4242

@@ -95,7 +95,7 @@ module.exports = async function ({
9595
} else console.log('\u001B[36mnothing\u001B[0m');
9696
}
9797

98-
if (filename != null) {
98+
if (!(filename === null || filename === undefined)) {
9999
await mkdirp(dirname(filename));
100100
await writeFile(filename, script);
101101
}

packages/core-js-compat/compat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = function ({
5656
version = null,
5757
inverse = false,
5858
} = {}) {
59-
if (modules == null) modules = filter;
59+
if (modules === null || modules === undefined) modules = filter;
6060
inverse = !!inverse;
6161

6262
const parsedTargets = targets ? targetsParser(targets) : null;

packages/core-js/internals/regexp-sticky-helpers.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var $RegExp = global.RegExp;
88
var UNSUPPORTED_Y = fails(function () {
99
var re = $RegExp('a', 'y');
1010
re.lastIndex = 2;
11-
return re.exec('abcd') != null;
11+
return re.exec('abcd') !== null;
1212
});
1313

1414
// UC Browser bug
@@ -21,7 +21,7 @@ var BROKEN_CARET = UNSUPPORTED_Y || fails(function () {
2121
// https://bugzilla.mozilla.org/show_bug.cgi?id=773687
2222
var re = $RegExp('^r', 'gy');
2323
re.lastIndex = 2;
24-
return re.exec('str') != null;
24+
return re.exec('str') !== null;
2525
});
2626

2727
module.exports = {

tests/eslint/eslint.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ const base = {
154154
'no-empty-function': ERROR,
155155
// disallow empty static blocks
156156
'no-empty-static-block': ERROR,
157+
// disallow `null` comparisons without type-checking operators
158+
'no-eq-null': ERROR,
157159
// disallow use of eval()
158160
'no-eval': ERROR,
159161
// disallow adding to native types

0 commit comments

Comments
 (0)