From a76e0bebc1dd4df35d5ec8a824653a203dc66196 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 5 Mar 2018 15:50:22 -0800 Subject: [PATCH 1/2] benchmark,lib,test,tools: use consistent quotes In preparation for a linting rule, use consistent quotation for properties in objects. --- benchmark/querystring/querystring-stringify.js | 2 +- lib/internal/loader/DefaultResolve.js | 2 +- test/doctool/test-doctool-json.js | 4 ++-- test/parallel/test-http-client-headers-array.js | 4 ++-- test/parallel/test-http-raw-headers.js | 10 +++++----- .../test-http2-compat-expect-continue-check.js | 2 +- test/parallel/test-http2-compat-expect-continue.js | 2 +- test/parallel/test-http2-compat-expect-handling.js | 2 +- test/parallel/test-http2-cookies.js | 4 ++-- test/parallel/test-http2-server-rst-before-respond.js | 2 +- test/parallel/test-http2-server-rst-stream.js | 2 +- test/parallel/test-querystring.js | 4 ++-- test/parallel/test-vm-module-link.js | 2 +- tools/eslint-rules/no-unescaped-regexp-dot.js | 8 ++++---- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/benchmark/querystring/querystring-stringify.js b/benchmark/querystring/querystring-stringify.js index cd1debd4df622d..9f025c922ad4e8 100644 --- a/benchmark/querystring/querystring-stringify.js +++ b/benchmark/querystring/querystring-stringify.js @@ -17,7 +17,7 @@ function main({ type, n }) { encodemany: { '\u0080\u0083\u0089': 'bar', '\u008C\u008E\u0099': 'quux', - xyzzy: '\u00A5q\u00A3r' + 'xyzzy': '\u00A5q\u00A3r' }, encodelast: { foo: 'bar', diff --git a/lib/internal/loader/DefaultResolve.js b/lib/internal/loader/DefaultResolve.js index d815be87dd8954..bd99f31e54c599 100644 --- a/lib/internal/loader/DefaultResolve.js +++ b/lib/internal/loader/DefaultResolve.js @@ -40,7 +40,7 @@ function search(target, base) { } const extensionFormatMap = { - __proto__: null, + '__proto__': null, '.mjs': 'esm', '.json': 'json', '.node': 'addon', diff --git a/test/doctool/test-doctool-json.js b/test/doctool/test-doctool-json.js index 1be086c3a6a7ea..993050924a326c 100644 --- a/test/doctool/test-doctool-json.js +++ b/test/doctool/test-doctool-json.js @@ -102,9 +102,9 @@ const testData = [ meta: { added: ['v5.3.0', 'v4.2.0'], changes: [ - { version: 'v4.2.0', + { 'version': 'v4.2.0', 'pr-url': 'https://github.com/nodejs/node/pull/3276', - description: 'The `error` parameter can now be ' + + 'description': 'The `error` parameter can now be ' + 'an arrow function.' } ] diff --git a/test/parallel/test-http-client-headers-array.js b/test/parallel/test-http-client-headers-array.js index dffe04bb108401..c637de61c012b5 100644 --- a/test/parallel/test-http-client-headers-array.js +++ b/test/parallel/test-http-client-headers-array.js @@ -9,8 +9,8 @@ function execute(options) { http.createServer(function(req, res) { const expectHeaders = { 'x-foo': 'boom', - cookie: 'a=1; b=2; c=3', - connection: 'close' + 'cookie': 'a=1; b=2; c=3', + 'connection': 'close' }; // no Host header when you set headers an array diff --git a/test/parallel/test-http-raw-headers.js b/test/parallel/test-http-raw-headers.js index eb3f7280f89100..8ce20db351302c 100644 --- a/test/parallel/test-http-raw-headers.js +++ b/test/parallel/test-http-raw-headers.js @@ -37,10 +37,10 @@ http.createServer(function(req, res) { 'close' ]; const expectHeaders = { - host: `localhost:${this.address().port}`, + 'host': `localhost:${this.address().port}`, 'transfer-encoding': 'CHUNKED', 'x-bar': 'yoyoyo', - connection: 'close' + 'connection': 'close' }; const expectRawTrailers = [ 'x-bAr', @@ -96,9 +96,9 @@ http.createServer(function(req, res) { 'chunked' ]; const expectHeaders = { - trailer: 'x-foo', - date: null, - connection: 'close', + 'trailer': 'x-foo', + 'date': null, + 'connection': 'close', 'transfer-encoding': 'chunked' }; res.rawHeaders[3] = null; diff --git a/test/parallel/test-http2-compat-expect-continue-check.js b/test/parallel/test-http2-compat-expect-continue-check.js index 6aded8b52935c1..4f2514a44a4f9e 100644 --- a/test/parallel/test-http2-compat-expect-continue-check.js +++ b/test/parallel/test-http2-compat-expect-continue-check.js @@ -33,7 +33,7 @@ server.listen(0, common.mustCall(() => { const client = http2.connect(`http://localhost:${server.address().port}`); const req = client.request({ ':method': 'POST', - expect: '100-continue' + 'expect': '100-continue' }); let gotContinue = false; diff --git a/test/parallel/test-http2-compat-expect-continue.js b/test/parallel/test-http2-compat-expect-continue.js index 42fa80ae4e8620..cb90e51f3bc9d7 100644 --- a/test/parallel/test-http2-compat-expect-continue.js +++ b/test/parallel/test-http2-compat-expect-continue.js @@ -29,7 +29,7 @@ server.on('listening', common.mustCall(() => { const client = http2.connect(`http://localhost:${server.address().port}`); const req = client.request({ ':method': 'POST', - expect: '100-continue' + 'expect': '100-continue' }); let gotContinue = false; diff --git a/test/parallel/test-http2-compat-expect-handling.js b/test/parallel/test-http2-compat-expect-handling.js index e987118476337d..77f22758345cff 100644 --- a/test/parallel/test-http2-compat-expect-handling.js +++ b/test/parallel/test-http2-compat-expect-handling.js @@ -30,7 +30,7 @@ function nextTest(testsToRun) { ':method': 'GET', ':scheme': 'http', ':authority': `localhost:${port}`, - expect: expectValue + 'expect': expectValue }); req.on('response', common.mustCall((headers) => { diff --git a/test/parallel/test-http2-cookies.js b/test/parallel/test-http2-cookies.js index cf763915389287..8b371d8c4263cb 100644 --- a/test/parallel/test-http2-cookies.js +++ b/test/parallel/test-http2-cookies.js @@ -41,8 +41,8 @@ server.on('listening', common.mustCall(() => { const req = client.request({ ':path': '/', - abc: [1, 2, 3], - cookie: ['a=b', 'c=d', 'e=f'], + 'abc': [1, 2, 3], + 'cookie': ['a=b', 'c=d', 'e=f'], }); req.resume(); diff --git a/test/parallel/test-http2-server-rst-before-respond.js b/test/parallel/test-http2-server-rst-before-respond.js index 74181f4ffa0bbe..c2831d33079616 100644 --- a/test/parallel/test-http2-server-rst-before-respond.js +++ b/test/parallel/test-http2-server-rst-before-respond.js @@ -17,7 +17,7 @@ function onStream(stream, headers, flags) { common.expectsError(() => { stream.additionalHeaders({ ':status': 123, - abc: 123 + 'abc': 123 }); }, { code: 'ERR_HTTP2_INVALID_STREAM' }); } diff --git a/test/parallel/test-http2-server-rst-stream.js b/test/parallel/test-http2-server-rst-stream.js index 4a58091aa61d7f..d19704509a5e5f 100644 --- a/test/parallel/test-http2-server-rst-stream.js +++ b/test/parallel/test-http2-server-rst-stream.js @@ -40,7 +40,7 @@ server.listen(0, common.mustCall(() => { tests.forEach((test) => { const req = client.request({ ':method': 'POST', - rstcode: test[0] + 'rstcode': test[0] }); req.on('close', common.mustCall((code) => { assert.strictEqual(code, test[0]); diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index f4046c33a11d62..7b77a42a167525 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -75,8 +75,8 @@ const qsTestCases = [ ['foo&bar=baz', 'foo=&bar=baz', { foo: '', bar: 'baz' }], ['a=b&c&d=e', 'a=b&c=&d=e', { a: 'b', c: '', d: 'e' }], ['a=b&c=&d=e', 'a=b&c=&d=e', { a: 'b', c: '', d: 'e' }], - ['a=b&=c&d=e', 'a=b&=c&d=e', { a: 'b', '': 'c', d: 'e' }], - ['a=b&=&c=d', 'a=b&=&c=d', { a: 'b', '': '', c: 'd' }], + ['a=b&=c&d=e', 'a=b&=c&d=e', { 'a': 'b', '': 'c', 'd': 'e' }], + ['a=b&=&c=d', 'a=b&=&c=d', { 'a': 'b', '': '', 'c': 'd' }], ['&&foo=bar&&', 'foo=bar', { foo: 'bar' }], ['&', '', {}], ['&&&&', '', {}], diff --git a/test/parallel/test-vm-module-link.js b/test/parallel/test-vm-module-link.js index 843c1fdc517787..d9ee8e7767f43a 100644 --- a/test/parallel/test-vm-module-link.js +++ b/test/parallel/test-vm-module-link.js @@ -88,7 +88,7 @@ async function circular() { async function circular2() { const sourceMap = { - root: ` + 'root': ` import * as a from './a.mjs'; import * as b from './b.mjs'; if (!('fromA' in a)) diff --git a/tools/eslint-rules/no-unescaped-regexp-dot.js b/tools/eslint-rules/no-unescaped-regexp-dot.js index d0c575071297fb..3af514d4bb91a9 100644 --- a/tools/eslint-rules/no-unescaped-regexp-dot.js +++ b/tools/eslint-rules/no-unescaped-regexp-dot.js @@ -120,10 +120,10 @@ module.exports = function(context) { } return { - TemplateLiteral: checkLiteral, - Literal: checkLiteral, - CallExpression: checkRegExpStart, - NewExpression: checkRegExpStart, + 'TemplateLiteral': checkLiteral, + 'Literal': checkLiteral, + 'CallExpression': checkRegExpStart, + 'NewExpression': checkRegExpStart, 'CallExpression:exit': checkRegExpEnd, 'NewExpression:exit': checkRegExpEnd }; From d86fa63b1a2a17a2517aca36b37f42448ca2c7ca Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 5 Mar 2018 15:51:38 -0800 Subject: [PATCH 2/2] tools: enable ESLint quote-props rule Refs: https://github.com/nodejs/node/pull/19100#discussion_r171993685 --- .eslintrc.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 2836173ca3b201..bf09c553b09791 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -58,12 +58,12 @@ module.exports = { 'dot-location': ['error', 'property'], 'dot-notation': 'error', 'eol-last': 'error', - eqeqeq: ['error', 'smart'], + 'eqeqeq': ['error', 'smart'], 'for-direction': 'error', 'func-call-spacing': 'error', 'func-name-matching': 'error', 'func-style': ['error', 'declaration', { allowArrowFunctions: true }], - indent: ['error', 2, { + 'indent': ['error', 2, { ArrayExpression: 'first', CallExpression: { arguments: 'first' }, FunctionDeclaration: { parameters: 'first' }, @@ -209,9 +209,10 @@ module.exports = { 'one-var-declaration-per-line': 'error', 'operator-linebreak': ['error', 'after'], 'prefer-const': ['error', { ignoreReadBeforeAssign: true }], - quotes: ['error', 'single', { avoidEscape: true }], + 'quotes': ['error', 'single', { avoidEscape: true }], + 'quote-props': ['error', 'consistent'], 'rest-spread-spacing': 'error', - semi: 'error', + 'semi': 'error', 'semi-spacing': 'error', 'space-before-blocks': ['error', 'always'], 'space-before-function-paren': ['error', { @@ -222,7 +223,7 @@ module.exports = { 'space-in-parens': ['error', 'never'], 'space-infix-ops': 'error', 'space-unary-ops': 'error', - strict: ['error', 'global'], + 'strict': ['error', 'global'], 'symbol-description': 'error', 'template-curly-spacing': 'error', 'unicode-bom': 'error',