Skip to content

Commit 39891da

Browse files
authored
[eslint] Enable unused argument linting within the JS compiler. NFC (#23494)
Also, remove the explicit `'no-undef'` specifier since we now get that as part of `js.configs.recommended` above. Also, remove `vars: 'all'` which is the default.
1 parent 8838d22 commit 39891da

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

eslint.config.mjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,8 @@ export default [{
8989
files: ['**/*.mjs'],
9090

9191
rules: {
92-
'no-undef': 'error',
9392
'no-unused-vars': ['error', {
94-
vars: 'all',
95-
args: 'none',
96-
ignoreRestSiblings: false,
93+
argsIgnorePattern: '^_',
9794
destructuredArrayIgnorePattern: '^_',
9895
}],
9996
},

src/jsifier.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function resolveAlias(symbol) {
112112
return symbol;
113113
}
114114

115-
function getTransitiveDeps(symbol, debug) {
115+
function getTransitiveDeps(symbol) {
116116
// TODO(sbc): Use some kind of cache to avoid quadratic behaviour here.
117117
const transitiveDeps = new Set();
118118
const seen = new Set();

src/modules.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ if (!BOOTSTRAPPING_STRUCT_INFO) {
334334
// Use proxy objects for C_DEFINES and C_STRUCTS so that we can give useful
335335
// error messages.
336336
const C_STRUCTS = new Proxy(structs, {
337-
get(target, prop, receiver) {
337+
get(target, prop) {
338338
if (!(prop in target)) {
339339
throw new Error(
340340
`Missing C struct ${prop}! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py (then run a second time with --wasm64)`,
@@ -345,7 +345,7 @@ const C_STRUCTS = new Proxy(structs, {
345345
});
346346

347347
const C_DEFINES = new Proxy(defines, {
348-
get(target, prop, receiver) {
348+
get(target, prop) {
349349
if (!(prop in target)) {
350350
throw new Error(
351351
`Missing C define ${prop}! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py (then run a second time with --wasm64)`,

src/parseTools.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ no matching #endif found (${showStack.length$}' unmatched preprocessing directiv
214214
}
215215

216216
// Returns true if ident is a niceIdent (see toNiceIdent). Also allow () and spaces.
217-
function isNiceIdent(ident, loose) {
217+
function isNiceIdent(ident) {
218218
return /^\(?[$_]+[\w$_\d ]*\)?$/.test(ident);
219219
}
220220

@@ -970,7 +970,7 @@ function from64(x) {
970970

971971
// Like from64 above but generate an expression instead of an assignment
972972
// statement.
973-
function from64Expr(x, assign = true) {
973+
function from64Expr(x) {
974974
if (!MEMORY64) return x;
975975
return `Number(${x})`;
976976
}

tools/acorn-optimizer.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ function JSDCE(ast, aggressive) {
289289
}
290290
function cleanUp(ast, names) {
291291
recursiveWalk(ast, {
292-
VariableDeclaration(node, c) {
292+
VariableDeclaration(node, _c) {
293293
const old = node.declarations;
294294
let removedHere = 0;
295295
node.declarations = node.declarations.filter((node) => {
@@ -315,15 +315,15 @@ function JSDCE(ast, aggressive) {
315315
node.oldDeclarations = old;
316316
}
317317
},
318-
ExpressionStatement(node, c) {
318+
ExpressionStatement(node, _c) {
319319
if (aggressive && !hasSideEffects(node)) {
320320
if (!isNull(node.expression) && !isUseStrict(node.expression)) {
321321
convertToNullStatement(node);
322322
removed++;
323323
}
324324
}
325325
},
326-
FunctionDeclaration(node, c) {
326+
FunctionDeclaration(node, _c) {
327327
if (Object.prototype.hasOwnProperty.call(names, node.id.name)) {
328328
removed++;
329329
emptyOut(node);
@@ -436,7 +436,7 @@ function JSDCE(ast, aggressive) {
436436
ArrowFunctionExpression(node, c) {
437437
handleFunction(node, c);
438438
},
439-
Identifier(node, c) {
439+
Identifier(node, _c) {
440440
const name = node.name;
441441
ensureData(scopes[scopes.length - 1], name).use = 1;
442442
},
@@ -1678,7 +1678,7 @@ function minifyLocals(ast) {
16781678
localNames.add(param.name);
16791679
}
16801680
simpleWalk(fun, {
1681-
VariableDeclaration(node, c) {
1681+
VariableDeclaration(node, _c) {
16821682
for (const dec of node.declarations) {
16831683
localNames.add(dec.id.name);
16841684
}
@@ -1704,7 +1704,7 @@ function minifyLocals(ast) {
17041704
// Don't actually minify them yet as that might interfere with local
17051705
// variable names; just mark them as used, and what their new name will be.
17061706
simpleWalk(fun, {
1707-
Identifier(node, c) {
1707+
Identifier(node, _c) {
17081708
const name = node.name;
17091709
if (!isLocalName(name)) {
17101710
const minified = extraInfo.globals[name];
@@ -1714,7 +1714,7 @@ function minifyLocals(ast) {
17141714
}
17151715
}
17161716
},
1717-
CallExpression(node, c) {
1717+
CallExpression(node, _c) {
17181718
// We should never call a local name, as in asm.js-style code our
17191719
// locals are just numbers, not functions; functions are all declared
17201720
// in the outer scope. If a local is called, that is a bug.
@@ -1775,12 +1775,12 @@ function minifyLocals(ast) {
17751775
node.label.name = labelNames.get(node.label.name);
17761776
c(node.body);
17771777
},
1778-
BreakStatement(node, c) {
1778+
BreakStatement(node, _c) {
17791779
if (node.label) {
17801780
node.label.name = labelNames.get(node.label.name);
17811781
}
17821782
},
1783-
ContinueStatement(node, c) {
1783+
ContinueStatement(node, _c) {
17841784
if (node.label) {
17851785
node.label.name = labelNames.get(node.label.name);
17861786
}

0 commit comments

Comments
 (0)