test: adjust indentation for stricter linting
ESLint 4.x has stricter linting than previous versions. We are currently using the legacy indentation rules in the test directory. This commit changes the indentation of files to comply with the stricter 4.x linting and enable stricter linting in the test directory. PR-URL: https://github.com/nodejs/node/pull/14431 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
parent
4f0b107334
commit
aa6fac68da
@ -6,7 +6,7 @@ rules:
|
||||
MemberExpression: off,
|
||||
ObjectExpression: first,
|
||||
SwitchCase: 1}]
|
||||
indent-legacy: 0
|
||||
indent-legacy: off
|
||||
|
||||
# Custom rules in tools/eslint-rules
|
||||
require-buffer: error
|
||||
|
@ -1,6 +1,16 @@
|
||||
## Test-specific linter rules
|
||||
|
||||
rules:
|
||||
# Stylistic Issues
|
||||
# http://eslint.org/docs/rules/#stylistic-issues
|
||||
indent: [error, 2, {ArrayExpression: first,
|
||||
CallExpression: {arguments: first},
|
||||
FunctionDeclaration: {parameters: first},
|
||||
FunctionExpression: {parameters: first},
|
||||
MemberExpression: off,
|
||||
ObjectExpression: first,
|
||||
SwitchCase: 1}]
|
||||
indent-legacy: off
|
||||
# ECMAScript 6
|
||||
# http://eslint.org/docs/rules/#ecmascript-6
|
||||
no-var: error
|
||||
|
@ -61,8 +61,10 @@ if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol &&
|
||||
typeof Symbol.hasInstance === 'symbol') {
|
||||
|
||||
function compareToNative(theObject, theConstructor) {
|
||||
assert.strictEqual(addon.doInstanceOf(theObject, theConstructor),
|
||||
(theObject instanceof theConstructor));
|
||||
assert.strictEqual(
|
||||
addon.doInstanceOf(theObject, theConstructor),
|
||||
(theObject instanceof theConstructor)
|
||||
);
|
||||
}
|
||||
|
||||
function MyClass() {}
|
||||
|
@ -218,7 +218,8 @@ exports = module.exports = function initHooks({
|
||||
ondestroy,
|
||||
allowNoInit,
|
||||
logid,
|
||||
logtype } = {}) {
|
||||
logtype
|
||||
} = {}) {
|
||||
return new ActivityCollector(process.hrtime(), {
|
||||
oninit,
|
||||
onbefore,
|
||||
|
@ -19,7 +19,7 @@
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
/* eslint-disable indent-legacy, no-tabs */
|
||||
/* eslint-disable indent, no-tabs */
|
||||
'use strict';
|
||||
require('../common');
|
||||
|
||||
|
@ -750,7 +750,7 @@ assert.strictEqual('<Buffer 81 a3 66 6f 6f a3 62 61 72>', x.inspect());
|
||||
|
||||
// Call .fill() first, stops valgrind warning about uninitialized memory reads.
|
||||
Buffer.allocUnsafe(3.3).fill().toString();
|
||||
// throws bad argument error in commit 43cb4ec
|
||||
// throws bad argument error in commit 43cb4ec
|
||||
Buffer.alloc(3.3).fill().toString();
|
||||
assert.strictEqual(Buffer.allocUnsafe(NaN).length, 0);
|
||||
assert.strictEqual(Buffer.allocUnsafe(3.3).length, 3);
|
||||
|
@ -30,9 +30,10 @@ class MyBadPrimitive {
|
||||
deepStrictEqual(Buffer.from(new String(checkString)), check);
|
||||
deepStrictEqual(Buffer.from(new MyString()), check);
|
||||
deepStrictEqual(Buffer.from(new MyPrimitive()), check);
|
||||
deepStrictEqual(Buffer.from(
|
||||
runInNewContext('new String(checkString)', { checkString })),
|
||||
check);
|
||||
deepStrictEqual(
|
||||
Buffer.from(runInNewContext('new String(checkString)', { checkString })),
|
||||
check
|
||||
);
|
||||
|
||||
[
|
||||
{},
|
||||
|
@ -3,7 +3,8 @@
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
[ 'hex',
|
||||
[
|
||||
'hex',
|
||||
'utf8',
|
||||
'utf-8',
|
||||
'ascii',
|
||||
@ -13,11 +14,13 @@ const assert = require('assert');
|
||||
'ucs2',
|
||||
'ucs-2',
|
||||
'utf16le',
|
||||
'utf-16le' ].forEach((enc) => {
|
||||
'utf-16le'
|
||||
].forEach((enc) => {
|
||||
assert.strictEqual(Buffer.isEncoding(enc), true);
|
||||
});
|
||||
});
|
||||
|
||||
[ 'utf9',
|
||||
[
|
||||
'utf9',
|
||||
'utf-7',
|
||||
'Unicode-FTW',
|
||||
'new gnu gun',
|
||||
@ -28,6 +31,7 @@ const assert = require('assert');
|
||||
[],
|
||||
1,
|
||||
0,
|
||||
-1 ].forEach((enc) => {
|
||||
-1
|
||||
].forEach((enc) => {
|
||||
assert.strictEqual(Buffer.isEncoding(enc), false);
|
||||
});
|
||||
});
|
||||
|
@ -6,6 +6,5 @@ const assert = require('assert');
|
||||
assert.throws(() => new Buffer(42, 'utf8'), common.expectsError({
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
type: TypeError,
|
||||
message: 'The "string" argument must be of type string. ' +
|
||||
'Received type number'
|
||||
message: 'The "string" argument must be of type string. Received type number'
|
||||
}));
|
||||
|
@ -16,7 +16,7 @@ function read(buff, funx, args, expected) {
|
||||
assert.doesNotThrow(
|
||||
() => assert.strictEqual(buff[funx](...args, true), expected),
|
||||
'noAssert does not change return value for valid ranges'
|
||||
);
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
@ -81,4 +81,4 @@ test1
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
}
|
||||
);
|
||||
);
|
||||
|
@ -8,14 +8,14 @@ if (!common.hasCrypto)
|
||||
const assert = require('assert');
|
||||
const os = require('os');
|
||||
const childProcess = require('child_process');
|
||||
const result = childProcess.spawnSync(process.execPath, [
|
||||
'--use-bundled-ca',
|
||||
'--use-openssl-ca',
|
||||
'-p', 'process.version'],
|
||||
{ encoding: 'utf8' });
|
||||
const result = childProcess.spawnSync(
|
||||
process.execPath,
|
||||
[ '--use-bundled-ca', '--use-openssl-ca', '-p', 'process.version' ],
|
||||
{ encoding: 'utf8' }
|
||||
);
|
||||
|
||||
assert.strictEqual(result.stderr, `${process.execPath
|
||||
}: either --use-openssl-ca or --use-bundled-ca can be used, not both${os.EOL}`
|
||||
}: either --use-openssl-ca or --use-bundled-ca can be used, not both${os.EOL}`
|
||||
);
|
||||
assert.strictEqual(result.status, 9);
|
||||
|
||||
|
@ -356,7 +356,7 @@ assert.strictEqual(
|
||||
{
|
||||
const b = qs.unescapeBuffer('%d3%f2Ug%1f6v%24%5e%98%cb' +
|
||||
'%0d%ac%a2%2f%9d%eb%d8%a2%e6');
|
||||
// <Buffer d3 f2 55 67 1f 36 76 24 5e 98 cb 0d ac a2 2f 9d eb d8 a2 e6>
|
||||
// <Buffer d3 f2 55 67 1f 36 76 24 5e 98 cb 0d ac a2 2f 9d eb d8 a2 e6>
|
||||
assert.strictEqual(0xd3, b[0]);
|
||||
assert.strictEqual(0xf2, b[1]);
|
||||
assert.strictEqual(0x55, b[2]);
|
||||
|
@ -5,8 +5,10 @@ const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const child_process = require('child_process');
|
||||
const path = require('path');
|
||||
const cp = child_process.spawn(process.execPath,
|
||||
[path.resolve(__dirname, 'test-stdin-pause-resume.js')]);
|
||||
const cp = child_process.spawn(
|
||||
process.execPath,
|
||||
[path.resolve(__dirname, 'test-stdin-pause-resume.js')]
|
||||
);
|
||||
|
||||
cp.on('exit', common.mustCall((code) => {
|
||||
assert.strictEqual(code, 0);
|
||||
|
@ -28,7 +28,7 @@ assert.throws(() => tls.createServer({ handshakeTimeout: 'abcd' }),
|
||||
type: TypeError,
|
||||
message: 'The "timeout" argument must be of type number'
|
||||
})
|
||||
);
|
||||
);
|
||||
|
||||
assert.throws(() => tls.createServer({ sessionTimeout: 'abcd' }),
|
||||
/TypeError: Session timeout must be a 32-bit integer/);
|
||||
|
@ -10,8 +10,10 @@ const FILE_NAME = 'node_trace.1.log';
|
||||
common.refreshTmpDir();
|
||||
process.chdir(common.tmpDir);
|
||||
|
||||
const proc_no_categories = cp.spawn(process.execPath,
|
||||
[ '--trace-events-enabled', '--trace-event-categories', '""', '-e', CODE ]);
|
||||
const proc_no_categories = cp.spawn(
|
||||
process.execPath,
|
||||
[ '--trace-events-enabled', '--trace-event-categories', '""', '-e', CODE ]
|
||||
);
|
||||
|
||||
proc_no_categories.once('exit', common.mustCall(() => {
|
||||
assert(!common.fileExists(FILE_NAME));
|
||||
|
@ -30,7 +30,7 @@ assert.strictEqual(b.a(), 'a');
|
||||
assert.strictEqual(b.b(), 'b');
|
||||
assert.strictEqual(b.constructor, B);
|
||||
|
||||
// two levels of inheritance
|
||||
// two levels of inheritance
|
||||
function C() {
|
||||
B.call(this, 'b');
|
||||
this._c = 'c';
|
||||
|
@ -76,13 +76,22 @@ assert.strictEqual(util.inspect({ 'a': { 'b': { 'c': 2 } } }, false, 1),
|
||||
'{ a: { b: [Object] } }');
|
||||
assert.strictEqual(util.inspect({ 'a': { 'b': ['c'] } }, false, 1),
|
||||
'{ a: { b: [Array] } }');
|
||||
assert.strictEqual(util.inspect(Object.create({},
|
||||
{ visible: { value: 1, enumerable: true }, hidden: { value: 2 } })),
|
||||
assert.strictEqual(
|
||||
util.inspect(
|
||||
Object.create(
|
||||
{},
|
||||
{ visible: { value: 1, enumerable: true }, hidden: { value: 2 } }
|
||||
)
|
||||
),
|
||||
'{ visible: 1 }'
|
||||
);
|
||||
assert.strictEqual(util.inspect(Object.assign(new String('hello'),
|
||||
{ [Symbol('foo')]: 123 }), { showHidden: true }),
|
||||
'{ [String: \'hello\'] [length]: 5, [Symbol(foo)]: 123 }');
|
||||
assert.strictEqual(
|
||||
util.inspect(
|
||||
Object.assign(new String('hello'), { [Symbol('foo')]: 123 }),
|
||||
{ showHidden: true }
|
||||
),
|
||||
'{ [String: \'hello\'] [length]: 5, [Symbol(foo)]: 123 }'
|
||||
);
|
||||
|
||||
assert.strictEqual(util.inspect((new JSStream())._externalStream),
|
||||
'[External]');
|
||||
@ -196,7 +205,7 @@ for (const showHidden of [true, false]) {
|
||||
util.inspect(array, false),
|
||||
`${constructor.name} [ 65, 97 ]`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// Now check that declaring a TypedArray in a different context works the same
|
||||
[ Float32Array,
|
||||
@ -230,7 +239,7 @@ for (const showHidden of [true, false]) {
|
||||
util.inspect(array, false),
|
||||
`${constructor.name} [ 65, 97 ]`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// Due to the hash seed randomization it's not deterministic the order that
|
||||
// the following ways this hash is displayed.
|
||||
|
Loading…
x
Reference in New Issue
Block a user