Skip to content

Commit 71d03e5

Browse files
authored
chore: add prettier (#442)
* chore: add prettier * fix lint
1 parent 87890a3 commit 71d03e5

File tree

86 files changed

+5445
-3881
lines changed

Some content is hidden

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

86 files changed

+5445
-3881
lines changed

eslint-remote-tester.config.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = {
2323
"l10n-tw/canvas-lms",
2424
"rust-lang/crates.io",
2525
"simonihmig/ember-responsive-image",
26-
"videojs/video.js"
26+
"videojs/video.js",
2727
],
2828

2929
/** Extensions of files under scanning */
@@ -40,15 +40,18 @@ module.exports = {
4040
rules: Object.fromEntries(
4141
fs
4242
.readdirSync(`${__dirname}/lib/rules`)
43-
.map((filename) => `qunit/${basename(filename, extname(filename))}`)
44-
.map((ruleName) => [ruleName, "error"])
43+
.map(
44+
(filename) =>
45+
`qunit/${basename(filename, extname(filename))}`,
46+
)
47+
.map((ruleName) => [ruleName, "error"]),
4548
),
4649

4750
overrides: [
4851
{
4952
files: ["*.ts", "*.mts", "*.cts"],
50-
parser: "@typescript-eslint/parser"
51-
}
52-
]
53-
}
53+
parser: "@typescript-eslint/parser",
54+
},
55+
],
56+
},
5457
};

eslint.config.js

Lines changed: 88 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -2,85 +2,64 @@
22

33
const js = require("@eslint/js");
44
const { FlatCompat } = require("@eslint/eslintrc");
5-
const eslintPluginMarkdown = require("eslint-plugin-markdown");
65
const eslintPluginEslintPluginAll = require("eslint-plugin-eslint-plugin/configs/all");
6+
const eslintPluginMarkdown = require("eslint-plugin-markdown");
77
const globals = require("globals");
88

99
const compat = new FlatCompat({
1010
baseDirectory: __dirname,
11-
recommendedConfig: js.configs.recommended
11+
recommendedConfig: js.configs.recommended,
1212
});
1313

