Skip to content

Commit

Permalink
[eslint] fully enable @ljharb eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 27, 2021
1 parent 1020639 commit 836610d
Show file tree
Hide file tree
Showing 90 changed files with 611 additions and 328 deletions.
128 changes: 118 additions & 10 deletions .eslintrc
@@ -1,16 +1,124 @@
{
"root": true,
"env": {
"browser": true,
"node": true,
},
"extends": "@ljharb",
"globals": {
"Promise": false,
},
"rules": {
"array-bracket-spacing": "off",
"complexity": "off",
"eqeqeq": ["error", "always", { "null": "ignore" }],
"func-style": "warn",
"indent": ["error", 4],
"key-spacing": "error",
"quotes": ["error", "single", {
"avoidEscape": true,
}],
"semi": ["error", "always"],
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never",
}],
"no-useless-escape": "error",
"no-magic-numbers": "off",
"max-lines": "warn",
"max-lines-per-function": "warn",
"max-statements": "warn",
"max-statements-per-line": [2, { "max": 2 }],
"multiline-comment-style": "off",
"no-param-reassign": "warn",
"no-negated-condition": "off",
"no-use-before-define": "warn",
"no-underscore-dangle": "warn",
"operator-linebreak": ["error", "before"],
"sort-keys": "warn",
},
"ignorePatterns": [ "syntax-error.*" ],
"overrides": [
{
"files": ["*.mjs", "test/import/package_type/*.js"],
"extends": "@ljharb/eslint-config/esm",
},
{
"files": ["bin/**"],
"rules": {
"global-require": "off",
"no-process-exit": "off",
"quote-props": ["error", "as-needed", {
"keywords": false,
}],
},
},
{
"files": ["bin/import-or-require.js"],
"parserOptions": {
"ecmaVersion": 2020,
},
},
{
"files": ["index.js"],
"rules": {
"no-param-reassign": "warn",
},
},
{
"files": ["lib/results.js"],
"rules": {
"no-cond-assign": "warn",
"no-param-reassign": "warn",
"no-plusplus": "warn",
},
},
{
"files": ["lib/test.js"],
"rules": {
"eqeqeq": "warn",
"func-name-matching": "off",
"max-params": "off",
"no-continue": "off",
"no-invalid-this": "off",
"no-param-reassign": "warn",
"no-plusplus": "warn",
"no-multi-assign": "off",
"no-restricted-syntax": "off",
},
},
{
"files": ["test/async-await/*"],
"parserOptions": {
"ecmaVersion": 2017,
},
},
{
"files": ["example/**", "test/**"],
"globals": {
"g": false,
},
"rules": {
"no-new-func": "off",
},
},
{
"files": ["example/**"],
"rules": {
"array-bracket-newline": "off",
"global-require": "off",
"no-console": "off",
},
},
{
"files": ["test/**"],
"rules": {
"dot-notation": [2, {
"allowKeywords": true,
"allowPattern": "throws"
}],
"id-length": "off",
"max-len": "off",
"max-lines-per-function": "off",
"no-plusplus": "off",
"no-throw-literal": "off",
},
},
{
"files": ["test/*/**"],
"rules": {
"camelcase": "off",
},
},
],
}
9 changes: 4 additions & 5 deletions bin/tape
@@ -1,5 +1,7 @@
#!/usr/bin/env node

'use strict';

var resolveModule = require('resolve').sync;
var resolvePath = require('path').resolve;
var readFileSync = require('fs').readFileSync;
Expand All @@ -21,9 +23,7 @@ if (typeof opts.require === 'string') {

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

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

if (!Array.isArray(files)) {
Expand Down
12 changes: 7 additions & 5 deletions example/array.js
@@ -1,3 +1,5 @@
'use strict';

var falafel = require('falafel');
var test = require('../');

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

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
[3, 4],
[1, 2, [3, 4]],
[5, 6],
[[ 1, 2, [3, 4]], [5, 6]]
];

Function(['fn','g'], output)(
Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
Expand Down
6 changes: 4 additions & 2 deletions example/fail.js
@@ -1,3 +1,5 @@
'use strict';

var falafel = require('falafel');
var test = require('../');

Expand All @@ -20,10 +22,10 @@ test('array', function (t) {
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]
];

Function(['fn','g'], output)(
Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
Expand Down
18 changes: 10 additions & 8 deletions example/nested.js
@@ -1,12 +1,14 @@
'use strict';

var falafel = require('falafel');
var test = require('../');

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

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
var xs = [1, 2, [3, 4]];
var ys = [5, 6];
g([ xs, ys ]);
} + ')()';

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

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
[3, 4],
[1, 2, [3, 4]],
[5, 6],
[[ 1, 2, [3, 4]], [5, 6]]
];

Function(['fn','g'], output)(
Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
}
);
});
Expand Down
6 changes: 4 additions & 2 deletions example/nested_fail.js
@@ -1,3 +1,5 @@
'use strict';

var falafel = require('falafel');
var test = require('../');

Expand Down Expand Up @@ -29,10 +31,10 @@ test('nested array test', function (t) {
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]
];

Function(['fn','g'], output)(
Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
Expand Down
6 changes: 4 additions & 2 deletions example/not_enough.js
@@ -1,3 +1,5 @@
'use strict';

var falafel = require('falafel');
var test = require('../');

Expand All @@ -20,10 +22,10 @@ test('array', function (t) {
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]
];

Function(['fn','g'], output)(
Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
Expand Down
2 changes: 2 additions & 0 deletions example/static/server.js
@@ -1,3 +1,5 @@
'use strict';

var http = require('http');
var ecstatic = require('ecstatic')(__dirname);
var server = http.createServer(ecstatic);
Expand Down
2 changes: 2 additions & 0 deletions example/stream/object.js
@@ -1,3 +1,5 @@
'use strict';

var test = require('../../');
var path = require('path');

Expand Down
2 changes: 2 additions & 0 deletions example/stream/tap.js
@@ -1,3 +1,5 @@
'use strict';

var test = require('../../');
var path = require('path');

Expand Down
2 changes: 2 additions & 0 deletions example/stream/test/x.js
@@ -1,3 +1,5 @@
'use strict';

var test = require('../../../');
test(function (t) {
t.plan(1);
Expand Down
4 changes: 3 additions & 1 deletion example/stream/test/y.js
@@ -1,7 +1,9 @@
'use strict';

var test = require('../../../');
test(function (t) {
t.plan(2);
t.equal(1+1, 2);
t.equal(1 + 1, 2);
t.ok(true);
});

Expand Down
6 changes: 4 additions & 2 deletions example/timing.js
@@ -1,12 +1,14 @@
'use strict';

var test = require('../');

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

t.equal(typeof Date.now, 'function');
var start = new Date;
var start = new Date();

setTimeout(function () {
t.equal(new Date - start, 100);
t.equal(new Date() - start, 100);
}, 100);
});
18 changes: 10 additions & 8 deletions example/too_many.js
@@ -1,12 +1,14 @@
'use strict';

var falafel = require('falafel');
var test = require('../');

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

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
var xs = [1, 2, [3, 4]];
var ys = [5, 6];
g([ xs, ys ]);
} + ')()';

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

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
[3, 4],
[1, 2, [3, 4]],
[5, 6],
[[1, 2, [3, 4]], [5, 6]]
];

Function(['fn','g'], output)(
Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
}
);
});

0 comments on commit 836610d

Please sign in to comment.