Skip to content

Commit e3e8060

Browse files
committed
Migrate to flat config format
1 parent 313dc43 commit e3e8060

File tree

2 files changed

+269
-0
lines changed

2 files changed

+269
-0
lines changed

.eslintrc.json [DEPRECATED]

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"browser": true,
5+
"es6": true,
6+
"greasemonkey": true,
7+
"jquery": true
8+
},
9+
"parserOptions": {
10+
"ecmaVersion": "latest",
11+
"sourceType": "script",
12+
"ecmaFeatures": {
13+
"globalReturn ": true,
14+
"impliedStrict": true
15+
}
16+
},
17+
"extends": [
18+
"eslint:recommended",
19+
"plugin:css/recommended",
20+
"plugin:jsonc/recommended-with-json",
21+
"plugin:no-jquery/deprecated",
22+
"plugin:regexp/recommended"
23+
],
24+
"plugins": [
25+
"css",
26+
"jsonc",
27+
"no-jquery",
28+
"regexp"
29+
],
30+
"rules": {
31+
"complexity": ["warn", 20],
32+
"eqeqeq": "warn",
33+
"func-style": "off",
34+
"indent": ["warn","tab", { "ignoreComments": false, "SwitchCase": 1 } ],
35+
"linebreak-style": ["warn","unix"],
36+
"max-len": "off",
37+
"max-statements-per-line": "off",
38+
"new-cap": "off",
39+
"no-alert": "warn",
40+
"no-console": "warn",
41+
"no-dupe-keys": "warn",
42+
"no-extra-semi": "warn",
43+
"no-inline-comments": "off",
44+
"no-magic-numbers": "off",
45+
"no-misleading-character-class": "warn",
46+
"no-mixed-spaces-and-tabs": "warn",
47+
"no-multiple-empty-lines": "off",
48+
"no-tabs": "off",
49+
"no-unused-labels": "warn",
50+
"no-unused-vars": ["warn", {"vars": "all", "args": "after-used"}],
51+
"no-useless-escape": "warn",
52+
"padded-blocks": "off",
53+
"quotes": ["warn", "single", { "allowTemplateLiterals": true }] ,
54+
"require-jsdoc": "off",
55+
"require-unicode-regexp": "off",
56+
"semi": ["warn","always"],
57+
"space-before-function-paren": "off",
58+
"unicode-bom": ["warn", "never"]
59+
},
60+
"reportUnusedDisableDirectives": true
61+
}

eslint.config.js

