Skip to content

Commit ae8b5c0

Browse files
committed
[eslint] fully enable @ljharb eslint config
It’s time.
1 parent fb4e3cf commit ae8b5c0

15 files changed

+135
-104
lines changed

.eslintrc

+84-67
Original file line numberDiff line numberDiff line change
@@ -4,92 +4,78 @@
44
"browser": true,
55
"node": true,
66
},
7+
"extends": "@ljharb",
78
"globals": {
89
"Promise": false,
910
},
1011
"rules": {
11-
"brace-style": ["error", "1tbs", {
12-
"allowSingleLine": true,
13-
}],
14-
"comma-dangle": ["error", "never"],
15-
"comma-spacing": [2, {
16-
"before": false,
17-
"after": true,
18-
}],
19-
"consistent-return": "error",
20-
"curly": ["error", "all"],
21-
"function-paren-newline": ["error", "multiline"],
22-
"function-call-argument-newline": ["error", "consistent"],
12+
"array-bracket-spacing": "off",
13+
"complexity": "off",
14+
"eqeqeq": ["error", "always", { "null": "ignore" }],
15+
"func-style": "warn",
2316
"indent": ["error", 4],
24-
"key-spacing": "error",
25-
"quotes": ["error", "single", {
26-
"avoidEscape": true,
27-
}],
28-
"semi": ["error", "always"],
29-
"space-before-function-paren": ["error", {
30-
"anonymous": "always",
31-
"named": "never",
32-
}],
33-
"no-extra-parens": ["error", "all", {
34-
"conditionalAssign": false,
35-
"nestedBinaryExpressions": false,
36-
"returnAssign": false,
37-
"ignoreJSX": "all",
38-
"enforceForArrowConditionals": false,
39-
"enforceForSequenceExpressions": true,
40-
"enforceForNewInMemberExpressions": false,
41-
}],
42-
"no-extra-semi": "error",
43-
"no-shadow": ["error", {
44-
"builtinGlobals": false,
45-
"hoist": "functions",
46-
"allow": []
47-
}],
48-
"no-undef": "error",
49-
"no-unused-vars": ["error", {
50-
"vars": "all",
51-
"args": "after-used"
52-
}],
53-
"no-useless-escape": "error",
54-
"object-curly-newline": ["error", {
55-
"ObjectExpression": {
56-
"multiline": true,
57-
"consistent": true,
58-
"minProperties": 3,
59-
},
60-
"ObjectPattern": {
61-
"multiline": true,
62-
"consistent": true,
63-
"minProperties": 3,
64-
},
65-
}],
66-
"object-curly-spacing": ["error", "always"],
17+
"no-magic-numbers": "off",
18+
"max-lines": "warn",
19+
"max-lines-per-function": "warn",
20+
"max-statements": "warn",
21+
"max-statements-per-line": [2, { "max": 2 }],
22+
"multiline-comment-style": "off",
23+
"no-negated-condition": "off",
24+
"no-use-before-define": "warn",
25+
"no-underscore-dangle": "warn",
6726
"operator-linebreak": ["error", "before"],
68-
"semi-style": ["error", "last"],
69-
"space-in-parens": ["error", "never"],
70-
"space-infix-ops": "error",
71-
"space-unary-ops": ["error", {
72-
"words": false,
73-
"nonwords": false,
74-
}],
75-
"strict": "error",
76-
"wrap-iife": ["error", "outside", {
77-
"functionPrototypeMethods": true,
78-
}],
79-
"wrap-regex": "error",
27+
"sort-keys": "warn",
8028
},
8129
"ignorePatterns": [ "syntax-error.*" ],
8230
"overrides": [
8331
{
8432
"files": ["*.mjs", "test/import/package_type/*.js"],
8533
"extends": "@ljharb/eslint-config/esm",
8634
},
35+
{
36+
"files": ["bin/**"],
37+
"rules": {
38+
"global-require": "off",
39+
"no-process-exit": "off",
40+
"quote-props": ["error", "as-needed", {
41+
"keywords": false,
42+
}],
43+
},
44+
},
8745
{
8846
"files": ["bin/import-or-require.js"],
8947
"parserOptions": {
9048
"ecmaVersion": 2020,
9149
},
9250
},
51+
{
52+
"files": ["index.js"],
53+
"rules": {
54+
"no-param-reassign": "warn",
55+
},
56+
},
57+
{
58+
"files": ["lib/results.js"],
59+
"rules": {
60+
"no-cond-assign": "warn",
61+
"no-param-reassign": "warn",
62+
"no-plusplus": "warn",
63+
},
64+
},
65+
{
66+
"files": ["lib/test.js"],
67+
"rules": {
68+
"eqeqeq": "warn",
69+
"func-name-matching": "off",
70+
"max-params": "off",
71+
"no-continue": "off",
72+
"no-invalid-this": "off",
73+
"no-param-reassign": "warn",
74+
"no-plusplus": "warn",
75+
"no-multi-assign": "off",
76+
"no-restricted-syntax": "off",
77+
},
78+
},
9379
{
9480
"files": ["test/async-await/*"],
9581
"parserOptions": {
@@ -101,6 +87,37 @@
10187
"globals": {
10288
"g": false,
10389
},
90+
"rules": {
91+
"no-new-func": "off",
92+
},
93+
},
94+
{
95+
"files": ["example/**"],
96+
"rules": {
97+
"array-bracket-newline": "off",
98+
"global-require": "off",
99+
"no-console": "off",
100+
},
101+
},
102+
{
103+
"files": ["test/**"],
104+
"rules": {
105+
"dot-notation": [2, {
106+
"allowKeywords": true,
107+
"allowPattern": "throws"
108+
}],
109+
"id-length": "off",
110+
"max-len": "off",
111+
"max-lines-per-function": "off",
112+
"no-plusplus": "off",
113+
"no-throw-literal": "off",
114+
},
115+
},
116+
{
117+
"files": ["test/*/**"],
118+
"rules": {
119+
"camelcase": "off",
120+
},
104121
},
105122
],
106123
}

