GeezerVison is showing github.com — test: add lint rule to enforce trailing commas · nodejs/node@fac1f1b
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: test/.eslintrc.yaml +28Lines changed: 28 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | multiline-comment-style: [error, separate-lines] | 9 | 9 | prefer-const: error | 10 | 10 | symbol-description: off | | 11 | + comma-dangle: [error, always-multiline] | 11 | 12 |
| 12 | 13 | no-restricted-syntax: | 13 | 14 | # Config copied from .eslintrc.js | @@ -68,3 +69,30 @@ rules: | 68 | 69 | # Global scoped methods and vars | 69 | 70 | globals: | 70 | 71 | WebAssembly: false | | 72 | + | | 73 | +overrides: | | 74 | + - files: | | 75 | + - addons/*/*.js | | 76 | + - async-hooks/*.js | | 77 | + - common/*.js | | 78 | + - es-module/*.js | | 79 | + - es-module/*.mjs | | 80 | + - internet/*.js | | 81 | + - js-native-api/*/*.js | | 82 | + - known_issues/*.js | | 83 | + - message/*.js | | 84 | + - node-api/*/*.js | | 85 | + - parallel/*.js | | 86 | + - parallel/*.mjs | | 87 | + - pseudo-tty/*.js | | 88 | + - pummel/*.js | | 89 | + - sequential/*.js | | 90 | + - sequential/*.mjs | | 91 | + rules: | | 92 | + comma-dangle: [error, { | | 93 | + arrays: always-multiline, | | 94 | + exports: only-multiline, | | 95 | + functions: only-multiline, | | 96 | + imports: only-multiline, | | 97 | + objects: only-multiline, | | 98 | + }] |
Collapse file Copy file name to clipboardExpand all lines: test/common/README.md +4-4Lines changed: 4 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -110,20 +110,20 @@ expectWarning('DeprecationWarning', [ | 110 | 110 |
| 111 | 111 | expectWarning('DeprecationWarning', { | 112 | 112 | DEP0XXX: 'Foobar is deprecated', | 113 | | - DEP0XX2: 'Baz is also deprecated' | | 113 | + DEP0XX2: 'Baz is also deprecated', | 114 | 114 | }); | 115 | 115 |
| 116 | 116 | expectWarning({ | 117 | 117 | DeprecationWarning: { | 118 | 118 | DEP0XXX: 'Foobar is deprecated', | 119 | | - DEP0XX1: 'Baz is also deprecated' | | 119 | + DEP0XX1: 'Baz is also deprecated', | 120 | 120 | }, | 121 | 121 | Warning: [ | 122 | 122 | ['Multiple array entries are fine', 'SpecialWarningCode'], | 123 | 123 | ['No code is also fine'], | 124 | 124 | ], | 125 | 125 | SingleEntry: ['This will also work', 'WarningCode'], | 126 | | - SingleString: 'Single string entries without code will also work' | | 126 | + SingleString: 'Single string entries without code will also work', | 127 | 127 | }); | 128 | 128 | ``` | 129 | 129 |
| @@ -720,7 +720,7 @@ validateSnapshotNodes('TLSWRAP', [ | 720 | 720 | { name: 'enc_out' }, | 721 | 721 | { name: 'enc_in' }, | 722 | 722 | { name: 'TLSWrap' }, | 723 | | - ] | | 723 | + ], | 724 | 724 | }, | 725 | 725 | ]); | 726 | 726 | ``` | |
Collapse file Copy file name to clipboardExpand all lines: test/common/wpt/worker.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,7 +9,7 @@ const resource = new ResourceLoader(workerData.wptPath); | 9 | 9 | global.self = global; | 10 | 10 | global.GLOBAL = { | 11 | 11 | isWindow() { return false; }, | 12 | | - isShadowRealm() { return false; } | | 12 | + isShadowRealm() { return false; }, | 13 | 13 | }; | 14 | 14 | global.require = require; | 15 | 15 |
| @@ -25,7 +25,7 @@ if (workerData.initScript) { | 25 | 25 | } | 26 | 26 |
| 27 | 27 | runInThisContext(workerData.harness.code, { | 28 | | - filename: workerData.harness.filename | | 28 | + filename: workerData.harness.filename, | 29 | 29 | }); | 30 | 30 |
| 31 | 31 | // eslint-disable-next-line no-undef | |
Collapse file Copy file name to clipboardExpand all lines: test/doctool/test-apilinks.mjs +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,7 +23,7 @@ fs.readdirSync(apilinks).forEach((fixture) => { | 23 | 23 | execFileSync( | 24 | 24 | process.execPath, | 25 | 25 | [script, outputPath, input], | 26 | | - { encoding: 'utf-8' } | | 26 | + { encoding: 'utf-8' }, | 27 | 27 | ); | 28 | 28 |
| 29 | 29 | const expectedLinks = JSON.parse(expectedContent); | @@ -38,6 +38,6 @@ fs.readdirSync(apilinks).forEach((fixture) => { | 38 | 38 |
| 39 | 39 | assert.strictEqual( | 40 | 40 | Object.keys(actualLinks).length, 0, | 41 | | - `unexpected links returned ${JSON.stringify(actualLinks)}` | | 41 | + `unexpected links returned ${JSON.stringify(actualLinks)}`, | 42 | 42 | ); | 43 | 43 | }); |
Collapse file Copy file name to clipboardExpand all lines: test/doctool/test-deprecation-codes.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,7 +10,7 @@ const script = path.join( | 10 | 10 | '..', | 11 | 11 | 'tools', | 12 | 12 | 'doc', | 13 | | - 'deprecationCodes.mjs' | | 13 | + 'deprecationCodes.mjs', | 14 | 14 | ); | 15 | 15 |
| 16 | 16 | const mdPath = path.join( | @@ -19,7 +19,7 @@ const mdPath = path.join( | 19 | 19 | '..', | 20 | 20 | 'doc', | 21 | 21 | 'api', | 22 | | - 'deprecations.md' | | 22 | + 'deprecations.md', | 23 | 23 | ); | 24 | 24 |
| 25 | 25 | const cp = spawn(process.execPath, [script, mdPath], { encoding: 'utf-8', stdio: 'inherit' }); | |
Collapse file Copy file name to clipboardExpand all lines: test/doctool/test-doctool-html.mjs +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,8 +23,8 @@ import { | 23 | 23 | const testLinksMapper = { | 24 | 24 | 'foo': { | 25 | 25 | 'command line options': 'cli.html#cli-options', | 26 | | - 'web server': 'example.html' | 27 | | - } | | 26 | + 'web server': 'example.html', | | 27 | + }, | 28 | 28 | }; | 29 | 29 |
| 30 | 30 | function toHTML({ input, filename, nodeVersion, versions }) { | @@ -58,7 +58,7 @@ const testData = [ | 58 | 58 | 'id="foo_static_method_buffer_from_array"></a></h4>' + | 59 | 59 | '<ul><li><code>array</code><a ' + | 60 | 60 | 'href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/' + | 61 | | - 'Reference/Global_Objects/Array" class="type"><Array></a></li></ul>' | | 61 | + 'Reference/Global_Objects/Array" class="type"><Array></a></li></ul>', | 62 | 62 | }, | 63 | 63 | { | 64 | 64 | file: fixtures.path('doc_with_yaml.md'), | @@ -99,7 +99,7 @@ const testData = [ | 99 | 99 | '" id="something">#</a></span>' + | 100 | 100 | '<a aria-hidden="true" class="legacy" id="foo_something"></a></h3>' + | 101 | 101 | '<!-- This is not a metadata comment --> ' + | 102 | | - '<p>Describe <code>Something</code> in more detail here. </p></section>' | | 102 | + '<p>Describe <code>Something</code> in more detail here. </p></section>', | 103 | 103 | }, | 104 | 104 | { | 105 | 105 | file: fixtures.path('sample_document.md'), | @@ -129,7 +129,7 @@ const testData = [ | 129 | 129 | '<h3>See also<span><a class="mark"' + | 130 | 130 | 'href="#see-also" id="see-also">#</a></span><a aria-hidden="true"' + | 131 | 131 | 'class="legacy" id="foo_see_also"></a></h3><p>Check' + | 132 | | - 'out also<a href="https://nodejs.org/">this guide</a></p></section>' | | 132 | + 'out also<a href="https://nodejs.org/">this guide</a></p></section>', | 133 | 133 | }, | 134 | 134 | { | 135 | 135 | file: fixtures.path('document_with_special_heading.md'), | |
Collapse file Copy file name to clipboardExpand all lines: test/doctool/test-doctool-json.mjs +32-32Lines changed: 32 additions & 32 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -41,12 +41,12 @@ const testData = [ | 41 | 41 | desc: '<ol>\n<li>fish</li>\n<li>fish</li>\n</ol>\n' + | 42 | 42 | '<ul>\n<li>Red fish</li>\n<li>Blue fish</li>\n</ul>', | 43 | 43 | type: 'module', | 44 | | - displayName: 'Seussian Rhymes' | | 44 | + displayName: 'Seussian Rhymes', | 45 | 45 | }], | 46 | 46 | type: 'module', | 47 | | - displayName: 'Sample Markdown' | 48 | | - }] | 49 | | - } | | 47 | + displayName: 'Sample Markdown', | | 48 | + }], | | 49 | + }, | 50 | 50 | }, | 51 | 51 | { | 52 | 52 | file: fixtures.path('order_of_end_tags_5873.md'), | @@ -68,18 +68,18 @@ const testData = [ | 68 | 68 | params: [{ | 69 | 69 | textRaw: '`array` {Array}', | 70 | 70 | name: 'array', | 71 | | - type: 'Array' | 72 | | - }] | | 71 | + type: 'Array', | | 72 | + }], | 73 | 73 | }, | 74 | | - ] | | 74 | + ], | 75 | 75 | }], | 76 | 76 | type: 'module', | 77 | | - displayName: 'Subsection' | | 77 | + displayName: 'Subsection', | 78 | 78 | }], | 79 | 79 | type: 'module', | 80 | | - displayName: 'Title' | 81 | | - }] | 82 | | - } | | 80 | + displayName: 'Title', | | 81 | + }], | | 82 | + }, | 83 | 83 | }, | 84 | 84 | { | 85 | 85 | file: fixtures.path('doc_with_yaml.md'), | @@ -96,12 +96,12 @@ const testData = [ | 96 | 96 | name: 'foobar', | 97 | 97 | meta: { | 98 | 98 | added: ['v1.0.0'], | 99 | | - changes: [] | | 99 | + changes: [], | 100 | 100 | }, | 101 | 101 | desc: '<p>Describe <code>Foobar</code> in more detail ' + | 102 | 102 | 'here.</p>', | 103 | 103 | type: 'module', | 104 | | - displayName: 'Foobar' | | 104 | + displayName: 'Foobar', | 105 | 105 | }, | 106 | 106 | { | 107 | 107 | textRaw: 'Foobar II', | @@ -113,40 +113,40 @@ const testData = [ | 113 | 113 | 'pr-url': 'https://github.com/nodejs/node/pull/3276', | 114 | 114 | 'description': 'The `error` parameter can now be ' + | 115 | 115 | 'an arrow function.' }, | 116 | | - ] | | 116 | + ], | 117 | 117 | }, | 118 | 118 | desc: '<p>Describe <code>Foobar II</code> in more detail ' + | 119 | 119 | 'here. fg(1)</p>', | 120 | 120 | type: 'module', | 121 | | - displayName: 'Foobar II' | | 121 | + displayName: 'Foobar II', | 122 | 122 | }, | 123 | 123 | { | 124 | 124 | textRaw: 'Deprecated thingy', | 125 | 125 | name: 'deprecated_thingy', | 126 | 126 | meta: { | 127 | 127 | added: ['v1.0.0'], | 128 | 128 | deprecated: ['v2.0.0'], | 129 | | - changes: [] | | 129 | + changes: [], | 130 | 130 | }, | 131 | 131 | desc: '<p>Describe <code>Deprecated thingy</code> in more ' + | 132 | 132 | 'detail here. fg(1p)</p>', | 133 | 133 | type: 'module', | 134 | | - displayName: 'Deprecated thingy' | | 134 | + displayName: 'Deprecated thingy', | 135 | 135 | }, | 136 | 136 | { | 137 | 137 | textRaw: 'Something', | 138 | 138 | name: 'something', | 139 | 139 | desc: '<!-- This is not a metadata comment -->\n<p>' + | 140 | 140 | 'Describe <code>Something</code> in more detail here.</p>', | 141 | 141 | type: 'module', | 142 | | - displayName: 'Something' | | 142 | + displayName: 'Something', | 143 | 143 | }, | 144 | 144 | ], | 145 | 145 | type: 'module', | 146 | | - displayName: 'Sample Markdown with YAML info' | | 146 | + displayName: 'Sample Markdown with YAML info', | 147 | 147 | }, | 148 | | - ] | 149 | | - } | | 148 | + ], | | 149 | + }, | 150 | 150 | }, | 151 | 151 | { | 152 | 152 | file: fixtures.path('doc_with_backticks_in_headings.md'), | @@ -160,61 +160,61 @@ const testData = [ | 160 | 160 | properties: [ | 161 | 161 | { | 162 | 162 | name: 'fullName', | 163 | | - textRaw: '`Fqhqwhgads.fullName`' | | 163 | + textRaw: '`Fqhqwhgads.fullName`', | 164 | 164 | }, | 165 | 165 | ], | 166 | 166 | classMethods: [ | 167 | 167 | { | 168 | 168 | name: 'again', | 169 | 169 | signatures: [ | 170 | 170 | { | 171 | | - params: [] | | 171 | + params: [], | 172 | 172 | }, | 173 | 173 | ], | 174 | 174 | textRaw: 'Static method: `Fhqwhgads.again()`', | 175 | | - type: 'classMethod' | | 175 | + type: 'classMethod', | 176 | 176 | }, | 177 | 177 | ], | 178 | 178 | classes: [ | 179 | 179 | { | 180 | 180 | textRaw: 'Class: `ComeOn`', | 181 | 181 | type: 'class', | 182 | | - name: 'ComeOn' | | 182 | + name: 'ComeOn', | 183 | 183 | }, | 184 | 184 | ], | 185 | 185 | ctors: [ | 186 | 186 | { | 187 | 187 | name: 'Fhqwhgads', | 188 | 188 | signatures: [ | 189 | 189 | { | 190 | | - params: [] | | 190 | + params: [], | 191 | 191 | }, | 192 | 192 | ], | 193 | 193 | textRaw: 'Constructor: `new Fhqwhgads()`', | 194 | | - type: 'ctor' | | 194 | + type: 'ctor', | 195 | 195 | }, | 196 | 196 | ], | 197 | 197 | methods: [ | 198 | 198 | { | 199 | 199 | textRaw: '`everybody.to(limit)`', | 200 | 200 | type: 'method', | 201 | 201 | name: 'to', | 202 | | - signatures: [{ params: [] }] | | 202 | + signatures: [{ params: [] }], | 203 | 203 | }, | 204 | 204 | ], | 205 | 205 | events: [ | 206 | 206 | { | 207 | 207 | textRaw: "Event: `'FHQWHfest'`", | 208 | 208 | type: 'event', | 209 | 209 | name: 'FHQWHfest', | 210 | | - params: [] | | 210 | + params: [], | 211 | 211 | }, | 212 | 212 | ], | 213 | 213 | type: 'module', | 214 | | - displayName: 'Fhqwhgads' | | 214 | + displayName: 'Fhqwhgads', | 215 | 215 | }, | 216 | | - ] | 217 | | - } | | 216 | + ], | | 217 | + }, | 218 | 218 | }, | 219 | 219 | ]; | 220 | 220 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/doctool/test-make-doc.mjs +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,15 +21,15 @@ const actualDocs = allDocs.filter( | 21 | 21 | (name) => { | 22 | 22 | const extension = path.extname(name); | 23 | 23 | return extension === '.html' || extension === '.json'; | 24 | | - } | | 24 | + }, | 25 | 25 | ); | 26 | 26 |
| 27 | 27 | for (const name of actualDocs) { | 28 | 28 | if (name.startsWith('all.')) continue; | 29 | 29 |
| 30 | 30 | assert.ok( | 31 | 31 | allMD.includes(name.replace(/\.\w+$/, '.md')), | 32 | | - `Unexpected output: out/doc/api/${name}, remove and rerun.` | | 32 | + `Unexpected output: out/doc/api/${name}, remove and rerun.`, | 33 | 33 | ); | 34 | 34 | } | 35 | 35 |
| @@ -66,6 +66,6 @@ for (const actualDoc of actualDocs) { | 66 | 66 | assert.notStrictEqual( | 67 | 67 | fs.statSync(new URL(`./${actualDoc}`, apiURL)).size, | 68 | 68 | 0, | 69 | | - `${actualDoc} is empty` | | 69 | + `${actualDoc} is empty`, | 70 | 70 | ); | 71 | 71 | } |
Collapse file Copy file name to clipboardExpand all lines: test/report/test-report-config.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -76,13 +76,13 @@ if (!common.isWindows) { | 76 | 76 | process.report.signal = 'foo'; | 77 | 77 | }, { | 78 | 78 | code: 'ERR_UNKNOWN_SIGNAL', | 79 | | - message: 'Unknown signal: foo' | | 79 | + message: 'Unknown signal: foo', | 80 | 80 | }); | 81 | 81 | assert.throws(() => { | 82 | 82 | process.report.signal = 'sigusr1'; | 83 | 83 | }, { | 84 | 84 | code: 'ERR_UNKNOWN_SIGNAL', | 85 | | - message: 'Unknown signal: sigusr1 (signals must use all capital letters)' | | 85 | + message: 'Unknown signal: sigusr1 (signals must use all capital letters)', | 86 | 86 | }); | 87 | 87 | assert.strictEqual(process.report.signal, 'SIGUSR2'); | 88 | 88 | process.report.signal = 'SIGUSR1'; | |
Collapse file Copy file name to clipboardExpand all lines: test/report/test-report-uncaught-exception-compat.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,7 +17,7 @@ const child = childProcess.spawn(process.execPath, [ | 17 | 17 | __filename, | 18 | 18 | 'child', | 19 | 19 | ], { | 20 | | - cwd: tmpdir.path | | 20 | + cwd: tmpdir.path, | 21 | 21 | }); | 22 | 22 | child.on('exit', common.mustCall((code) => { | 23 | 23 | assert.strictEqual(code, 1); | |
|