1414
module.exports = [
1515
...compat.extends(
16-
"plugin:node/recommended",
1716
"plugin:eslint-comments/recommended",
18-
"plugin:unicorn/recommended"
17+
"plugin:node/recommended",
18+
"plugin:prettier/recommended",
19+
"plugin:unicorn/recommended",
1920
),
2021

2122
eslintPluginEslintPluginAll,
2223

2324
// Apply mocha config only to tests.
24-
...compat.extends("plugin:mocha/recommended").map(config => ({ ...config,
25-
files: ["tests/**/*.js"] })),
25+
...compat
26+
.extends("plugin:mocha/recommended")
27+
.map((config) => ({ ...config, files: ["tests/**/*.js"] })),
2628

2729
{
2830
languageOptions: {
29-
"sourceType": "script",
30-
"ecmaVersion": "latest",
31-
"globals": globals.node
32-
}
33-
},
34-
{
35-
"rules":
36-
{
37-
"array-bracket-spacing": ["error", "never"],
38-
"block-spacing": ["error", "always"],
39-
"brace-style": ["error", "1tbs"],
40-
"camelcase": ["error", { "properties": "always" }],
41-
"comma-dangle": ["error", "never"],
42-
"comma-spacing": ["error", { "before": false,
43-
"after": true }],
44-
"comma-style": ["error", "last"],
45-
"complexity": ["error", 10],
46-
"computed-property-spacing": ["error", "never"],
31+
sourceType: "script",
32+
ecmaVersion: "latest",
33+
globals: globals.node,
34+
},
35+
rules: {
36+
camelcase: ["error", { properties: "always" }],
37+
complexity: ["error", 10],
4738
"consistent-return": "error",
4839
"consistent-this": ["error", "self"],
49-
"curly": ["error", "multi-line"],
40+
curly: ["error", "multi-line"],
5041
"default-case": "error",
51-
"dot-location": ["error", "property"],
5242
"dot-notation": "error",
53-
"eol-last": "error",
54-
"eqeqeq": "error",
55-
"func-call-spacing": "error",
43+
eqeqeq: "error",
5644
"func-style": ["error", "declaration"],
5745
"guard-for-in": "error",
58-
"indent": ["error", 4, { "SwitchCase": 1,
59-
"VariableDeclarator": 1 }],
60-
"key-spacing": ["error", { "beforeColon": false,
61-
"afterColon": true }],
62-
"keyword-spacing": ["error", { "before": true,
63-
"after": true }],
64-
"linebreak-style": ["error", "unix"],
6546
"lines-around-comment": [
6647
"error",
6748
{
68-
"beforeBlockComment": false,
69-
"afterBlockComment": false,
70-
"beforeLineComment": true,
71-
"afterLineComment": false,
72-
"allowBlockStart": true,
73-
"allowBlockEnd": true,
74-
"allowObjectStart": true,
75-
"allowObjectEnd": true,
76-
"allowArrayStart": true,
77-
"allowArrayEnd": true
78-
}
49+
beforeBlockComment: false,
50+
afterBlockComment: false,
51+
beforeLineComment: true,
52+
afterLineComment: false,
53+
allowBlockStart: true,
54+
allowBlockEnd: true,
55+
allowObjectStart: true,
56+
allowObjectEnd: true,
57+
allowArrayStart: true,
58+
allowArrayEnd: true,
59+
},
7960
],
8061
"max-depth": ["error", 5],
81-
"new-cap": ["error", { "newIsCap": true,
82-
"capIsNew": true }],
83-
"new-parens": "error",
62+
"new-cap": ["error", { newIsCap: true, capIsNew: true }],
8463
"no-array-constructor": "error",
8564
"no-caller": "error",
8665
"no-catch-shadow": "error",
@@ -102,10 +81,7 @@ module.exports = [
10281
"no-ex-assign": "error",
10382
"no-extend-native": "error",
10483
"no-extra-boolean-cast": "error",
105-
"no-extra-parens": "error",
106-
"no-extra-semi": "error",
10784
"no-fallthrough": "error",
108-
"no-floating-decimal": "error",
10985
"no-func-assign": "error",
11086
"no-implied-eval": "error",
11187
"no-invalid-regexp": "error",
@@ -115,10 +91,7 @@ module.exports = [
11591
"no-lonely-if": "error",
11692
"no-loop-func": "error",
11793
"no-mixed-requires": "error",
118-
"no-mixed-spaces-and-tabs": "error",
119-
"no-multi-spaces": ["error", { "ignoreEOLComments": true }],
12094
"no-multi-str": "error",
121-
"no-multiple-empty-lines": "error",
12295
"no-unsafe-negation": "error",
12396
"no-nested-ternary": "error",
12497
"no-new-func": "error",
@@ -156,54 +129,61 @@ module.exports = [
156129
"no-useless-return": "error",
157130
"no-var": "error",
158131
"no-warning-comments": "error",
159-
"no-whitespace-before-property": "error",
160132
"no-with": "error",
161-
"object-curly-newline": ["error", { "consistent": true }],
162-
"object-curly-spacing": ["error", "always"],
163-
"object-property-newline": "error",
164133
"operator-assignment": ["error", "always"],
165-
"operator-linebreak": ["error", "after"],
166-
"padded-blocks": ["error", "never"],
167134
"prefer-const": "error",
168135
"prefer-template": "error",
169-
"quote-props": ["error", "consistent"],
170-
"quotes": ["error", "double"],
171-
"radix": "error",
172-
"semi": ["error", "always"],
173-
"semi-spacing": ["error", { "before": false,
174-
"after": true }],
175-
"space-before-blocks": ["error", "always"],
176-
"space-before-function-paren": ["error", { "anonymous": "always",
177-
"named": "never" }],
178-
"space-in-parens": ["error", "never"],
179-
"space-infix-ops": "error",
180-
"space-unary-ops": ["error", { "words": true,
181-
"nonwords": false }],
182-
"spaced-comment": ["error", "always", { "exceptions": ["-"] }],
183-
"strict": ["error", "global"],
184-
"template-curly-spacing": ["error", "never"],
136+
radix: "error",
137+
"spaced-comment": ["error", "always", { exceptions: ["-"] }],
138+
strict: ["error", "global"],
185139
"use-isnan": "error",
186-
"valid-jsdoc": ["error", {
187-
"prefer": {
188-
"return": "returns"
189-
}
190-
}],
140+
"valid-jsdoc": [
141+
"error",
142+
{
143+
prefer: {
144+
return: "returns",
145+
},
146+
},
147+
],
191148
"valid-typeof": "error",
192-
"wrap-iife": "error",
193-
"yoda": ["error", "never"],
149+
yoda: ["error", "never"],
194150

195151
// eslint-plugin-eslint-plugin
196-
"eslint-plugin/meta-property-ordering": ["error", [
197-
"type", "docs", "fixable", "messages", "schema", "deprecated", "replacedBy"
198-
]],
199-
"eslint-plugin/require-meta-docs-url": ["error", {
200-
"pattern": "https://github.com/platinumazure/eslint-plugin-qunit/blob/master/docs/rules/{{name}}.md"
201-
}],
152+
"eslint-plugin/meta-property-ordering": [
153+
"error",
154+
[
155+
"type",
156+
"docs",
157+
"fixable",
158+
"messages",
159+
"schema",
160+
"deprecated",
161+
"replacedBy",
162+
],
163+
],
164+
"eslint-plugin/require-meta-docs-url": [
165+
"error",
166+
{
167+
pattern:
168+
"https://github.com/platinumazure/eslint-plugin-qunit/blob/master/docs/rules/{{name}}.md",
169+
},
170+
],
202171

203172
// eslint-plugin-node
204-
"node/no-missing-require": ["error", {
205-
"allowModules": ["@typescript-eslint/parser"]
206-
}],
173+
"node/no-missing-require": [
174+
"error",
175+
{
176+
allowModules: ["@typescript-eslint/parser"],
177+
},
178+
],
179+
180+
// prettier
181+
"prettier/prettier": [
182+
"error",
183+
{
184+
tabWidth: 4,
185+
},
186+
],
207187

208188
// eslint-plugin-unicorn
209189
"unicorn/consistent-function-scoping": "off",
@@ -214,35 +194,32 @@ module.exports = [
214194
// eslint-disable-next-line no-warning-comments
215195
"unicorn/prefer-at": "off", // TODO: enable once we raise Node requirement to v16.6.0
216196
"unicorn/prefer-module": "off",
217-
"unicorn/prevent-abbreviations": "off"
218-
}
197+
"unicorn/prevent-abbreviations": "off",
198+
},
219199
},
220200
{
221201
files: ["**/*.md"],
222202
plugins: { markdown: eslintPluginMarkdown },
223-
processor: "markdown/markdown"
203+
processor: "markdown/markdown",
224204
},
225205
{
226-
"files": ["**/*.md/*.js", "**/*.md/*.javascript"],
227-
"languageOptions": {
228-
"parserOptions": {
229-
"sourceType": "module"
230-
}
206+
// Markdown code samples.
207+
files: ["**/*.md/*.js", "**/*.md/*.javascript"],
208+
languageOptions: {
209+
parserOptions: {
210+
sourceType: "module",
211+
},
231212
},
232-
"rules": {
233-
"brace-style": "off",
234-
"eqeqeq": "off",
213+
rules: {
214+
eqeqeq: "off",
235215
"guard-for-in": "off",
236216
"no-constant-condition": "off",
237217
"no-empty-function": "off",
238218
"no-undef": "off",
239219
"no-unused-expressions": "off",
240220
"no-unused-vars": "off",
241221
"no-var": "off",
242-
"quotes": "off",
243-
"space-before-function-paren": "off",
244-
"strict": "off"
245-
}
246-
}
222+
strict: "off",
223+
},
224+
},
247225
];
248-

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const pkg = require("./package.json");
1313
module.exports = {
1414
meta: {
1515
name: pkg.name,
16-
version: pkg.version
16+
version: pkg.version,
1717
},
1818

1919
rules: requireIndex(`${__dirname}/lib/rules`),
@@ -23,8 +23,8 @@ module.exports = {
2323
recommended: {
2424
description: [
2525
"This configuration includes rules which I recommend to avoid QUnit runtime errors or incorrect behavior, some of which can be difficult to debug. Some of these rules also encourage best practices that help QUnit work better for you.",
26-
"For ESLint `.eslintrc.js` legacy config, extend from `\"plugin:qunit/recommended\"`.",
27-
"For ESLint `eslint.config.js` flat config, load from `require('eslint-plugin-qunit/configs/recommended')`."
26+
'For ESLint `.eslintrc.js` legacy config, extend from `"plugin:qunit/recommended"`.',
27+
"For ESLint `eslint.config.js` flat config, load from `require('eslint-plugin-qunit/configs/recommended')`.",
2828
].join(" "),
2929
plugins: ["qunit"],
3030
rules: {
@@ -62,8 +62,8 @@ module.exports = {
6262
"qunit/no-throws-string": "error",
6363
"qunit/require-expect": "error",
6464
"qunit/require-object-in-propequal": "error",
65-
"qunit/resolve-async": "error"
66-
}
67-
}
68-
}
65+
"qunit/resolve-async": "error",
66+
},
67+
},
68+
},
6969
};

lib/configs/recommended.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ const plugin = require("../../index.js");
44

55
module.exports = {
66
plugins: { qunit: plugin },
7-
rules: plugin.configs.recommended.rules
7+
rules: plugin.configs.recommended.rules,
88
};

0 commit comments

Comments
 (0)