index.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = (function () {
1515
var wait = false;
1616
var harness;
1717
var lazyLoad = function () {
18+
// eslint-disable-next-line no-invalid-this
1819
return getHarness().apply(this, arguments);
1920
};
2021

@@ -89,14 +90,15 @@ function createExitHarness(conf, wait) {
8990
var only = harness._results._only;
9091
for (var i = 0; i < harness._tests.length; i++) {
9192
var t = harness._tests[i];
92-
if (only && t !== only) { continue; }
93-
t._exit();
93+
if (!only || t === only) {
94+
t._exit();
95+
}
9496
}
9597
}
9698
harness.close();
9799

98100
process.removeAllListeners('exit'); // necessary for node v0.6
99-
process.exit(code || harness._exitCode);
101+
process.exit(code || harness._exitCode); // eslint-disable-line no-process-exit
100102
});
101103

102104
return harness;

lib/default_stream.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = function () {
3030
}
3131
} else {
3232
try {
33-
console.log(line);
33+
console.log(line); // eslint-disable-line no-console
3434
} catch (e) {
3535
stream.emit('error', e);
3636
}

lib/results.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ function Results() {
3939
Results.prototype.createStream = function (opts) {
4040
if (!opts) { opts = {}; }
4141
var self = this;
42-
var output, testId = 0;
42+
var output;
43+
var testId = 0;
4344
if (opts.objectMode) {
4445
output = through();
4546
self.on('_push', function ontest(t, extra) {

lib/test.js

+3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ function Test(name_, opts_, cb_) {
101101
}
102102
}
103103

104+
// eslint-disable-next-line consistent-return
104105
Test.prototype.run = function run() {
105106
this.emit('prerun');
106107
if (!this._cb || this._skip) {
@@ -131,6 +132,7 @@ Test.prototype.run = function run() {
131132
}
132133
self.end();
133134
});
135+
// eslint-disable-next-line consistent-return
134136
return;
135137
}
136138

@@ -232,6 +234,7 @@ Test.prototype._end = function _end(err) {
232234
}
233235
if (res && typeof res.then === 'function') {
234236
res.then(next, function (_err) {
237+
// TODO: wth?
235238
err = err || _err;
236239
});
237240
} else {

test/async-await.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var nodeVersion = process.versions.node;
99
var majorVersion = nodeVersion.split('.')[0];
1010

1111
if (Number(majorVersion) < 8) {
12-
process.exit(0);
12+
process.exit(0); // eslint-disable-line no-process-exit
1313
}
1414

1515
tap.test('async1', function (t) {

test/async-await/async-error.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ var test = require('../../');
55
test('async-error', async function myTest(t) {
66
t.ok(true, 'before throw');
77
throw new Error('oopsie');
8+
/* eslint no-unreachable: 0 */
89
t.ok(true, 'after throw');
910
});

test/async-await/sync-error.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var test = require('../../');
55
test('sync-error', function myTest(t) {
66
t.ok(true, 'before throw');
77
throw new Error('oopsie');
8+
/* eslint no-unreachable: 0 */
89
t.ok(true, 'after throw');
910
t.end();
1011
});

test/deep-equal-failure.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,17 @@ tap.test('deep equal failure', function (assert) {
5050
}));
5151

5252
parser.once('assert', function (data) {
53-
delete data.diag.stack;
54-
delete data.diag.at;
5553
assert.deepEqual(data, {
5654
ok: false,
5755
id: 1,
5856
name: 'should be strictly equal',
5957
diag: {
6058
operator: 'equal',
6159
expected: '{ b: 2 }',
62-
actual: '{ a: 1 }'
60+
actual: '{ a: 1 }',
61+
// we don't care about these next two
62+
stack: data.diag.stack,
63+
at: data.diag.at
6364
}
6465
});
6566
});
@@ -111,16 +112,17 @@ tap.test('deep equal failure, depth 6, with option', function (assert) {
111112
}));
112113

113114
parser.once('assert', function (data) {
114-
delete data.diag.stack;
115-
delete data.diag.at;
116115
assert.deepEqual(data, {
117116
ok: false,
118117
id: 1,
119118
name: 'should be strictly equal',
120119
diag: {
121120
operator: 'equal',
122121
expected: '{ a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }',
123-
actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }'
122+
actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }',
123+
// we don't care about these next two
124+
stack: data.diag.stack,
125+
at: data.diag.at
124126
}
125127
});
126128
});
@@ -172,16 +174,17 @@ tap.test('deep equal failure, depth 6, without option', function (assert) {
172174
}));
173175

174176
parser.once('assert', function (data) {
175-
delete data.diag.stack;
176-
delete data.diag.at;
177177
assert.deepEqual(data, {
178178
ok: false,
179179
id: 1,
180180
name: 'should be strictly equal',
181181
diag: {
182182
operator: 'equal',
183183
expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }',
184-
actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }'
184+
actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }',
185+
// we don't care about these next two
186+
stack: data.diag.stack,
187+
at: data.diag.at
185188
}
186189
});
187190
});

test/import.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ tap.test('errors importing test files', function (t) {
189189
});
190190

191191
function tape(args, options) {
192-
options = assign({ cwd: __dirname }, options);
193-
194192
var bin = __dirname + '/../bin/tape';
195193

196-
return spawn('node', [bin].concat(args.split(' ')), options);
194+
return spawn('node', [bin].concat(args.split(' ')), assign({ cwd: __dirname }, options));
197195
}

test/max_listeners/source.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
var test = require('../../');
44

55
for (var i = 0; i < 11; i++) {
6-
test(function (t) { t.ok(true, 'true is truthy'); t.end(); });
6+
test(function (t) {
7+
t.ok(true, 'true is truthy');
8+
t.end();
9+
});
710
}

0 commit comments

Comments
 (0)