Skip to content

Commit 836610d

Browse files
committed
[eslint] fully enable @ljharb eslint config
1 parent 1020639 commit 836610d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+611
-328
lines changed

.eslintrc

+118-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,124 @@
11
{
22
"root": true,
3+
"env": {
4+
"browser": true,
5+
"node": true,
6+
},
7+
"extends": "@ljharb",
8+
"globals": {
9+
"Promise": false,
10+
},
311
"rules": {
12+
"array-bracket-spacing": "off",
13+
"complexity": "off",
14+
"eqeqeq": ["error", "always", { "null": "ignore" }],
15+
"func-style": "warn",
416
"indent": ["error", 4],
5-
"key-spacing": "error",
6-
"quotes": ["error", "single", {
7-
"avoidEscape": true,
8-
}],
9-
"semi": ["error", "always"],
10-
"space-before-function-paren": ["error", {
11-
"anonymous": "always",
12-
"named": "never",
13-
}],
14-
"no-useless-escape": "error",
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-param-reassign": "warn",
24+
"no-negated-condition": "off",
25+
"no-use-before-define": "warn",
26+
"no-underscore-dangle": "warn",
27+
"operator-linebreak": ["error", "before"],
28+
"sort-keys": "warn",
1529
},
30+
"ignorePatterns": [ "syntax-error.*" ],
31+
"overrides": [
32+
{
33+
"files": ["*.mjs", "test/import/package_type/*.js"],
34+
"extends": "@ljharb/eslint-config/esm",
35+
},
36+
{
37+
"files": ["bin/**"],
38+
"rules": {
39+
"global-require": "off",
40+
"no-process-exit": "off",
41+
"quote-props": ["error", "as-needed", {
42+
"keywords": false,
43+
}],
44+
},
45+
},
46+
{
47+
"files": ["bin/import-or-require.js"],
48+
"parserOptions": {
49+
"ecmaVersion": 2020,
50+
},
51+
},
52+
{
53+
"files": ["index.js"],
54+
"rules": {
55+
"no-param-reassign": "warn",
56+
},
57+
},
58+
{
59+
"files": ["lib/results.js"],
60+
"rules": {
61+
"no-cond-assign": "warn",
62+
"no-param-reassign": "warn",
63+
"no-plusplus": "warn",
64+
},
65+
},
66+
{
67+
"files": ["lib/test.js"],
68+
"rules": {
69+
"eqeqeq": "warn",
70+
"func-name-matching": "off",
71+
"max-params": "off",
72+
"no-continue": "off",
73+
"no-invalid-this": "off",
74+
"no-param-reassign": "warn",
75+
"no-plusplus": "warn",
76+
"no-multi-assign": "off",
77+
"no-restricted-syntax": "off",
78+
},
79+
},
80+
{
81+
"files": ["test/async-await/*"],
82+
"parserOptions": {
83+
"ecmaVersion": 2017,
84+
},
85+
},
86+
{
87+
"files": ["example/**", "test/**"],
88+
"globals": {
89+
"g": false,
90+
},
91+
"rules": {
92+
"no-new-func": "off",
93+
},
94+
},
95+
{
96+
"files": ["example/**"],
97+
"rules": {
98+
"array-bracket-newline": "off",
99+
"global-require": "off",
100+
"no-console": "off",
101+
},
102+
},
103+
{
104+
"files": ["test/**"],
105+
"rules": {
106+
"dot-notation": [2, {
107+
"allowKeywords": true,
108+
"allowPattern": "throws"
109+
}],
110+
"id-length": "off",
111+
"max-len": "off",
112+
"max-lines-per-function": "off",
113+
"no-plusplus": "off",
114+
"no-throw-literal": "off",
115+
},
116+
},
117+
{
118+
"files": ["test/*/**"],
119+
"rules": {
120+
"camelcase": "off",
121+
},
122+
},
123+
],
16124
}

bin/tape

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env node
22

