Skip to content

Commit b1b1978

Browse files
tools: add additional ESLint rules
PR-URL: #8643 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@keybase.io>
1 parent 66df5d1 commit b1b1978

17 files changed

+42
-33
lines changed

.eslintrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@ rules:
3030

3131
# Best Practices
3232
# http://eslint.org/docs/rules/#best-practices
33+
dot-location: [2, property]
3334
no-fallthrough: 2
3435
no-global-assign: 2
3536
no-multi-spaces: 2
3637
no-octal: 2
3738
no-redeclare: 2
3839
no-self-assign: 2
3940
no-unused-labels: 2
41+
no-useless-call: 2
42+
no-useless-escape: 2
43+
no-void: 2
44+
no-with: 2
4045

4146
# Strict Mode
4247
# http://eslint.org/docs/rules/#strict-mode
@@ -64,6 +69,8 @@ rules:
6469
# http://eslint.org/docs/rules/#stylistic-issues
6570
brace-style: [2, 1tbs, {allowSingleLine: true}]
6671
comma-spacing: 2
72+
comma-style: 2
73+
computed-property-spacing: 2
6774
eol-last: 2
6875
func-call-spacing: 2
6976
indent: [2, 2, {SwitchCase: 1, MemberExpression: 1}]
@@ -74,9 +81,11 @@ rules:
7481
new-parens: 2
7582
no-mixed-spaces-and-tabs: 2
7683
no-multiple-empty-lines: [2, {max: 2}]
84+
no-tabs: 2
7785
no-trailing-spaces: 2
7886
quotes: [2, single, avoid-escape]
7987
semi: 2
88+
semi-spacing: 2
8089
space-before-blocks: [2, always]
8190
space-before-function-paren: [2, never]
8291
space-in-parens: [2, never]

benchmark/util/format.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const util = require('util');
44
const common = require('../common');
55
const v8 = require('v8');
66
const bench = common.createBenchmark(main, {
7-
n: [1e6]
8-
, type: ['string',
7+
n: [1e6],
8+
type: ['string',
99
'number',
1010
'object',
1111
'unknown',

lib/_tls_wrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ Server.prototype.addContext = function(servername, context) {
918918

919919
var re = new RegExp('^' +
920920
servername.replace(/([\.^$+?\-\\[\]{}])/g, '\\$1')
921-
.replace(/\*/g, '[^\.]*') +
921+
.replace(/\*/g, '[^.]*') +
922922
'$');
923923
this._contexts.push([re, tls.createSecureContext(context).context]);
924924
};

lib/internal/bootstrap_node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
const filename = Module._resolveFilename(process.argv[1]);
126126
var source = fs.readFileSync(filename, 'utf-8');
127127
// remove shebang and BOM
128-
source = internalModule.stripBOM(source.replace(/^\#\!.*/, ''));
128+
source = internalModule.stripBOM(source.replace(/^#!.*/, ''));
129129
// wrap it
130130
source = Module.wrap(source);
131131
// compile the script, this will throw if it fails

test/inspector/inspector-helper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ function checkHttpResponse(port, path, callback) {
7777
http.get({port, path}, function(res) {
7878
let response = '';
7979
res.setEncoding('utf8');
80-
res.
81-
on('data', (data) => response += data.toString()).
82-
on('end', () => callback(JSON.parse(response)));
80+
res
81+
.on('data', (data) => response += data.toString())
82+
.on('end', () => callback(JSON.parse(response)));
8383
});
8484
}
8585

test/inspector/test-inspector.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ function testBreakpointOnStart(session) {
8585
{ 'method': 'Runtime.runIfWaitingForDebugger' }
8686
];
8787

88-
session.
89-
sendInspectorCommands(commands).
90-
expectMessages(setupExpectBreakOnLine(0, session.mainScriptPath, session));
88+
session
89+
.sendInspectorCommands(commands)
90+
.expectMessages(setupExpectBreakOnLine(0, session.mainScriptPath, session));
9191
}
9292

9393
function testSetBreakpointAndResume(session) {
@@ -105,9 +105,9 @@ function testSetBreakpointAndResume(session) {
105105
'params': { 'scriptId': session.mainScriptId } },
106106
expectMainScriptSource ],
107107
];
108-
session.
109-
sendInspectorCommands(commands).
110-
expectMessages([
108+
session
109+
.sendInspectorCommands(commands)
110+
.expectMessages([
111111
setupExpectConsoleOutput('log', ['A message', 5]),
112112
setupExpectBreakOnLine(5, session.mainScriptPath,
113113
session, (id) => scopeId = id),
@@ -131,7 +131,7 @@ function testInspectScope(session) {
131131
[
132132
{
133133
'method': 'Debugger.evaluateOnCallFrame', 'params': {
134-
'callFrameId': '{\"ordinal\":0,\"injectedScriptId\":1}',
134+
'callFrameId': '{"ordinal":0,"injectedScriptId":1}',
135135
'expression': 'k + t',
136136
'objectGroup': 'console',
137137
'includeCommandLineAPI': true,
@@ -153,9 +153,9 @@ function testInspectScope(session) {
153153

154154
function testWaitsForFrontendDisconnect(session, harness) {
155155
console.log('[test]', 'Verify node waits for the frontend to disconnect');
156-
session.sendInspectorCommands({ 'method': 'Debugger.resume'}).
157-
expectStderrOutput('Waiting for the debugger to disconnect...').
158-
disconnect(true);
156+
session.sendInspectorCommands({ 'method': 'Debugger.resume'})
157+
.expectStderrOutput('Waiting for the debugger to disconnect...')
158+
.disconnect(true);
159159
}
160160

161161
function runTests(harness) {

test/message/throw_in_line_with_tabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable indent */
1+
/* eslint-disable indent, no-tabs */
22
'use strict';
33
require('../common');
44

test/parallel/test-debug-protocol-execute.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ assert.strictEqual(protocol.res.body, undefined);
1515

1616
protocol.state = 'sterrance';
1717
assert.throws(
18-
() => { protocol.execute('grumblecakes'); },
19-
/^Error: Unknown state$/
18+
() => { protocol.execute('grumblecakes'); },
19+
/^Error: Unknown state$/
2020
);

test/parallel/test-http-multi-line-headers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var server = net.createServer(function(conn) {
1414
'Content-Length: ' + body.length + '\r\n' +
1515
'Content-Type: text/plain;\r\n' +
1616
' x-unix-mode=0600;\r\n' +
17-
' name=\"hello.txt\"\r\n' +
17+
' name="hello.txt"\r\n' +
1818
'\r\n' +
1919
body;
2020

test/parallel/test-http-response-multi-content-length.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const server = http.createServer((req, res) => {
2727
var count = 0;
2828

2929
server.listen(0, common.mustCall(() => {
30-
for (let n = 1; n <= MAX_COUNT ; n++) {
30+
for (let n = 1; n <= MAX_COUNT; n++) {
3131
// This runs twice, the first time, the server will use
3232
// setHeader, the second time it uses writeHead. In either
3333
// case, the error handler must be called because the client

0 commit comments

Comments
 (0)