Skip to content

Commit 5e46553

Browse files
committed
Use domenic's ESLint config as the base
This involves a variety of style updates to conform to newer ESLint rules.
1 parent 19b35da commit 5e46553

Some content is hidden

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

57 files changed

+426
-1105
lines changed

.eslintrc.json

+13-276
Original file line numberDiff line numberDiff line change
@@ -1,289 +1,20 @@
11
{
22
"root": true,
3+
"extends": "@domenic",
34
"env": {
4-
"node": true,
5-
"es6": true
6-
},
7-
"parserOptions": {
8-
"ecmaVersion": 2019
5+
"node": true
96
},
107
"plugins": [
118
"jsdom-internal"
129
],
1310
"rules": {
14-
// Possible errors
15-
"for-direction": "error",
16-
"getter-return": "error",
17-
"no-await-in-loop": "error",
18-
"no-compare-neg-zero": "error",
19-
"no-cond-assign": ["error", "except-parens"],
20-
"no-console": "error",
21-
"no-constant-condition": ["error", { "checkLoops": false }],
22-
"no-control-regex": "off",
23-
"no-debugger": "error",
24-
"no-dupe-args": "error",
25-
"no-dupe-keys": "error",
26-
"no-duplicate-case": "error",
27-
"no-empty": "error",
28-
"no-empty-character-class": "error",
29-
"no-ex-assign": "error",
30-
"no-extra-boolean-cast": "error",
31-
"no-extra-parens": [
32-
"error",
33-
"all",
34-
{ "conditionalAssign": false, "nestedBinaryExpressions": false, "returnAssign": false, "enforceForNewInMemberExpressions": false }
35-
],
36-
"no-extra-semi": "error",
37-
"no-func-assign": "error",
38-
"no-inner-declarations": "off",
39-
"no-invalid-regexp": "error",
40-
"no-irregular-whitespace": "error",
41-
"no-obj-calls": "error",
42-
"no-prototype-builtins": "error",
43-
"no-regex-spaces": "error",
44-
"no-sparse-arrays": "error",
45-
"no-template-curly-in-string": "error",
46-
"no-unexpected-multiline": "error",
47-
"no-unreachable": "error",
48-
"no-unsafe-finally": "off",
49-
"no-unsafe-negation": "error",
50-
"use-isnan": "error",
51-
"valid-jsdoc": "off",
52-
"valid-typeof": "error",
53-
54-
// Best practices
55-
"accessor-pairs": "error",
56-
"array-callback-return": "error",
57-
"block-scoped-var": "off",
58-
"class-methods-use-this": "off",
59-
"complexity": "off",
60-
"consistent-return": "error",
61-
"curly": ["error", "all"],
62-
"default-case": "off",
63-
"dot-location": ["error", "property"],
64-
"dot-notation": "error",
65-
"eqeqeq": "error",
66-
"guard-for-in": "off",
67-
"no-alert": "error",
68-
"no-caller": "error",
69-
"no-case-declarations": "error",
70-
"no-div-regex": "off",
71-
"no-else-return": "error",
72-
"no-empty-function": "off",
73-
"no-empty-pattern": "error",
74-
"no-eq-null": "error",
75-
"no-eval": "error",
76-
"no-extend-native": "error",
77-
"no-extra-bind": "error",
78-
"no-extra-label": "error",
79-
"no-fallthrough": "error",
80-
"no-floating-decimal": "error",
81-
"no-global-assign": "error",
82-
"no-implicit-coercion": "error",
83-
"no-implicit-globals": "error",
11+
// Overrides for jsdom
12+
"array-element-newline": "off",
8413
"no-implied-eval": "off",
85-
"no-invalid-this": "off", // meh
86-
"no-iterator": "error",
87-
"no-labels": ["error", { "allowLoop": true }],
88-
"no-lone-blocks": "error",
89-
"no-loop-func": "off",
90-
"no-magic-numbers": "off",
91-
"no-multi-spaces": "error",
92-
"no-multi-str": "error",
93-
"no-new": "error",
94-
"no-new-func": "error",
95-
"no-new-wrappers": "error",
96-
"no-octal": "error",
97-
"no-octal-escape": "error",
98-
"no-param-reassign": "off",
99-
"no-process-env": "error",
100-
"no-proto": "error",
101-
"no-redeclare": "error",
102-
"no-restricted-properties": "off",
103-
"no-return-assign": ["error", "except-parens"],
104-
"no-return-await": "error",
105-
"no-script-url": "off",
106-
"no-self-assign": "error",
107-
"no-self-compare": "error",
108-
"no-sequences": "error",
109-
"no-throw-literal": "error",
110-
"no-unmodified-loop-condition": "error",
111-
"no-unused-expressions": "error",
112-
"no-unused-labels": "error",
113-
"no-useless-call": "error",
114-
"no-useless-concat": "error",
115-
"no-useless-escape": "error",
116-
"no-useless-return": "error",
117-
"no-void": "error",
118-
"no-warning-comments": "off",
119-
"no-with": "error",
120-
"prefer-promise-reject-errors": "error",
121-
"radix": ["error", "as-needed"],
122-
"require-await": "error",
123-
"vars-on-top": "off",
124-
"wrap-iife": ["error", "outside"],
125-
"yoda": ["error", "never"],
126-
127-
// Strict Mode
128-
"strict": ["error", "global"],
129-
130-
// Variables
131-
"init-declarations": "off",
132-
"no-catch-shadow": "error",
133-
"no-delete-var": "error",
134-
"no-label-var": "error",
135-
"no-restricted-globals": "off",
136-
"no-shadow": "error",
137-
"no-shadow-restricted-names": "error",
138-
"no-undef": "error",
139-
"no-undef-init": "error",
140-
"no-undefined": "off",
141-
"no-unused-vars": "error",
142-
"no-use-before-define": ["error", "nofunc"],
143-
144-
// Node.js and CommonJS
145-
"callback-return": "off",
146-
"global-require": "error",
147-
"handle-callback-err": "error",
148-
"no-buffer-constructor": "error",
149-
"no-mixed-requires": ["error", true],
150-
"no-new-require": "error",
151-
"no-path-concat": "error",
152-
"no-process-exit": "error",
153-
"no-restricted-modules": "off",
154-
"no-sync": "off",
155-
156-
// Stylistic Issues
157-
"array-bracket-newline": ["error", { "multiline": true }],
158-
"array-bracket-spacing": ["error", "never"],
159-
"array-element-newline": ["off"],
160-
"block-spacing": ["error", "always"],
161-
"brace-style": ["error", "1tbs", { "allowSingleLine": false }],
162-
"camelcase": ["error", { "properties": "always" }],
163-
"capitalized-comments": "off",
164-
"comma-dangle": ["error", "never"],
165-
"comma-spacing": ["error", { "before": false, "after": true }],
166-
"comma-style": ["error", "last"],
167-
"computed-property-spacing": ["error", "never"],
168-
"consistent-this": "off",
169-
"eol-last": "error",
170-
"func-call-spacing": ["error", "never"],
171-
"func-name-matching": ["error"],
172-
"func-names": "off",
173-
"func-style": ["error", "declaration"],
174-
"function-paren-newline": ["error", "multiline"],
175-
"id-blacklist": "off",
176-
"id-length": "off",
177-
"id-match": "off",
178-
"indent": ["error", 2, { "SwitchCase": 1, "CallExpression": {"arguments": "first"}, "FunctionExpression": {"parameters": "first"}, "ignoredNodes": ["ConditionalExpression"] }],
179-
"jsx-quotes": "off",
180-
"key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "strict" }],
181-
"keyword-spacing": ["error", { "before": true, "after": true }],
182-
"line-comment-position": "off",
183-
"linebreak-style": ["error", "unix"],
184-
"lines-around-comment": "off",
185-
"max-depth": "off",
186-
"max-len": ["error", 120, { "ignoreUrls": true }],
187-
"max-lines": "off",
188-
"max-nested-callbacks": "off",
189-
"max-params": "off",
190-
"max-statements": "off",
191-
"max-statements-per-line": ["error", { "max": 1 }],
192-
"multiline-ternary": ["error", "always-multiline"],
193-
"new-cap": ["error", { "capIsNewExceptions": ["ByteString", "USVString", "DOMString"] }],
194-
"new-parens": "error",
195-
"newline-per-chained-call": "off",
196-
"no-array-constructor": "error",
197-
"no-bitwise": "off",
198-
"no-continue": "off",
199-
"no-inline-comments": "off",
200-
"no-lonely-if": "error",
201-
"no-mixed-operators": [
202-
"error",
203-
{
204-
"groups": [
205-
["&", "|", "^", "~", "<<", ">>", ">>>"],
206-
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
207-
["&&", "||"],
208-
["in", "instanceof"]
209-
]
210-
}
211-
],
212-
"no-mixed-spaces-and-tabs": "error",
213-
"no-multi-assign": "off",
214-
"no-multiple-empty-lines": "error",
215-
"no-negated-condition": "off",
216-
"no-nested-ternary": "error",
217-
"no-new-object": "error",
218-
"no-plusplus": "off",
219-
"no-restricted-syntax": "off",
220-
"no-tabs": "error",
221-
"no-ternary": "off",
222-
"no-trailing-spaces": "error",
223-
"no-underscore-dangle": "off",
224-
"no-unneeded-ternary": "error",
225-
"no-whitespace-before-property": "error",
226-
"nonblock-statement-body-position": "error",
227-
"object-curly-newline": ["error", { "consistent": true }],
228-
"object-curly-spacing": ["error", "always"],
229-
"object-property-newline": "off",
230-
"one-var": ["error", "never"],
231-
"one-var-declaration-per-line": ["error", "initializations"],
232-
"operator-assignment": ["error", "always"],
233-
"operator-linebreak": ["error", "after"],
234-
"padded-blocks": ["error", "never"],
235-
"padding-line-between-statements": "off",
236-
"quote-props": ["error", "as-needed"],
237-
"quotes": ["error", "double", { "avoidEscape": true, "allowTemplateLiterals": true }],
238-
"require-jsdoc": "off",
239-
"semi": ["error", "always"],
240-
"semi-spacing": "error",
241-
"semi-style": "error",
242-
"sort-keys": "off",
243-
"sort-vars": "off",
244-
"space-before-blocks": ["error", "always"],
245-
"space-before-function-paren": ["error", { "anonymous": "always", "named": "never" }],
246-
"space-in-parens": ["error", "never"],
247-
"space-infix-ops": "error",
248-
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
249-
"spaced-comment": ["error", "always", { "markers": ["///"] }],
250-
"switch-colon-spacing": "error",
251-
"template-tag-spacing": "error",
252-
"unicode-bom": "error",
253-
"wrap-regex": "off",
254-
255-
// ECMAScript 6
256-
"arrow-body-style": "off", // meh
257-
"arrow-parens": ["error", "as-needed"],
258-
"arrow-spacing": "error",
259-
"constructor-super": "error",
260-
"generator-star-spacing": ["error", "after"],
261-
"no-class-assign": "error",
262-
"no-confusing-arrow": "off",
263-
"no-const-assign": "error",
264-
"no-dupe-class-members": "error",
265-
"no-duplicate-imports": "error",
266-
"no-new-symbol": "error",
267-
"no-restricted-imports": "off",
268-
"no-this-before-super": "error",
269-
"no-useless-computed-key": "error",
270-
"no-useless-constructor": "error",
271-
"no-useless-rename": "error",
272-
"no-var": "error",
273-
"object-shorthand": "error",
274-
"prefer-arrow-callback": "error",
275-
"prefer-const": ["error", { "ignoreReadBeforeAssign": true }],
276-
"prefer-destructuring": ["error", { "VariableDeclarator": { "array": false, "object": true }, "AssignmentExpression": { "array": false, "object": false } }, { "enforceForRenamedProperties": false }],
277-
"prefer-numeric-literals": "error",
278-
"prefer-rest-params": "off",
279-
"prefer-spread": "error",
14+
"no-invalid-this": "off",
15+
"require-unicode-regexp": "off",
28016
"prefer-template": "off",
281-
"require-yield": "error",
282-
"rest-spread-spacing": "error",
283-
"sort-imports": "off",
284-
"symbol-description": "error",
285-
"template-curly-spacing": ["error", "never"],
286-
"yield-star-spacing": ["error", "after"],
17+
"new-cap": ["error", { "capIsNewExceptions": ["ByteString", "USVString", "DOMString"] }],
28718

28819
// Custom rules
28920
"jsdom-internal/hook-super-invocation": ["error",
@@ -309,6 +40,12 @@
30940
{ "property": "toggleAttribute", "message": "Use 'setAttributeNS' and 'removeAttributeNS' with null as the namespace to access attributes within jsdom" }
31041
]
31142
}
43+
},
44+
{
45+
"files": ["test/api/**"],
46+
"rules": {
47+
"no-loop-func": "off" // interacts poorly with Mocha's before() and tests generated using loops
48+
}
31249
}
31350
]
31451
}

