Skip to content

Commit b4d7032

Browse files
targosmarco-ippolito
authored andcommitted
tools: use stylistic ESLint plugin for formatting
Refs: https://eslint.org/blog/2023/10/deprecating-formatting-rules/ PR-URL: #50714 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 29d2011 commit b4d7032

File tree

1,049 files changed

+14778
-4478
lines changed

Some content is hidden

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

1,049 files changed

+14778
-4478
lines changed

.eslintrc.js

+70-67
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const hacks = [
1919
'eslint-plugin-markdown',
2020
'@babel/eslint-parser',
2121
'@babel/plugin-syntax-import-attributes',
22+
'@stylistic/eslint-plugin-js',
2223
];
2324
Module._findPath = (request, paths, isMain) => {
2425
const r = ModuleFindPath(request, paths, isMain);
@@ -39,7 +40,7 @@ module.exports = {
3940
es2022: true,
4041
},
4142
extends: ['eslint:recommended', 'plugin:jsdoc/recommended'],
42-
plugins: ['jsdoc', 'markdown', 'node-core'],
43+
plugins: ['jsdoc', 'markdown', 'node-core', '@stylistic/js'],
4344
parser: '@babel/eslint-parser',
4445
parserOptions: {
4546
babelOptions: {
@@ -133,11 +134,7 @@ module.exports = {
133134
// https://eslint.org/docs/rules/
134135
'accessor-pairs': 'error',
135136
'array-callback-return': 'error',
136-
'arrow-parens': 'error',
137-
'arrow-spacing': 'error',
138137
'block-scoped-var': 'error',
139-
'block-spacing': 'error',
140-
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
141138
'capitalized-comments': ['error', 'always', {
142139
line: {
143140
// Ignore all lines that have less characters than 20 and all lines that
@@ -150,49 +147,17 @@ module.exports = {
150147
ignorePattern: '.*',
151148
},
152149
}],
153-
'comma-dangle': ['error', 'always-multiline'],
154-
'comma-spacing': 'error',
155-
'comma-style': 'error',
156-
'computed-property-spacing': 'error',
157150
'default-case-last': 'error',
158-
'dot-location': ['error', 'property'],
159151
'dot-notation': 'error',
160-
'eol-last': 'error',
161152
'eqeqeq': ['error', 'smart'],
162-
'func-call-spacing': 'error',
163153
'func-name-matching': 'error',
164154
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
165-
'indent': ['error', 2, {
166-
ArrayExpression: 'first',
167-
CallExpression: { arguments: 'first' },
168-
FunctionDeclaration: { parameters: 'first' },
169-
FunctionExpression: { parameters: 'first' },
170-
MemberExpression: 'off',
171-
ObjectExpression: 'first',
172-
SwitchCase: 1,
173-
}],
174-
'key-spacing': 'error',
175-
'keyword-spacing': 'error',
176-
'linebreak-style': 'error',
177-
'max-len': ['error', {
178-
code: 120,
179-
ignorePattern: '^// Flags:',
180-
ignoreRegExpLiterals: true,
181-
ignoreTemplateLiterals: true,
182-
ignoreUrls: true,
183-
tabWidth: 2,
184-
}],
185-
'new-parens': 'error',
186-
'no-confusing-arrow': 'error',
187155
'no-constant-condition': ['error', { checkLoops: false }],
188156
'no-constructor-return': 'error',
189157
'no-duplicate-imports': 'error',
190158
'no-else-return': 'error',
191-
'no-extra-parens': ['error', 'functions'],
192159
'no-lonely-if': 'error',
193160
'no-mixed-requires': 'error',
194-
'no-multi-spaces': ['error', { ignoreEOLComments: true }],
195-
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0, maxBOF: 0 }],
196161
'no-new-require': 'error',
197162
'no-path-concat': 'error',
198163
'no-proto': 'error',
@@ -257,10 +222,8 @@ module.exports = {
257222
},
258223
],
259224
'no-self-compare': 'error',
260-
'no-tabs': 'error',
261225
'no-template-curly-in-string': 'error',
262226
'no-throw-literal': 'error',
263-
'no-trailing-spaces': 'error',
264227
'no-undef': ['error', { typeof: true }],
265228
'no-undef-init': 'error',
266229
'no-unused-expressions': ['error', { allowShortCircuit: true }],
@@ -276,39 +239,11 @@ module.exports = {
276239
'no-useless-return': 'error',
277240
'no-var': 'error',
278241
'no-void': 'error',
279-
'no-whitespace-before-property': 'error',
280-
'object-curly-newline': 'error',
281-
'object-curly-spacing': ['error', 'always'],
282242
'one-var': ['error', { initialized: 'never' }],
283-
'one-var-declaration-per-line': 'error',
284-
'operator-linebreak': ['error', 'after'],
285-
'padding-line-between-statements': [
286-
'error',
287-
{ blankLine: 'always', prev: 'function', next: 'function' },
288-
],
289243
'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
290244
'prefer-object-has-own': 'error',
291-
'quotes': ['error', 'single', { avoidEscape: true }],
292-
'quote-props': ['error', 'consistent'],
293-
'rest-spread-spacing': 'error',
294-
'semi': 'error',
295-
'semi-spacing': 'error',
296-
'space-before-blocks': ['error', 'always'],
297-
'space-before-function-paren': ['error', {
298-
anonymous: 'never',
299-
named: 'never',
300-
asyncArrow: 'always',
301-
}],
302-
'space-in-parens': 'error',
303-
'space-infix-ops': 'error',
304-
'space-unary-ops': 'error',
305-
'spaced-comment': ['error', 'always', {
306-
'block': { 'balanced': true },
307-
'exceptions': ['-'],
308-
}],
309245
'strict': ['error', 'global'],
310246
'symbol-description': 'error',
311-
'template-curly-spacing': 'error',
312247
'unicode-bom': 'error',
313248
'valid-typeof': ['error', { requireStringLiterals: true }],
314249

@@ -327,6 +262,74 @@ module.exports = {
327262
'jsdoc/check-tag-names': 'off',
328263
'jsdoc/require-returns': 'off',
329264

265+
// Stylistic rules
266+
'@stylistic/js/arrow-parens': 'error',
267+
'@stylistic/js/arrow-spacing': 'error',
268+
'@stylistic/js/block-spacing': 'error',
269+
'@stylistic/js/brace-style': ['error', '1tbs', { allowSingleLine: true }],
270+
'@stylistic/js/comma-dangle': ['error', 'always-multiline'],
271+
'@stylistic/js/comma-spacing': 'error',
272+
'@stylistic/js/comma-style': 'error',
273+
'@stylistic/js/computed-property-spacing': 'error',
274+
'@stylistic/js/dot-location': ['error', 'property'],
275+
'@stylistic/js/eol-last': 'error',
276+
'@stylistic/js/func-call-spacing': 'error',
277+
'@stylistic/js/indent': ['error', 2, {
278+
ArrayExpression: 'first',
279+
CallExpression: { arguments: 'first' },
280+
FunctionDeclaration: { parameters: 'first' },
281+
FunctionExpression: { parameters: 'first' },
282+
MemberExpression: 'off',
283+
ObjectExpression: 'first',
284+
SwitchCase: 1,
285+
}],
286+
'@stylistic/js/key-spacing': 'error',
287+
'@stylistic/js/keyword-spacing': 'error',
288+
'@stylistic/js/linebreak-style': 'error',
289+
'@stylistic/js/max-len': ['error', {
290+
code: 120,
291+
ignorePattern: '^// Flags:',
292+
ignoreRegExpLiterals: true,
293+
ignoreTemplateLiterals: true,
294+
ignoreUrls: true,
295+
tabWidth: 2,
296+
}],
297+
'@stylistic/js/new-parens': 'error',
298+
'@stylistic/js/no-confusing-arrow': 'error',
299+
'@stylistic/js/no-extra-parens': ['error', 'functions'],
300+
'@stylistic/js/no-multi-spaces': ['error', { ignoreEOLComments: true }],
301+
'@stylistic/js/no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0, maxBOF: 0 }],
302+
'@stylistic/js/no-tabs': 'error',
303+
'@stylistic/js/no-trailing-spaces': 'error',
304+
'@stylistic/js/no-whitespace-before-property': 'error',
305+
'@stylistic/js/object-curly-newline': 'error',
306+
'@stylistic/js/object-curly-spacing': ['error', 'always'],
307+
'@stylistic/js/one-var-declaration-per-line': 'error',
308+
'@stylistic/js/operator-linebreak': ['error', 'after'],
309+
'@stylistic/js/padding-line-between-statements': [
310+
'error',
311+
{ blankLine: 'always', prev: 'function', next: 'function' },
312+
],
313+
'@stylistic/js/quotes': ['error', 'single', { avoidEscape: true }],
314+
'@stylistic/js/quote-props': ['error', 'consistent'],
315+
'@stylistic/js/rest-spread-spacing': 'error',
316+
'@stylistic/js/semi': 'error',
317+
'@stylistic/js/semi-spacing': 'error',
318+
'@stylistic/js/space-before-blocks': ['error', 'always'],
319+
'@stylistic/js/space-before-function-paren': ['error', {
320+
anonymous: 'never',
321+
named: 'never',
322+
asyncArrow: 'always',
323+
}],
324+
'@stylistic/js/space-in-parens': 'error',
325+
'@stylistic/js/space-infix-ops': 'error',
326+
'@stylistic/js/space-unary-ops': 'error',
327+
'@stylistic/js/spaced-comment': ['error', 'always', {
328+
'block': { 'balanced': true },
329+
'exceptions': ['-'],
330+
}],
331+
'@stylistic/js/template-curly-spacing': 'error',
332+
330333
// Custom rules from eslint-plugin-node-core
331334
'node-core/no-unescaped-regexp-dot': 'error',
332335
'node-core/no-duplicate-requires': 'error',

doc/.eslintrc.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ rules:
1313
prefer-rest-params: error
1414
prefer-template: error
1515

16-
# Stylistic Issues
17-
no-multiple-empty-lines: [error, {max: 1, maxEOF: 0, maxBOF: 0}]
16+
# Stylistic rules
17+
'@stylistic/js/no-multiple-empty-lines': [error, {max: 1, maxEOF: 0, maxBOF: 0}]

doc/api/dns.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Returns an array of IP address strings, formatted according to [RFC 5952][],
163163
that are currently configured for DNS resolution. A string will include a port
164164
section if a custom port is used.
165165

166-
<!-- eslint-disable semi-->
166+
<!-- eslint-disable @stylistic/js/semi-->
167167

168168
```js
169169
[
@@ -468,7 +468,7 @@ will be present on the object:
468468

469469
Here is an example of the `ret` object passed to the callback:
470470

471-
<!-- eslint-disable semi -->
471+
<!-- eslint-disable @stylistic/js/semi -->
472472

473473
```js
474474
[ { type: 'A', address: '127.0.0.1', ttl: 299 },
@@ -932,7 +932,7 @@ Returns an array of IP address strings, formatted according to [RFC 5952][],
932932
that are currently configured for DNS resolution. A string will include a port
933933
section if a custom port is used.
934934

935-
<!-- eslint-disable semi-->
935+
<!-- eslint-disable @stylistic/js/semi-->
936936

937937
```js
938938
[
@@ -1133,7 +1133,7 @@ present on the object:
11331133

11341134
Here is an example of the result object:
11351135

1136-
<!-- eslint-disable semi -->
1136+
<!-- eslint-disable @stylistic/js/semi -->
11371137

11381138
```js
11391139
[ { type: 'A', address: '127.0.0.1', ttl: 299 },

doc/api/http.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ property, which is an array of `[key, value, key2, value2, ...]`. For
3838
example, the previous message header object might have a `rawHeaders`
3939
list like the following:
4040

41-
<!-- eslint-disable semi -->
41+
<!-- eslint-disable @stylistic/js/semi -->
4242

4343
```js
4444
[ 'ConTent-Length', '123456',

doc/api/http2.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3585,7 +3585,7 @@ Accept: text/plain
35853585

35863586
Then `request.url` will be:
35873587

3588-
<!-- eslint-disable semi -->
3588+
<!-- eslint-disable @stylistic/js/semi -->
35893589

35903590
```js
35913591
'/status?name=ryan'

doc/api/os.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ The properties included on each object include:
9191
* `idle` {number} The number of milliseconds the CPU has spent in idle mode.
9292
* `irq` {number} The number of milliseconds the CPU has spent in irq mode.
9393

94-
<!-- eslint-disable semi -->
94+
<!-- eslint-disable @stylistic/js/semi -->
9595

9696
```js
9797
[

doc/api/process.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ Results in `process.execArgv`:
17221722
17231723
And `process.argv`:
17241724
1725-
<!-- eslint-disable semi -->
1725+
<!-- eslint-disable @stylistic/js/semi -->
17261726
17271727
```js
17281728
['/usr/local/bin/node', 'script.js', '--version']
@@ -1742,7 +1742,7 @@ added: v0.1.100
17421742
The `process.execPath` property returns the absolute pathname of the executable
17431743
that started the Node.js process. Symbolic links, if any, are resolved.
17441744
1745-
<!-- eslint-disable semi -->
1745+
<!-- eslint-disable @stylistic/js/semi -->
17461746
17471747
```js
17481748
'/usr/local/bin/node'

doc/api/zlib.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ From `zlib/zconf.h`, modified for Node.js usage:
264264

265265
The memory requirements for deflate are (in bytes):
266266

267-
<!-- eslint-disable semi -->
267+
<!-- eslint-disable @stylistic/js/semi -->
268268

269269
```js
270270
(1 << (windowBits + 2)) + (1 << (memLevel + 9))

lib/.eslintrc.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ env:
44
rules:
55
prefer-object-spread: error
66
no-buffer-constructor: error
7-
no-mixed-operators:
8-
- error
9-
- groups: [['&&', '||']]
107
no-restricted-syntax:
118
# Config copied from .eslintrc.js
129
- error
@@ -179,6 +176,12 @@ rules:
179176
- error
180177
- name: url
181178
message: Require `internal/url` instead of `url`.
179+
180+
# Stylistic rules
181+
'@stylistic/js/no-mixed-operators':
182+
- error
183+
- groups: [['&&', '||']]
184+
182185
# Custom rules in tools/eslint-rules
183186
node-core/avoid-prototype-pollution: error
184187
node-core/lowercase-name-for-primitive: error

test/.eslintrc.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ rules:
88
multiline-comment-style: [error, separate-lines]
99
prefer-const: error
1010
symbol-description: off
11-
comma-dangle: [error, always-multiline]
1211

1312
no-restricted-syntax:
1413
# Config copied from .eslintrc.js
@@ -54,6 +53,9 @@ rules:
5453
- selector: Identifier[name='webcrypto']
5554
message: Use `globalThis.crypto`.
5655

56+
# Stylistic rules
57+
'@stylistic/js/comma-dangle': [error, always-multiline]
58+
5759
# Custom rules in tools/eslint-rules
5860
node-core/prefer-assert-iferror: error
5961
node-core/prefer-assert-methods: error
@@ -83,7 +85,7 @@ overrides:
8385
- sequential/*.js
8486
- sequential/*.mjs
8587
rules:
86-
comma-dangle: [error, {
88+
'@stylistic/js/comma-dangle': [error, {
8789
arrays: always-multiline,
8890
exports: always-multiline,
8991
functions: only-multiline,

test/common/dns.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function readDomainFromPacket(buffer, offset) {
4040
}
4141
// Pointer to another part of the packet.
4242
assert.strictEqual(length & 0xC0, 0xC0);
43-
// eslint-disable-next-line space-infix-ops, space-unary-ops
43+
// eslint-disable-next-line @stylistic/js/space-infix-ops, @stylistic/js/space-unary-ops
4444
const pointeeOffset = buffer.readUInt16BE(offset) &~ 0xC000;
4545
return {
4646
nread: 2,

0 commit comments

Comments
 (0)