Browse Source

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>
v6
Rich Trott 8 years ago
parent
commit
aa6fac68da
  1. 2
      lib/.eslintrc.yaml
  2. 10
      test/.eslintrc.yaml
  3. 6
      test/addons-napi/test_general/testInstanceOf.js
  4. 3
      test/async-hooks/init-hooks.js
  5. 2
      test/message/throw_in_line_with_tabs.js
  6. 7
      test/parallel/test-buffer-from.js
  7. 12
      test/parallel/test-buffer-isencoding.js
  8. 3
      test/parallel/test-buffer-new.js
  9. 10
      test/parallel/test-openssl-ca-options.js
  10. 6
      test/parallel/test-stdin-child-proc.js
  11. 6
      test/parallel/test-trace-event.js
  12. 19
      test/parallel/test-util-inspect.js

2
lib/.eslintrc.yaml

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

10
test/.eslintrc.yaml

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

6
test/addons-napi/test_general/testInstanceOf.js

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

3
test/async-hooks/init-hooks.js

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

2
test/message/throw_in_line_with_tabs.js

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

7
test/parallel/test-buffer-from.js

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

12
test/parallel/test-buffer-isencoding.js

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

3
test/parallel/test-buffer-new.js

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

10
test/parallel/test-openssl-ca-options.js

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

6
test/parallel/test-stdin-child-proc.js

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

6
test/parallel/test-trace-event.js

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

19
test/parallel/test-util-inspect.js

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

Loading…
Cancel
Save