Skip to content

Commit 5aaa8c3

Browse files
aduh95juanarbol
authored andcommitted
tools: enforce use of trailing commas in tools/
PR-URL: #45889 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent a749ced commit 5aaa8c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+128
-121
lines changed

.eslintrc.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module.exports = {
6868
files: ['**/*.md/*.cjs', '**/*.md/*.js'],
6969
parserOptions: {
7070
sourceType: 'script',
71-
ecmaFeatures: { impliedStrict: true }
71+
ecmaFeatures: { impliedStrict: true },
7272
},
7373
rules: { strict: 'off' },
7474
},
@@ -103,11 +103,11 @@ module.exports = {
103103
},
104104
{
105105
name: 'Buffer',
106-
message: 'Import Buffer instead of using the global'
106+
message: 'Import Buffer instead of using the global',
107107
},
108108
{
109109
name: 'process',
110-
message: 'Import process instead of using the global'
110+
message: 'Import process instead of using the global',
111111
},
112112
] },
113113
},
@@ -134,13 +134,7 @@ module.exports = {
134134
ignorePattern: '.*',
135135
},
136136
}],
137-
'comma-dangle': ['error', {
138-
arrays: 'always-multiline',
139-
exports: 'only-multiline',
140-
functions: 'only-multiline',
141-
imports: 'only-multiline',
142-
objects: 'only-multiline',
143-
}],
137+
'comma-dangle': ['error', 'always-multiline'],
144138
'comma-spacing': 'error',
145139
'comma-style': 'error',
146140
'computed-property-spacing': 'error',

benchmark/.eslintrc.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ env:
55
es6: true
66

77
rules:
8+
comma-dangle: [error, {
9+
arrays: always-multiline,
10+
exports: only-multiline,
11+
functions: only-multiline,
12+
imports: only-multiline,
13+
objects: only-multiline,
14+
}]
815
prefer-arrow-callback: error

doc/.eslintrc.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ rules:
1515

1616
# Stylistic Issues
1717
no-multiple-empty-lines: [error, {max: 1, maxEOF: 0, maxBOF: 0}]
18-
comma-dangle: [error, always-multiline]

lib/.eslintrc.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ env:
22
es6: true
33

44
rules:
5+
comma-dangle: [error, {
6+
arrays: always-multiline,
7+
exports: only-multiline,
8+
functions: only-multiline,
9+
imports: only-multiline,
10+
objects: only-multiline,
11+
}]
512
prefer-object-spread: error
613
no-buffer-constructor: error
714
no-mixed-operators:

tools/build-addons.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async function buildAddon(dir) {
3131
await execFile(process.execPath, [nodeGyp, 'rebuild', `--directory=${dir}`],
3232
{
3333
stdio: 'inherit',
34-
env: { ...process.env, MAKEFLAGS: '-j1' }
34+
env: { ...process.env, MAKEFLAGS: '-j1' },
3535
});
3636

3737
// We buffer the output and print it out once the process is done in order

tools/doc/addon-verify.mjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ tree.children.forEach((node) => {
3838

3939
await Promise.all(
4040
Object.keys(addons).flatMap(
41-
(header) => verifyFiles(addons[header].files, header)
41+
(header) => verifyFiles(addons[header].files, header),
4242
));
4343

4444
function verifyFiles(files, blockName) {
@@ -82,8 +82,8 @@ ${files[name].replace(
8282
sources: files.map(({ name }) => name),
8383
includes: ['../common.gypi'],
8484
},
85-
]
86-
})
85+
],
86+
}),
8787
});
8888

8989
const dirCreation = mkdir(dir);

tools/doc/allhtml.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ all = all.slice(0, apiStart.index + apiStart[0].length)
9696
'\n</head>',
9797
buildCSSForFlavoredJS(new Set(Array.from(
9898
apicontent.matchAll(/(?<=<pre class="with-)\d+(?=-chars">)/g),
99-
(x) => Number(x[0])
100-
))) + '\n</head>'
99+
(x) => Number(x[0]),
100+
))) + '\n</head>',
101101
) +
102102
apicontent +
103103
all.slice(apiEnd);

tools/doc/alljson.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const results = {
1818
modules: [],
1919
classes: [],
2020
globals: [],
21-
methods: []
21+
methods: [],
2222
};
2323

