tools: add additional ESLint rules
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
66df5d147f
commit
b1b1978ec5
@ -30,6 +30,7 @@ rules:
|
||||
|
||||
# Best Practices
|
||||
# http://eslint.org/docs/rules/#best-practices
|
||||
dot-location: [2, property]
|
||||
no-fallthrough: 2
|
||||
no-global-assign: 2
|
||||
no-multi-spaces: 2
|
||||
@ -37,6 +38,10 @@ rules:
|
||||
no-redeclare: 2
|
||||
no-self-assign: 2
|
||||
no-unused-labels: 2
|
||||
no-useless-call: 2
|
||||
no-useless-escape: 2
|
||||
no-void: 2
|
||||
no-with: 2
|
||||
|
||||
# Strict Mode
|
||||
# http://eslint.org/docs/rules/#strict-mode
|
||||
@ -64,6 +69,8 @@ rules:
|
||||
# http://eslint.org/docs/rules/#stylistic-issues
|
||||
brace-style: [2, 1tbs, {allowSingleLine: true}]
|
||||
comma-spacing: 2
|
||||
comma-style: 2
|
||||
computed-property-spacing: 2
|
||||
eol-last: 2
|
||||
func-call-spacing: 2
|
||||
indent: [2, 2, {SwitchCase: 1, MemberExpression: 1}]
|
||||
@ -74,9 +81,11 @@ rules:
|
||||
new-parens: 2
|
||||
no-mixed-spaces-and-tabs: 2
|
||||
no-multiple-empty-lines: [2, {max: 2}]
|
||||
no-tabs: 2
|
||||
no-trailing-spaces: 2
|
||||
quotes: [2, single, avoid-escape]
|
||||
semi: 2
|
||||
semi-spacing: 2
|
||||
space-before-blocks: [2, always]
|
||||
space-before-function-paren: [2, never]
|
||||
space-in-parens: [2, never]
|
||||
|
@ -4,8 +4,8 @@ const util = require('util');
|
||||
const common = require('../common');
|
||||
const v8 = require('v8');
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e6]
|
||||
, type: ['string',
|
||||
n: [1e6],
|
||||
type: ['string',
|
||||
'number',
|
||||
'object',
|
||||
'unknown',
|
||||
|
@ -918,7 +918,7 @@ Server.prototype.addContext = function(servername, context) {
|
||||
|
||||
var re = new RegExp('^' +
|
||||
servername.replace(/([\.^$+?\-\\[\]{}])/g, '\\$1')
|
||||
.replace(/\*/g, '[^\.]*') +
|
||||
.replace(/\*/g, '[^.]*') +
|
||||
'$');
|
||||
this._contexts.push([re, tls.createSecureContext(context).context]);
|
||||
};
|
||||
|
2
lib/internal/bootstrap_node.js
vendored
2
lib/internal/bootstrap_node.js
vendored
@ -125,7 +125,7 @@
|
||||
const filename = Module._resolveFilename(process.argv[1]);
|
||||
var source = fs.readFileSync(filename, 'utf-8');
|
||||
// remove shebang and BOM
|
||||
source = internalModule.stripBOM(source.replace(/^\#\!.*/, ''));
|
||||
source = internalModule.stripBOM(source.replace(/^#!.*/, ''));
|
||||
// wrap it
|
||||
source = Module.wrap(source);
|
||||
// compile the script, this will throw if it fails
|
||||
|
@ -77,9 +77,9 @@ function checkHttpResponse(port, path, callback) {
|
||||
http.get({port, path}, function(res) {
|
||||
let response = '';
|
||||
res.setEncoding('utf8');
|
||||
res.
|
||||
on('data', (data) => response += data.toString()).
|
||||
on('end', () => callback(JSON.parse(response)));
|
||||
res
|
||||
.on('data', (data) => response += data.toString())
|
||||
.on('end', () => callback(JSON.parse(response)));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -85,9 +85,9 @@ function testBreakpointOnStart(session) {
|
||||
{ 'method': 'Runtime.runIfWaitingForDebugger' }
|
||||
];
|
||||
|
||||
session.
|
||||
sendInspectorCommands(commands).
|
||||
expectMessages(setupExpectBreakOnLine(0, session.mainScriptPath, session));
|
||||
session
|
||||
.sendInspectorCommands(commands)
|
||||
.expectMessages(setupExpectBreakOnLine(0, session.mainScriptPath, session));
|
||||
}
|
||||
|
||||
function testSetBreakpointAndResume(session) {
|
||||
@ -105,9 +105,9 @@ function testSetBreakpointAndResume(session) {
|
||||
'params': { 'scriptId': session.mainScriptId } },
|
||||
expectMainScriptSource ],
|
||||
];
|
||||
session.
|
||||
sendInspectorCommands(commands).
|
||||
expectMessages([
|
||||
session
|
||||
.sendInspectorCommands(commands)
|
||||
.expectMessages([
|
||||
setupExpectConsoleOutput('log', ['A message', 5]),
|
||||
setupExpectBreakOnLine(5, session.mainScriptPath,
|
||||
session, (id) => scopeId = id),
|
||||
@ -131,7 +131,7 @@ function testInspectScope(session) {
|
||||
[
|
||||
{
|
||||
'method': 'Debugger.evaluateOnCallFrame', 'params': {
|
||||
'callFrameId': '{\"ordinal\":0,\"injectedScriptId\":1}',
|
||||
'callFrameId': '{"ordinal":0,"injectedScriptId":1}',
|
||||
'expression': 'k + t',
|
||||
'objectGroup': 'console',
|
||||
'includeCommandLineAPI': true,
|
||||
@ -153,9 +153,9 @@ function testInspectScope(session) {
|
||||
|
||||
function testWaitsForFrontendDisconnect(session, harness) {
|
||||
console.log('[test]', 'Verify node waits for the frontend to disconnect');
|
||||
session.sendInspectorCommands({ 'method': 'Debugger.resume'}).
|
||||
expectStderrOutput('Waiting for the debugger to disconnect...').
|
||||
disconnect(true);
|
||||
session.sendInspectorCommands({ 'method': 'Debugger.resume'})
|
||||
.expectStderrOutput('Waiting for the debugger to disconnect...')
|
||||
.disconnect(true);
|
||||
}
|
||||
|
||||
function runTests(harness) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* eslint-disable indent */
|
||||
/* eslint-disable indent, no-tabs */
|
||||
'use strict';
|
||||
require('../common');
|
||||
|
||||
|
@ -15,6 +15,6 @@ assert.strictEqual(protocol.res.body, undefined);
|
||||
|
||||
protocol.state = 'sterrance';
|
||||
assert.throws(
|
||||
() => { protocol.execute('grumblecakes'); },
|
||||
/^Error: Unknown state$/
|
||||
() => { protocol.execute('grumblecakes'); },
|
||||
/^Error: Unknown state$/
|
||||
);
|
||||
|
@ -14,7 +14,7 @@ var server = net.createServer(function(conn) {
|
||||
'Content-Length: ' + body.length + '\r\n' +
|
||||
'Content-Type: text/plain;\r\n' +
|
||||
' x-unix-mode=0600;\r\n' +
|
||||
' name=\"hello.txt\"\r\n' +
|
||||
' name="hello.txt"\r\n' +
|
||||
'\r\n' +
|
||||
body;
|
||||
|
||||
|
@ -27,7 +27,7 @@ const server = http.createServer((req, res) => {
|
||||
var count = 0;
|
||||
|
||||
server.listen(0, common.mustCall(() => {
|
||||
for (let n = 1; n <= MAX_COUNT ; n++) {
|
||||
for (let n = 1; n <= MAX_COUNT; n++) {
|
||||
// This runs twice, the first time, the server will use
|
||||
// setHeader, the second time it uses writeHead. In either
|
||||
// case, the error handler must be called because the client
|
||||
|
@ -48,7 +48,7 @@ const server = http.createServer(function(req, res) {
|
||||
|
||||
server.listen(0, common.mustCall(function() {
|
||||
var count = 0;
|
||||
for (let n = 1; n <= 2 ; n++) {
|
||||
for (let n = 1; n <= 2; n++) {
|
||||
// this runs twice, the first time, the server will use
|
||||
// setHeader, the second time it uses writeHead. The
|
||||
// result on the client side should be the same in
|
||||
|
@ -4,7 +4,7 @@ const assert = require('assert');
|
||||
const net = require('net');
|
||||
|
||||
const invalidPort = -1 >>> 0;
|
||||
const errorMessage = /"port" argument must be \>= 0 and \< 65536/;
|
||||
const errorMessage = /"port" argument must be >= 0 and < 65536/;
|
||||
|
||||
net.Server().listen(common.PORT, function() {
|
||||
const address = this.address();
|
||||
|
@ -160,7 +160,7 @@ function error_test() {
|
||||
// invalid RegExps are a special case of syntax error,
|
||||
// should throw
|
||||
{ client: client_unix, send: '/(/;',
|
||||
expect: /\bSyntaxError: Invalid regular expression\:/ },
|
||||
expect: /\bSyntaxError: Invalid regular expression:/ },
|
||||
// invalid RegExp modifiers are a special case of syntax error,
|
||||
// should throw (GH-4012)
|
||||
{ client: client_unix, send: 'new RegExp("foo", "wrong modifier");',
|
||||
@ -313,7 +313,7 @@ function error_test() {
|
||||
{ client: client_unix, send: "function x(s) {\nreturn s.replace(/'/,'');\n}",
|
||||
expect: prompt_multiline + prompt_multiline +
|
||||
'undefined\n' + prompt_unix },
|
||||
{ client: client_unix, send: "function x(s) {\nreturn s.replace(/\'/,'');\n}",
|
||||
{ client: client_unix, send: "function x(s) {\nreturn s.replace(/'/,'');\n}",
|
||||
expect: prompt_multiline + prompt_multiline +
|
||||
'undefined\n' + prompt_unix },
|
||||
{ client: client_unix, send: 'function x(s) {\nreturn s.replace(/"/,"");\n}',
|
||||
|
@ -154,7 +154,7 @@ test('write bufferize', function(t) {
|
||||
});
|
||||
|
||||
chunks.forEach(function(chunk, i) {
|
||||
var enc = encodings[ i % encodings.length ];
|
||||
var enc = encodings[i % encodings.length];
|
||||
chunk = Buffer.from(chunk);
|
||||
tw.write(chunk.toString(enc), enc);
|
||||
});
|
||||
@ -192,7 +192,7 @@ test('write no bufferize', function(t) {
|
||||
});
|
||||
|
||||
chunks.forEach(function(chunk, i) {
|
||||
var enc = encodings[ i % encodings.length ];
|
||||
var enc = encodings[i % encodings.length];
|
||||
chunk = Buffer.from(chunk);
|
||||
tw.write(chunk.toString(enc), enc);
|
||||
});
|
||||
|
@ -16,9 +16,9 @@ function doCheck(arg, check) {
|
||||
'-pe',
|
||||
'require("crypto").constants.defaultCipherList'
|
||||
]);
|
||||
spawn(process.execPath, arg, {}).
|
||||
on('error', common.fail).
|
||||
stdout.on('data', function(chunk) {
|
||||
spawn(process.execPath, arg, {})
|
||||
.on('error', common.fail)
|
||||
.stdout.on('data', function(chunk) {
|
||||
out += chunk;
|
||||
}).on('end', function() {
|
||||
assert.equal(out.trim(), check);
|
||||
|
@ -10,7 +10,7 @@ var tls = require('tls');
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
var hosterr = /Hostname\/IP doesn\'t match certificate\'s altnames/g;
|
||||
var hosterr = /Hostname\/IP doesn't match certificate's altnames/g;
|
||||
var testCases =
|
||||
[{ ca: ['ca1-cert'],
|
||||
key: 'agent2-key',
|
||||
|
@ -29,5 +29,5 @@ execFile(node, traceWarn, function(er, stdout, stderr) {
|
||||
assert.equal(er, null);
|
||||
assert.equal(stdout, '');
|
||||
assert(/^\(.+\)\sWarning: a bad practice warning/.test(stderr));
|
||||
assert(/at Object\.\<anonymous\>\s\(.+warnings.js:3:9\)/.test(stderr));
|
||||
assert(/at Object\.<anonymous>\s\(.+warnings.js:3:9\)/.test(stderr));
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user