Skip to content

Commit

Permalink
review eslint core rules: disallow null comparisons without type-…
Browse files Browse the repository at this point in the history
…checking operators
  • Loading branch information
zloirock committed Aug 18, 2023
1 parent e98027d commit bc32a7f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/core-js-builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = async function ({
if (!['bundle', 'cjs', 'esm'].includes(format)) throw TypeError('Incorrect output type');
summary = { comment: normalizeSummary(summary.comment), console: normalizeSummary(summary.console) };

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

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

if (filename != null) {
if (!(filename === null || filename === undefined)) {
await mkdirp(dirname(filename));
await writeFile(filename, script);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js-compat/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = function ({
version = null,
inverse = false,
} = {}) {
if (modules == null) modules = filter;
if (modules === null || modules === undefined) modules = filter;
inverse = !!inverse;

const parsedTargets = targets ? targetsParser(targets) : null;
Expand Down
4 changes: 2 additions & 2 deletions packages/core-js/internals/regexp-sticky-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var $RegExp = global.RegExp;
var UNSUPPORTED_Y = fails(function () {
var re = $RegExp('a', 'y');
re.lastIndex = 2;
return re.exec('abcd') != null;
return re.exec('abcd') !== null;
});

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

module.exports = {
Expand Down
2 changes: 2 additions & 0 deletions tests/eslint/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ const base = {
'no-empty-function': ERROR,
// disallow empty static blocks
'no-empty-static-block': ERROR,
// disallow `null` comparisons without type-checking operators
'no-eq-null': ERROR,
// disallow use of eval()
'no-eval': ERROR,
// disallow adding to native types
Expand Down

0 comments on commit bc32a7f

Please sign in to comment.