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:
Rich Trott 2017-07-25 10:37:08 -07:00
parent 4f0b107334
commit aa6fac68da
101 changed files with 689 additions and 659 deletions

View File

@ -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

View File

@ -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

View File

@ -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() {}

View File

@ -218,7 +218,8 @@ exports = module.exports = function initHooks({
ondestroy,
allowNoInit,
logid,
logtype } = {}) {
logtype
} = {}) {
return new ActivityCollector(process.hrtime(), {
oninit,
onbefore,

View File

@ -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');

View File

@ -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
);
[
{},

View File

@ -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);
});

View File

@ -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'
}));

View File

@ -8,11 +8,11 @@ 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}`

View File

@ -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);

View File

@ -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));

View File

@ -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]');