Skip to content

Commit a84ec28

Browse files
authored
Enable eqeqeq rule (#16404)
* eqeqeq * review * review
1 parent f7a7715 commit a84ec28

File tree

20 files changed

+31
-25
lines changed

20 files changed

+31
-25
lines changed

Gulpfile.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ async function buildBabel(useWorker, ignore = []) {
288288
return Promise.allSettled(promises)
289289
.then(results => {
290290
results.forEach(result => {
291-
if (result.status == "rejected") {
291+
if (result.status === "rejected") {
292292
if (process.env.WATCH_SKIP_BUILD) {
293293
console.error(result.reason);
294294
} else {

Makefile.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile.source.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function exec(executable, args, cwd, inheritStdio = true) {
5454
env: process.env,
5555
});
5656
} catch (error) {
57-
if (inheritStdio && error.status != 0) {
57+
if (inheritStdio && error.status !== 0) {
5858
console.error(
5959
new Error(
6060
`\ncommand: ${executable} ${args.join(" ")}\ncode: ${error.status}`
@@ -180,7 +180,7 @@ target["bootstrap"] = function () {
180180
target["build"] = function () {
181181
target["build-no-bundle"]();
182182

183-
if (process.env.BABEL_COVERAGE != "true") {
183+
if (process.env.BABEL_COVERAGE !== "true") {
184184
target["build-standalone"]();
185185
}
186186
};

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ function pluginGeneratorOptimization({ types: t }) {
10361036
t.isStringLiteral(args[0])
10371037
) {
10381038
const str = args[0].value;
1039-
if (str.length == 1) {
1039+
if (str.length === 1) {
10401040
node.callee.property.name = "tokenChar";
10411041
args[0] = t.numericLiteral(str.charCodeAt(0));
10421042
}

eslint/babel-eslint-config-internal/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = [
2828
},
2929
rules: {
3030
curly: ["error", "multi-line"],
31+
eqeqeq: ["error", "smart"],
3132
"linebreak-style": ["error", "unix"],
3233
"no-case-declarations": "error",
3334
"no-confusing-arrow": "error",

packages/babel-cli/src/babel/dir.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default async function ({
5353
let outputMap: "both" | "external" | false = false;
5454
if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
5555
outputMap = "external";
56-
} else if (babelOptions.sourceMaps == undefined) {
56+
} else if (babelOptions.sourceMaps == null) {
5757
outputMap = util.hasDataSourcemap(res.code) ? "external" : "both";
5858
}
5959

packages/babel-cli/src/babel/file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default async function ({
100100
let outputMap: "both" | "external" | false = false;
101101
if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
102102
outputMap = "external";
103-
} else if (babelOptions.sourceMaps == undefined && result.hasRawMap) {
103+
} else if (babelOptions.sourceMaps == null && result.hasRawMap) {
104104
outputMap = util.hasDataSourcemap(result.code) ? "external" : "both";
105105
}
106106

packages/babel-cli/src/babel/options.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,12 @@ function booleanify(val: "true" | 1): true;
362362
function booleanify(val: any): any {
363363
if (val === undefined) return undefined;
364364

365+
// eslint-disable-next-line eqeqeq
365366
if (val === "true" || val == 1) {
366367
return true;
367368
}
368369

370+
// eslint-disable-next-line eqeqeq
369371
if (val === "false" || val == 0 || !val) {
370372
return false;
371373
}

packages/babel-cli/src/babel/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function addSourceMappingUrl(code: string, loc: string): string {
6161

6262
export function hasDataSourcemap(code: string): boolean {
6363
const pos = code.lastIndexOf("\n", code.length - 2);
64-
return pos != -1 && code.lastIndexOf("//# sourceMappingURL") < pos;
64+
return pos !== -1 && code.lastIndexOf("//# sourceMappingURL") < pos;
6565
}
6666

6767
const CALLER = {

packages/babel-generator/src/printer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ class Printer {
661661
this._printStack.push(node);
662662

663663
const oldInAux = this._insideAux;
664-
this._insideAux = node.loc == undefined;
664+
this._insideAux = node.loc == null;
665665
this._maybeAddAuxComment(this._insideAux && !oldInAux);
666666

667667
const parenthesized = node.extra?.parenthesized as boolean | undefined;
@@ -1128,7 +1128,7 @@ class Printer {
11281128
if (
11291129
this._buf.hasContent() &&
11301130
(comment.type === "CommentLine" ||
1131-
commentStartLine != commentEndLine)
1131+
commentStartLine !== commentEndLine)
11321132
) {
11331133
offset = leadingCommentNewline = 1;
11341134
}

packages/babel-helper-simple-access/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ if (!process.env.BABEL_8_BREAKING) {
9797
!path.isCompletionRecord()
9898
) {
9999
// ++i => (i += 1);
100-
const operator = path.node.operator == "++" ? "+=" : "-=";
100+
const operator = path.node.operator === "++" ? "+=" : "-=";
101101
path.replaceWith(
102102
assignmentExpression(operator, arg.node, numericLiteral(1)),
103103
);

packages/babel-helper-validator-identifier/scripts/generate-identifier-regex.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let last = -1;
1313
const cont = require(
1414
"@unicode/unicode-" + version + "/Binary_Property/ID_Continue/code-points.js"
1515
).filter(function (ch) {
16-
return ch > 0x7f && search(start, ch, last + 1) == -1;
16+
return ch > 0x7f && search(start, ch, last + 1) === -1;
1717
});
1818

1919
function search(arr, ch, starting) {
@@ -40,13 +40,13 @@ function generate(chars) {
4040
for (let i = 0, at = 0x10000; i < chars.length; i++) {
4141
const from = chars[i];
4242
let to = from;
43-
while (i < chars.length - 1 && chars[i + 1] == to + 1) {
43+
while (i < chars.length - 1 && chars[i + 1] === to + 1) {
4444
i++;
4545
to++;
4646
}
4747
if (to <= 0xffff) {
48-
if (from == to) re += esc(from);
49-
else if (from + 1 == to) re += esc(from) + esc(to);
48+
if (from === to) re += esc(from);
49+
else if (from + 1 === to) re += esc(from) + esc(to);
5050
else re += esc(from) + "-" + esc(to);
5151
} else {
5252
astral.push(from - at, to - from);

packages/babel-helpers/src/helpers/applyDecs2311.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,10 @@ export default /* @no-mangle */ function applyDecs2311(
523523
var kind = decInfo[1];
524524
var kindOnly: PROP_KIND = kind & PROP_KIND.KIND_MASK;
525525
if (
526-
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
526+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison, eqeqeq
527527
(kind & PROP_KIND.STATIC) == isStatic &&
528528
// @ts-expect-error comparing a boolean with 0 | 1
529+
// eslint-disable-next-line eqeqeq
529530
!kindOnly == isField
530531
) {
531532
var name = decInfo[2];

packages/babel-highlight/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ if (process.env.BABEL_8_BREAKING) {
189189

190190
if (
191191
JSX_TAG.test(token.value) &&
192-
(text[offset - 1] === "<" || text.slice(offset - 2, offset) == "</")
192+
(text[offset - 1] === "<" || text.slice(offset - 2, offset) === "</")
193193
) {
194194
return "jsxIdentifier";
195195
}

packages/babel-parser/src/parser/comments.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ export default class CommentsParser extends BaseParser {
103103
addComment(comment: Comment): void {
104104
if (this.filename) comment.loc.filename = this.filename;
105105
const { commentsLen } = this.state;
106-
if (this.comments.length != commentsLen) this.comments.length = commentsLen;
106+
if (this.comments.length !== commentsLen) {
107+
this.comments.length = commentsLen;
108+
}
107109
this.comments.push(comment);
108110
this.state.commentsLen++;
109111
}

packages/babel-parser/src/plugins/jsx/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export default (superClass: typeof Parser) =>
221221
while (
222222
count++ < 10 &&
223223
this.state.pos < this.length &&
224-
!(semi = this.codePointAtPos(this.state.pos) == charCodes.semicolon)
224+
!(semi = this.codePointAtPos(this.state.pos) === charCodes.semicolon)
225225
) {
226226
++this.state.pos;
227227
}

packages/babel-parser/src/plugins/typescript/scope.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class TypeScriptScopeHandler extends ScopeHandler<TypeScriptScope
3636
}
3737

3838
enter(flags: ScopeFlag): void {
39-
if (flags == ScopeFlag.TS_MODULE) {
39+
if (flags === ScopeFlag.TS_MODULE) {
4040
this.importsStack.push(new Set());
4141
}
4242

@@ -46,7 +46,7 @@ export default class TypeScriptScopeHandler extends ScopeHandler<TypeScriptScope
4646
exit() {
4747
const flags = super.exit();
4848

49-
if (flags == ScopeFlag.TS_MODULE) {
49+
if (flags === ScopeFlag.TS_MODULE) {
5050
this.importsStack.pop();
5151
}
5252

packages/babel-plugin-transform-classes/src/transformClass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ export default function transformClass(
478478
});
479479

480480
if (
481-
maxGuaranteedSuperBeforeIndex != -1 &&
481+
maxGuaranteedSuperBeforeIndex !== -1 &&
482482
thisIndex > maxGuaranteedSuperBeforeIndex
483483
) {
484484
thisPath.replaceWith(thisRef());

packages/babel-traverse/src/path/evaluation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ function _evaluate(path: NodePath, state: State): any {
397397
case "==":
398398
return left == right; // eslint-disable-line eqeqeq
399399
case "!=":
400-
return left != right;
400+
return left != right; // eslint-disable-line eqeqeq
401401
case "===":
402402
return left === right;
403403
case "!==":

scripts/pack-script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function pack(inputPath, outputPath, dynamicRequireTargets) {
2222
.update(readFileSync(inputPath, "utf8"))
2323
.digest("hex");
2424

25-
if (process.argv[2] == "--auto") {
25+
if (process.argv[2] === "--auto") {
2626
if (readFileSync(outputPath, "utf8").includes(hash)) {
2727
return;
2828
}

0 commit comments

Comments
 (0)