-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
86 lines (79 loc) · 4.24 KB
/
Copy patheslint.config.js
File metadata and controls
86 lines (79 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// eslint.config.js (ESM)
// @ts-ignore
import { defineConfig } from "eslint/config"
// @ts-ignore
import stylistic from "@stylistic/eslint-plugin"
// @ts-ignore
import jsdoc from "eslint-plugin-jsdoc"
export default defineConfig([
{
...stylistic.configs.recommended,
ignores: ["eslint.config.js", "node_modules/"],
files: ["./**/*.js"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "script",
globals: {
$: "readonly",
bean: "readonly",
md5: "readonly",
google: "readonly"
},
},
plugins: {
"@stylistic": stylistic,
jsdoc,
},
rules: {
// 0) Flag unused declarations (functions/vars) and private class members
"no-unused-vars": ["warn", {
"vars": "local",
"args": "after-used",
}],
"no-unused-private-class-members": "warn",
// Spacing: prevent extra/unnecessary spaces (auto-fixable where applicable)
"no-multi-spaces": "error",
"no-trailing-spaces": "error",
"@stylistic/key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "strict" }],
// Prevent redeclaring base-class fields like `element`
"no-restricted-syntax": ["warn", {
"selector": "ClassDeclaration[superClass.name='cJQueryWidgetClass'] PropertyDefinition[key.name='element']",
"message": "Do not redeclare `element` in subclasses of cJQueryWidgetClass; it is set by the base class.",
}],
// 1) No trailing semicolons (auto-fixable)
// Note: core `semi` is deprecated from ESLint 8.53 but still works in ESLint 9;
// it may be removed in ESLint 11. For now this will auto-remove semicolons.
semi: ["error", "never"], // [1](https://eslint.org/docs/latest/rules/semi)
"no-extra-semi": "error", // (defensive) [2](https://github.com/eslint/eslint/blob/main/docs/src/rules/curly.md)
// 2) Put single-statement bodies on their own line (auto-fixable)
// e.g., `if (x) doThing()` ->
// `if (x)\n doThing()`
"nonblock-statement-body-position": ["error", "below"],// [3](https://eslint.org/docs/latest/rules/nonblock-statement-body-position)
// Require a blank line after control blocks (auto-fixable)
"padding-line-between-statements": ["error",
{ "blankLine": "always", "prev": "block-like", "next": "*" },
{ "blankLine": "always", "prev": "*", "next": ["case", "default"] },
],
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 0 }],
// Require a newline after `{` in object/import/export braces
"@stylistic/object-curly-newline": ["error", {
"ObjectExpression": "always",
"ObjectPattern": "always",
"ImportDeclaration": "always",
"ExportDeclaration": "always",
}],
// Put each function call argument on its own line (puts `{` on its own line for object literals)
"@stylistic/function-call-argument-newline": ["error", "always"],
// When multiple arguments, put `(` and first argument on a new line
"@stylistic/function-paren-newline": ["error", "multiline-arguments"],
// Strongly recommended along with the above so fixes are unambiguous
// Require braces for all control statements (auto-fixable)
curly: ["error", "multi"], // [4](https://eslint.org/docs/latest/rules/curly)
// Keep opening braces on the same line as the control statement (auto-fixable)
"@stylistic/brace-style": ["error", "1tbs", { "allowSingleLine": false }], // [5](https://eslint.style/rules/default/brace-style)
// Enforce consistent indentation (auto-fixable)
"@stylistic/indent": ["error", "tab", { "SwitchCase": 1 }], // [6](https://eslint.style/rules/default/indent)
"jsdoc/check-alignment": "error",
},
},
])