diff --git a/.eslintrc.js b/.eslintrc.js index cd5fc51e8e3071..5fb535c3d83759 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -130,6 +130,7 @@ module.exports = { // http://eslint.org/docs/rules/#variables 'no-delete-var': 'error', 'no-undef': 'error', + 'no-undef-init': 'error', 'no-unused-vars': ['error', { args: 'none' }], 'no-use-before-define': ['error', { classes: true, @@ -165,7 +166,7 @@ module.exports = { ObjectExpression: 'first', SwitchCase: 1, }], - 'key-spacing': ['error', { mode: 'minimum' }], + 'key-spacing': ['error', { mode: 'strict' }], 'keyword-spacing': 'error', 'linebreak-style': ['error', 'unix'], 'max-len': ['error', { @@ -211,10 +212,12 @@ module.exports = { 'no-tabs': 'error', 'no-trailing-spaces': 'error', 'no-unsafe-finally': 'error', + 'no-whitespace-before-property': 'error', 'object-curly-spacing': ['error', 'always'], + 'one-var': ['error', { initialized: 'never' }], 'one-var-declaration-per-line': 'error', 'operator-linebreak': ['error', 'after'], - quotes: ['error', 'single', 'avoid-escape'], + quotes: ['error', 'single', { avoidEscape: true }], semi: 'error', 'semi-spacing': 'error', 'space-before-blocks': ['error', 'always'], diff --git a/benchmark/http/_chunky_http_client.js b/benchmark/http/_chunky_http_client.js index a90535e489f4c9..7728a5d06c60aa 100644 --- a/benchmark/http/_chunky_http_client.js +++ b/benchmark/http/_chunky_http_client.js @@ -5,8 +5,8 @@ const common = require('../common.js'); const net = require('net'); const bench = common.createBenchmark(main, { - len: [1, 4, 8, 16, 32, 64, 128], - n: [5, 50, 500, 2000], + len: [1, 4, 8, 16, 32, 64, 128], + n: [5, 50, 500, 2000], type: ['send'], }); diff --git a/benchmark/tls/tls-connect.js b/benchmark/tls/tls-connect.js index da0f5e08d5e6db..524d7468d000a1 100644 --- a/benchmark/tls/tls-connect.js +++ b/benchmark/tls/tls-connect.js @@ -1,7 +1,7 @@ 'use strict'; -var fs = require('fs'), - path = require('path'), - tls = require('tls'); +const fs = require('fs'); +const path = require('path'); +const tls = require('tls'); const common = require('../common.js'); const bench = common.createBenchmark(main, { diff --git a/doc/.eslintrc.yaml b/doc/.eslintrc.yaml index c8c1612e3a100b..7b38afec10276a 100644 --- a/doc/.eslintrc.yaml +++ b/doc/.eslintrc.yaml @@ -12,6 +12,7 @@ rules: no-var: error prefer-const: error prefer-rest-params: error + prefer-template: error # Stylistic Issues no-multiple-empty-lines: [error, {max: 1, maxEOF: 0, maxBOF: 0}] diff --git a/doc/api/esm.md b/doc/api/esm.md index 3ff2904488afc1..2a564332951fea 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -118,7 +118,7 @@ given module specifier and parent file URL: ```js const baseURL = new URL('file://'); -baseURL.pathname = process.cwd() + '/'; +baseURL.pathname = `${process.cwd()}/`; export async function resolve(specifier, parentModuleURL = baseURL, @@ -161,7 +161,7 @@ const builtins = Module.builtinModules; const JS_EXTENSIONS = new Set(['.js', '.mjs']); const baseURL = new URL('file://'); -baseURL.pathname = process.cwd() + '/'; +baseURL.pathname = `${process.cwd()}/`; export function resolve(specifier, parentModuleURL = baseURL, defaultResolve) { if (builtins.includes(specifier)) { diff --git a/doc/api/http.md b/doc/api/http.md index daa058a8b0b426..e396471b3e9802 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -422,7 +422,7 @@ const req = http.request(options); req.end(); req.on('information', (res) => { - console.log('got information prior to main response: ' + res.statusCode); + console.log(`Got information prior to main response: ${res.statusCode}`); }); ``` diff --git a/doc/api/stream.md b/doc/api/stream.md index c72873c466fdb3..20eaa95bc19ab4 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1852,7 +1852,7 @@ class Counter extends Readable { if (i > this._max) this.push(null); else { - const str = '' + i; + const str = String(i); const buf = Buffer.from(str, 'ascii'); this.push(buf); } diff --git a/lib/internal/util.js b/lib/internal/util.js index 630cd0ef213bdb..5cec64ca18bfba 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -228,8 +228,8 @@ function getSystemErrorName(err) { // getConstructorOf is wrapped into this to save iterations function getIdentificationOf(obj) { const original = obj; - let constructor = undefined; - let tag = undefined; + let constructor; + let tag; while (obj) { if (constructor === undefined) { diff --git a/test/parallel/test-cluster-worker-kill.js b/test/parallel/test-cluster-worker-kill.js index 38e2deb1555c2d..bb2d3495d95a4d 100644 --- a/test/parallel/test-cluster-worker-kill.js +++ b/test/parallel/test-cluster-worker-kill.js @@ -40,29 +40,28 @@ if (cluster.isWorker) { } else if (cluster.isMaster) { - const KILL_SIGNAL = 'SIGKILL', - expected_results = { - cluster_emitDisconnect: [1, "the cluster did not emit 'disconnect'"], - cluster_emitExit: [1, "the cluster did not emit 'exit'"], - cluster_exitCode: [null, 'the cluster exited w/ incorrect exitCode'], - cluster_signalCode: [KILL_SIGNAL, - 'the cluster exited w/ incorrect signalCode'], - worker_emitDisconnect: [1, "the worker did not emit 'disconnect'"], - worker_emitExit: [1, "the worker did not emit 'exit'"], - worker_state: ['disconnected', 'the worker state is incorrect'], - worker_exitedAfter: [false, - 'the .exitedAfterDisconnect flag is incorrect'], - worker_died: [true, 'the worker is still running'], - worker_exitCode: [null, 'the worker exited w/ incorrect exitCode'], - worker_signalCode: [KILL_SIGNAL, - 'the worker exited w/ incorrect signalCode'] - }, - results = { - cluster_emitDisconnect: 0, - cluster_emitExit: 0, - worker_emitDisconnect: 0, - worker_emitExit: 0 - }; + const KILL_SIGNAL = 'SIGKILL'; + const expected_results = { + cluster_emitDisconnect: [1, "the cluster did not emit 'disconnect'"], + cluster_emitExit: [1, "the cluster did not emit 'exit'"], + cluster_exitCode: [null, 'the cluster exited w/ incorrect exitCode'], + cluster_signalCode: [KILL_SIGNAL, + 'the cluster exited w/ incorrect signalCode'], + worker_emitDisconnect: [1, "the worker did not emit 'disconnect'"], + worker_emitExit: [1, "the worker did not emit 'exit'"], + worker_state: ['disconnected', 'the worker state is incorrect'], + worker_exitedAfter: [false, 'the .exitedAfterDisconnect flag is incorrect'], + worker_died: [true, 'the worker is still running'], + worker_exitCode: [null, 'the worker exited w/ incorrect exitCode'], + worker_signalCode: [KILL_SIGNAL, + 'the worker exited w/ incorrect signalCode'] + }; + const results = { + cluster_emitDisconnect: 0, + cluster_emitExit: 0, + worker_emitDisconnect: 0, + worker_emitExit: 0 + }; // start worker diff --git a/test/parallel/test-eslint-require-buffer.js b/test/parallel/test-eslint-require-buffer.js index ca2c44cb322515..bdc794dd594240 100644 --- a/test/parallel/test-eslint-require-buffer.js +++ b/test/parallel/test-eslint-require-buffer.js @@ -36,14 +36,14 @@ ruleTester.run('require-buffer', rule, { output: useStrict + bufferModule + useBuffer, }, { - code: mockComment + useBuffer, + code: mockComment + useBuffer, errors: [{ message }], - output: mockComment + bufferModule + useBuffer, + output: mockComment + bufferModule + useBuffer, }, { - code: mockComment + useStrict + useBuffer, + code: mockComment + useStrict + useBuffer, errors: [{ message }], - output: mockComment + useStrict + bufferModule + useBuffer, + output: mockComment + useStrict + bufferModule + useBuffer, }, ] }); diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js index dae9c7dc9eabfc..5b57287a6428b5 100644 --- a/test/parallel/test-fs-utimes.js +++ b/test/parallel/test-fs-utimes.js @@ -88,7 +88,7 @@ function testIt(atime, mtime, callback) { expect_errno('futimesSync', fd, ex, 'ENOSYS'); } - let err = undefined; + let err; try { fs.utimesSync('foobarbaz', atime, mtime); } catch (ex) { diff --git a/test/parallel/test-https-agent-servername.js b/test/parallel/test-https-agent-servername.js index 985fbb3ce3f76e..df14d113994f89 100644 --- a/test/parallel/test-https-agent-servername.js +++ b/test/parallel/test-https-agent-servername.js @@ -10,7 +10,7 @@ const fixtures = require('../common/fixtures'); const options = { key: fixtures.readKey('agent1-key.pem'), cert: fixtures.readKey('agent1-cert.pem'), - ca: fixtures.readKey('ca1-cert.pem') + ca: fixtures.readKey('ca1-cert.pem') };