2424
// Identify files that should be skipped. As files are processed, they
@@ -33,7 +33,7 @@ for (const link of toc.match(/<a.*?>/g)) {
3333
if (!jsonFiles.includes(json) || seen.has(json)) continue;
3434
const data = JSON.parse(
3535
fs.readFileSync(new URL(`./${json}`, source), 'utf8')
36-
.replace(/<a href=\\"#/g, `<a href=\\"${href}#`)
36+
.replace(/<a href=\\"#/g, `<a href=\\"${href}#`),
3737
);
3838

3939
for (const property in data) {

tools/doc/apilinks.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function execSync(command) {
2727
try {
2828
return child_process.execSync(
2929
command,
30-
{ stdio: ['ignore', null, 'ignore'] }
30+
{ stdio: ['ignore', null, 'ignore'] },
3131
).toString().trim();
3232
} catch {
3333
return '';

tools/doc/deprecationCodes.mjs

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const testHeading = (headingNode, expectedDeprecationCode) => {
2727
assert.strictEqual(
2828
headingNode?.children[0]?.value.substring(0, 9),
2929
`${expectedDeprecationCode}: `,
30-
'Ill-formed or out-of-order deprecation code.'
30+
'Ill-formed or out-of-order deprecation code.',
3131
);
3232
} catch (e) {
3333
throw addMarkdownPathToErrorStack(e, headingNode);
@@ -39,7 +39,7 @@ const testYAMLComment = (commentNode) => {
3939
assert.match(
4040
commentNode?.value?.substring(0, 21),
4141
/^<!-- YAML\r?\nchanges:\r?\n/,
42-
'Missing or ill-formed YAML comment.'
42+
'Missing or ill-formed YAML comment.',
4343
);
4444
} catch (e) {
4545
throw addMarkdownPathToErrorStack(e, commentNode);
@@ -51,7 +51,7 @@ const testDeprecationType = (paragraphNode) => {
5151
assert.strictEqual(
5252
paragraphNode?.children[0]?.value?.substring(0, 6),
5353
'Type: ',
54-
'Missing deprecation type.'
54+
'Missing deprecation type.',
5555
);
5656
} catch (e) {
5757
throw addMarkdownPathToErrorStack(e, paragraphNode);
@@ -74,7 +74,7 @@ for (let i = 0; i < tree.children.length; i++) {
7474
assert.strictEqual(
7575
deprecationCodeAsText,
7676
expectedDeprecationCode,
77-
'Deprecation codes are not ordered correctly.'
77+
'Deprecation codes are not ordered correctly.',
7878
);
7979
} catch (e) {
8080
throw addMarkdownPathToErrorStack(e, node);

tools/doc/html.mjs

+4-4
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export function preprocessElements({ filename }) {
220220
} else if (node.type === 'code') {
221221
if (!node.lang) {
222222
console.warn(
223-
`No language set in ${filename}, line ${node.position.start.line}`
223+
`No language set in ${filename}, line ${node.position.start.line}`,
224224
);
225225
}
226226
const className = isJSFlavorSnippet(node) ?
@@ -302,7 +302,7 @@ export function preprocessElements({ filename }) {
302302
(noLinking ? '' :
303303
'<a href="documentation.html#stability-index">') +
304304
`${prefix} ${number}${noLinking ? '' : '</a>'}`
305-
.replace(/\n/g, ' ')
305+
.replace(/\n/g, ' '),
306306
});
307307

308308
// Remove prefix and number from text
@@ -408,7 +408,7 @@ export function buildToc({ filename, apilinks }) {
408408

409409
if (node.depth - depth > 1) {
410410
throw new Error(
411-
`Inappropriate heading level:\n${JSON.stringify(node)}`
411+
`Inappropriate heading level:\n${JSON.stringify(node)}`,
412412
);
413413
}
414414

@@ -543,7 +543,7 @@ function gtocPicker(id) {
543543

544544
// Highlight the current module and add a link to the index
545545
const gtoc = gtocHTML.replace(
546-
`class="nav-${id}"`, `class="nav-${id} active"`
546+
`class="nav-${id}"`, `class="nav-${id} active"`,
547547
).replace('</ul>', `
548548
<li>
549549
<a href="index.html">Index</a>

tools/doc/json.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ function parseSignature(text, sig) {
349349
throw new Error(
350350
`Invalid param "${sigParam}"\n` +
351351
` > ${JSON.stringify(listParam)}\n` +
352-
` > ${text}`
352+
` > ${text}`,
353353
);
354354
}
355355
}
@@ -376,7 +376,7 @@ function parseListItem(item, file) {
376376

377377
current.textRaw = item.children.filter((node) => node.type !== 'list')
378378
.map((node) => (
379-
file.value.slice(node.position.start.offset, node.position.end.offset))
379+
file.value.slice(node.position.start.offset, node.position.end.offset)),
380380
)
381381
.join('').replace(/\s+/g, ' ').replace(/<!--.*?-->/sg, '');
382382
let text = current.textRaw;

tools/doc/markdown.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function replaceLinks({ filename, linksMapper }) {
1010
if (node.url) {
1111
node.url = node.url.replace(
1212
referenceToLocalMdFile,
13-
(_, filename, hash) => `${filename}.html${hash || ''}`
13+
(_, filename, hash) => `${filename}.html${hash || ''}`,
1414
);
1515
}
1616
});

tools/doc/type-parser.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const jsPrimitives = {
88
number: 'Number',
99
string: 'String',
1010
symbol: 'Symbol',
11-
undefined: 'Undefined'
11+
undefined: 'Undefined',
1212
};
1313

1414
const jsGlobalObjectsUrl = `${jsDocPrefix}Reference/Global_Objects/`;
@@ -301,7 +301,7 @@ export function toLink(typeInput) {
301301
} else {
302302
throw new Error(
303303
`Unrecognized type: '${typeTextFull}'.\n` +
304-
`Please, edit the type or update '${import.meta.url}'.`
304+
`Please, edit the type or update '${import.meta.url}'.`,
305305
);
306306
}
307307
} else {

tools/eslint-rules/alphabetize-errors.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626
const message = [prefix, prev, opStr, curr].join('');
2727
context.report({ node, message });
2828
}
29-
}
29+
},
3030
};
31-
}
31+
},
3232
};

tools/eslint-rules/async-iife-no-unused-result.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const message =
1313

1414
module.exports = {
1515
meta: {
16-
fixable: 'code'
16+
fixable: 'code',
1717
},
1818
create: function(context) {
1919
let hasCommonModule = false;
@@ -31,10 +31,10 @@ module.exports = {
3131
fix: (fixer) => {
3232
if (hasCommonModule)
3333
return fixer.insertTextAfter(node, '.then(common.mustCall())');
34-
}
34+
},
3535
});
3636
}
37-
}
37+
},
3838
};
39-
}
39+
},
4040
};

tools/eslint-rules/avoid-prototype-pollution.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function createUnsafeStringMethodReport(context, name, lookedUpProperty) {
7474
node,
7575
message: `${name} looks up the ${lookedUpProperty} property on the first argument`,
7676
});
77-
}
77+
},
7878
};
7979
}
8080

@@ -92,7 +92,7 @@ function createUnsafeStringMethodOnRegexReport(context, name, lookedUpProperty)
9292
node,
9393
message: `${name} looks up the ${lookedUpProperty} property of the passed regex, use ${safePrimordialName} directly`,
9494
});
95-
}
95+
},
9696
};
9797
}
9898

@@ -131,7 +131,7 @@ module.exports = {
131131
fixer.replaceTextRange(testRange, 'Exec'),
132132
fixer.insertTextAfter(node, ' !== null'),
133133
];
134-
}
134+
},
135135
}],
136136
});
137137
},

tools/eslint-rules/crypto-check.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = {
7878
if (beforeAllChecks) {
7979
context.report({
8080
node: requireNode,
81-
message: msg
81+
message: msg,
8282
});
8383
}
8484
});
@@ -106,10 +106,10 @@ module.exports = {
106106
commonModuleNode,
107107
'\nif (!common.hasCrypto) {' +
108108
' common.skip("missing crypto");' +
109-
'}'
109+
'}',
110110
);
111111
}
112-
}
112+
},
113113
});
114114
});
115115
}
@@ -118,7 +118,7 @@ module.exports = {
118118
'CallExpression': (node) => testCryptoUsage(node),
119119
'IfStatement:exit': (node) => testIfStatement(node),
120120
'MemberExpression:exit': (node) => testMemberExpression(node),
121-
'Program:exit': () => reportIfMissingCheck()
121+
'Program:exit': () => reportIfMissingCheck(),
122122
};
123-
}
123+
},
124124
};

tools/eslint-rules/documented-errors.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = {
3434
`doc/api/errors.md does not have an anchor for "${code}"`;
3535
context.report({ node, message });
3636
}
37-
}
37+
},
3838
};
39-
}
39+
},
4040
};

tools/eslint-rules/eslint-check.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ module.exports = {
4747
if (commonModuleNode) {
4848
return fixer.insertTextAfter(
4949
commonModuleNode,
50-
'\ncommon.skipIfEslintMissing();'
50+
'\ncommon.skipIfEslintMissing();',
5151
);
5252
}
53-
}
53+
},
5454
});
5555
});
5656
}
@@ -59,7 +59,7 @@ module.exports = {
5959
return {
6060
'CallExpression': (node) => testEslintUsage(context, node),
6161
'MemberExpression': (node) => checkMemberExpression(context, node),
62-
'Program:exit': () => reportIfMissing(context)
62+
'Program:exit': () => reportIfMissing(context),
6363
};
64-
}
64+
},
6565
};

0 commit comments

Comments
 (0)