benchmark/document-suite.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,31 @@ function benchmarkFunctions(document, { setup = noop, fn, teardown = noop, defer
5353
module.exports = function documentSuite(optionsArg) {
5454
const options = typeof optionsArg === "function" ?
5555
{ fn: optionsArg } :
56-
Object.assign({}, optionsArg);
56+
{ ...optionsArg };
5757

5858
// default to async because that is required for defer:true
5959
const suite = options.suite || new Benchmark.Suite({ async: true });
6060
delete options.suite; // do not pass to `Benchmark`
6161

6262
if (nativeDoc) {
63-
const newOptions = Object.assign(
64-
{},
65-
options,
66-
benchmarkFunctions(nativeDoc, options),
67-
{ jsdomDocumentImplementation: "native" }
68-
);
63+
const newOptions = {
64+
65+
...options,
66+
...benchmarkFunctions(nativeDoc, options),
67+
jsdomDocumentImplementation: "native"
68+
};
6969
const benchmark = jsdomBenchmark(newOptions);
7070
benchmark.name = benchmark.name ? benchmark.name + " :: native" : "native";
7171
addBenchmark(suite, benchmark);
7272
}
7373

7474
if (jsdomDoc) {
75-
const newOptions = Object.assign(
76-
{},
77-
options,
78-
benchmarkFunctions(jsdomDoc, options),
79-
{ jsdomDocumentImplementation: "jsdom" }
80-
);
75+
const newOptions = {
76+
77+
...options,
78+
...benchmarkFunctions(jsdomDoc, options),
79+
jsdomDocumentImplementation: "jsdom"
80+
};
8181
const benchmark = jsdomBenchmark(newOptions);
8282

8383
// extra space in "jsdom " so that it aligns with "native"

benchmark/dom/compare-document-position.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ const suite = require("../document-suite");
33

44
exports["compare siblings"] = function () {
55
const SIBLINGS = 10000;
6-
let parent;
7-
let children;
8-
let it;
6+
let parent, children, it;
97

108
return suite({
119
setup(document) {
@@ -32,8 +30,7 @@ exports["compare siblings"] = function () {
3230
exports["compare descendant"] = function () {
3331
const DEPTH = 1000;
3432
const JUNK_CHILDREN = 10;
35-
let parent;
36-
let deepest;
33+
let parent, deepest;
3734

3835
return suite({
3936
setup(document) {
@@ -59,8 +56,7 @@ exports["compare descendant"] = function () {
5956
exports["compare ancestor"] = function () {
6057
const DEPTH = 1000;
6158
const JUNK_CHILDREN = 10;
62-
let parent;
63-
let deepest;
59+
let parent, deepest;
6460

6561
return suite({
6662
setup(document) {

benchmark/dom/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22

33
module.exports = {
4-
construction: require("./construction"),
4+
"construction": require("./construction"),
55
"tree-modification": require("./tree-modification"),
66
"compare-document-position": require("./compare-document-position"),
77
"named-properties": require("./named-properties"),

0 commit comments

Comments
 (0)