+208
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
/* eslint-disable @stylistic/js/quotes */
2+
/* eslint-disable @stylistic/js/indent */
3+
4+
// import * as cssPlugin from "eslint-plugin-css";
5+
import css from "@eslint/css";
6+
import eslintPluginJsonc from 'eslint-plugin-jsonc';
7+
import json from "@eslint/json";
8+
import noJquery from "eslint-plugin-no-jquery";
9+
import * as regexpPlugin from "eslint-plugin-regexp";
10+
import markdown from "@eslint/markdown";
11+
import globals from "globals";
12+
import js from "@eslint/js";
13+
import stylisticJs from "@stylistic/eslint-plugin-js";
14+
15+
16+
export default [
17+
{
18+
files: ['**/*.js', '**/*.mjs'],
19+
...js.configs.recommended
20+
},
21+
// cssPlugin.configs["flat/recommended"],
22+
...eslintPluginJsonc.configs['flat/recommended-with-jsonc'],
23+
{
24+
files: ['**/*.js', '**/*.mjs'],
25+
...regexpPlugin.configs["flat/recommended"],
26+
},
27+
...markdown.configs.recommended,
28+
{
29+
files: ["**/*.js"],
30+
ignores: ["**/*.min.js"],
31+
32+
plugins: {
33+
"@stylistic/js": stylisticJs
34+
},
35+
36+
linterOptions: {
37+
reportUnusedDisableDirectives: true,
38+
},
39+
40+
languageOptions: {
41+
globals: {
42+
...globals.browser,
43+
...globals.greasemonkey,
44+
...globals.jquery,
45+
},
46+
47+
ecmaVersion: "latest",
48+
sourceType: "module",
49+
50+
51+
parserOptions: {
52+
ecmaFeatures: {
53+
"globalReturn ": true,
54+
impliedStrict: true,
55+
},
56+
},
57+
},
58+
59+
rules: {
60+
complexity: ["warn", 20],
61+
eqeqeq: "warn",
62+
"func-style": "off",
63+
64+
"@stylistic/js/indent": ["warn", "tab", {
65+
ignoreComments: false,
66+
SwitchCase: 1,
67+
}],
68+
69+
"@stylistic/js/linebreak-style": ["warn", "unix"],
70+
"@stylistic/js/max-len": "off",
71+
"@stylistic/js/max-statements-per-line": "off",
72+
"new-cap": "off",
73+
"no-alert": "warn",
74+
"no-console": "warn",
75+
"no-dupe-keys": "warn",
76+
"@stylistic/js/no-extra-semi": "warn",
77+
"no-inline-comments": "off",
78+
"no-magic-numbers": "off",
79+
"no-misleading-character-class": "warn",
80+
"@stylistic/js/no-mixed-spaces-and-tabs": "warn",
81+
"@stylistic/js/no-multiple-empty-lines": "off",
82+
"@stylistic/js/no-tabs": "off",
83+
"no-unused-labels": "warn",
84+
85+
"no-unused-vars": ["warn", {
86+
vars: "all",
87+
args: "after-used",
88+
}],
89+
90+
"no-useless-escape": "warn",
91+
"@stylistic/js/padded-blocks": "off",
92+
93+
"@stylistic/js/quotes": ["warn", "single", {
94+
allowTemplateLiterals: true,
95+
}],
96+
97+
"require-jsdoc": "off",
98+
"require-unicode-regexp": "off",
99+
"@stylistic/js/semi": ["warn", "always"],
100+
"@stylistic/js/space-before-function-paren": "off",
101+
"unicode-bom": ["warn", "never"],
102+
},
103+
104+
},
105+
106+
107+
// https://github.com/eslint/json#usage
108+
{
109+
plugins: {
110+
json,
111+
},
112+
},
113+
// lint JSON files // (from: https://github.com/eslint/json#recommended-configuration)
114+
{
115+
files: ["**/*.json"],
116+
language: "json/json",
117+
...json.configs.recommended,
118+
},
119+
120+
// lint JSON-C files
121+
{
122+
// files: ["**/*.jsonc"],
123+
files: ["**/*.jsonc", ".vscode/*.json"], // https://github.com/eslint/json/pull/11
124+
language: "json/jsonc",
125+
...json.configs.recommended,
126+
},
127+
128+
129+
130+
// https://github.com/eslint/markdown#configuring
131+
{
132+
// 1. Add the plugin
133+
plugins: {
134+
markdown
135+
}
136+
},
137+
138+
// https://www.npmjs.com/package/eslint-plugin-markdown
139+
// https://eslint.org/docs/latest/use/configure/plugins
140+
// https://github.com/eslint/json
141+
{
142+
// 2. Enable the Markdown processor for all .md files.
143+
files: ["**/*.md"],
144+
// files: ["**/*.md/*.js"],
145+
// plugins: {
146+
// markdown
147+
// },
148+
processor: "markdown/markdown"
149+
},
150+
{
151+
// // 3. Optionally, customize the configuration ESLint uses for ```js
152+
// // fenced code blocks inside .md files.
153+
files: ["**/*.md/*.js"],
154+
rules: {
155+
// ...
156+
157+
// 2. Disable other rules.
158+
// "no-console": "off",
159+
// "import/no-unresolved": "off"
160+
}
161+
},
162+
163+
164+
165+
166+
167+
168+
169+
170+
// https://eslint.org/blog/2025/02/eslint-css-support/ [NEW ADDITION 20/2/2025]
171+
//
172+
// lint css files
173+
{
174+
files: ["**/*.css"],
175+
plugins: {
176+
css,
177+
},
178+
language: "css/css",
179+
rules: {
180+
"css/no-duplicate-imports": "error",
181+
},
182+
},
183+
184+
185+
186+
187+
// https://eslint.org/docs/latest/use/configure/ignore
188+
// https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files
189+
{
190+
// Note: there should be no other properties in this object
191+
ignores: [
192+
193+
"node_modules/*",
194+
"**/*.min.js",
195+
"package-lock.json"
196+
197+
]
198+
199+
}
200+
201+
202+
203+
204+
205+
206+
207+
208+
];

0 commit comments

Comments
 (0)