3+
'use strict';
4+
35
var resolveModule = require('resolve').sync;
46
var resolvePath = require('path').resolve;
57
var readFileSync = require('fs').readFileSync;
@@ -21,9 +23,7 @@ if (typeof opts.require === 'string') {
2123

2224
opts.require.forEach(function (module) {
2325
if (module) {
24-
/* This check ensures we ignore `-r ""`, trailing `-r`, or
25-
* other silly things the user might (inadvertently) be doing.
26-
*/
26+
// This check ensures we ignore `-r ""`, trailing `-r`, or other silly things the user might (inadvertently) be doing.
2727
require(resolveModule(module, { basedir: cwd }));
2828
}
2929
});
@@ -39,8 +39,7 @@ if (typeof opts.ignore === 'string') {
3939
}
4040

4141
opts._.forEach(function (arg) {
42-
// If glob does not match, `files` will be an empty array.
43-
// Note: `glob.sync` may throw an error and crash the node process.
42+
// If glob does not match, `files` will be an empty array. Note: `glob.sync` may throw an error and crash the node process.
4443
var files = glob.sync(arg);
4544

4645
if (!Array.isArray(files)) {

example/array.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var falafel = require('falafel');
24
var test = require('../');
35

@@ -17,13 +19,13 @@ test('array', function (t) {
1719
});
1820

1921
var arrays = [
20-
[ 3, 4 ],
21-
[ 1, 2, [ 3, 4 ] ],
22-
[ 5, 6 ],
23-
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
22+
[3, 4],
23+
[1, 2, [3, 4]],
24+
[5, 6],
25+
[[ 1, 2, [3, 4]], [5, 6]]
2426
];
2527

26-
Function(['fn','g'], output)(
28+
Function(['fn', 'g'], output)(
2729
function (xs) {
2830
t.same(arrays.shift(), xs);
2931
return xs;

example/fail.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var falafel = require('falafel');
24
var test = require('../');
35

@@ -20,10 +22,10 @@ test('array', function (t) {
2022
[ 3, 4 ],
2123
[ 1, 2, [ 3, 4 ] ],
2224
[ 5, 6 ],
23-
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
25+
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]
2426
];
2527

26-
Function(['fn','g'], output)(
28+
Function(['fn', 'g'], output)(
2729
function (xs) {
2830
t.same(arrays.shift(), xs);
2931
return xs;

example/nested.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
'use strict';
2+
13
var falafel = require('falafel');
24
var test = require('../');
35

46
test('nested array test', function (t) {
57
t.plan(5);
68

79
var src = '(' + function () {
8-
var xs = [ 1, 2, [ 3, 4 ] ];
9-
var ys = [ 5, 6 ];
10+
var xs = [1, 2, [3, 4]];
11+
var ys = [5, 6];
1012
g([ xs, ys ]);
1113
} + ')()';
1214

@@ -26,19 +28,19 @@ test('nested array test', function (t) {
2628
});
2729

2830
var arrays = [
29-
[ 3, 4 ],
30-
[ 1, 2, [ 3, 4 ] ],
31-
[ 5, 6 ],
32-
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
31+
[3, 4],
32+
[1, 2, [3, 4]],
33+
[5, 6],
34+
[[ 1, 2, [3, 4]], [5, 6]]
3335
];
3436

35-
Function(['fn','g'], output)(
37+
Function(['fn', 'g'], output)(
3638
function (xs) {
3739
t.same(arrays.shift(), xs);
3840
return xs;
3941
},
4042
function (xs) {
41-
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
43+
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
4244
}
4345
);
4446
});

example/nested_fail.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var falafel = require('falafel');
24
var test = require('../');
35

@@ -29,10 +31,10 @@ test('nested array test', function (t) {
2931
[ 3, 4 ],
3032
[ 1, 2, [ 3, 4 ] ],
3133
[ 5, 6 ],
32-
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
34+
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]
3335
];
3436

35-
Function(['fn','g'], output)(
37+
Function(['fn', 'g'], output)(
3638
function (xs) {
3739
t.same(arrays.shift(), xs);
3840
return xs;

example/not_enough.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var falafel = require('falafel');
24
var test = require('../');
35

@@ -20,10 +22,10 @@ test('array', function (t) {
2022
[ 3, 4 ],
2123
[ 1, 2, [ 3, 4 ] ],
2224
[ 5, 6 ],
23-
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
25+
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]
2426
];
2527

26-
Function(['fn','g'], output)(
28+
Function(['fn', 'g'], output)(
2729
function (xs) {
2830
t.same(arrays.shift(), xs);
2931
return xs;

example/static/server.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var http = require('http');
24
var ecstatic = require('ecstatic')(__dirname);
35
var server = http.createServer(ecstatic);

example/stream/object.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var test = require('../../');
24
var path = require('path');
35

example/stream/tap.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var test = require('../../');
24
var path = require('path');
35

example/stream/test/x.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var test = require('../../../');
24
test(function (t) {
35
t.plan(1);

example/stream/test/y.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
'use strict';
2+
13
var test = require('../../../');
24
test(function (t) {
35
t.plan(2);
4-
t.equal(1+1, 2);
6+
t.equal(1 + 1, 2);
57
t.ok(true);
68
});
79

example/timing.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
'use strict';
2+
13
var test = require('../');
24

35
test('timing test', function (t) {
46
t.plan(2);
57

68
t.equal(typeof Date.now, 'function');
7-
var start = new Date;
9+
var start = new Date();
810

911
setTimeout(function () {
10-
t.equal(new Date - start, 100);
12+
t.equal(new Date() - start, 100);
1113
}, 100);
1214
});

example/too_many.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
'use strict';
2+
13
var falafel = require('falafel');
24
var test = require('../');
35

46
test('array', function (t) {
57
t.plan(3);
68

79
var src = '(' + function () {
8-
var xs = [ 1, 2, [ 3, 4 ] ];
9-
var ys = [ 5, 6 ];
10+
var xs = [1, 2, [3, 4]];
11+
var ys = [5, 6];
1012
g([ xs, ys ]);
1113
} + ')()';
1214

@@ -17,19 +19,19 @@ test('array', function (t) {
1719
});
1820

1921
var arrays = [
20-
[ 3, 4 ],
21-
[ 1, 2, [ 3, 4 ] ],
22-
[ 5, 6 ],
23-
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
22+
[3, 4],
23+
[1, 2, [3, 4]],
24+
[5, 6],
25+
[[1, 2, [3, 4]], [5, 6]]
2426
];
2527

26-
Function(['fn','g'], output)(
28+
Function(['fn', 'g'], output)(
2729
function (xs) {
2830
t.same(arrays.shift(), xs);
2931
return xs;
3032
},
3133
function (xs) {
32-
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
34+
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
3335
}
3436
);
3537
});

0 commit comments

Comments
 (0)