Skip to content

Commit f29f9f0

Browse files
authored
chore: migrate to eslint flat config (#245)
1 parent 9003146 commit f29f9f0

File tree

7 files changed

+354
-247
lines changed

7 files changed

+354
-247
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

eslint.config.js

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import html from "eslint-plugin-html";
2+
import es from "eslint-plugin-es";
3+
import globals from "globals";
4+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
5+
import tsParser from "@typescript-eslint/parser";
6+
import path from "node:path";
7+
import { fileURLToPath } from "node:url";
8+
import js from "@eslint/js";
9+
import { FlatCompat } from "@eslint/eslintrc";
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = path.dirname(__filename);
13+
const compat = new FlatCompat({
14+
baseDirectory: __dirname,
15+
recommendedConfig: js.configs.recommended,
16+
allConfig: js.configs.all
17+
});
18+
19+
export default [
20+
{ ignores: ["**/*\\{.,-}min.js", "docs/Chart.Financial.js"] },
21+
...compat.extends("chartjs", "plugin:es/restrict-to-es2018", "plugin:markdown/recommended"),
22+
{
23+
files: ["**/*.html"],
24+
plugins: { html },
25+
},
26+
{
27+
plugins: {
28+
es
29+
},
30+
31+
languageOptions: {
32+
globals: {
33+
...globals.browser,
34+
...globals.node,
35+
36+
// TODO: it would be nicer to apply these only to tests
37+
afterEach: "readonly",
38+
describe: "readonly",
39+
expect: "readonly",
40+
it: "readonly"
41+
},
42+
43+
ecmaVersion: 2022,
44+
sourceType: "module",
45+
46+
parserOptions: {
47+
ecmaFeatures: {
48+
impliedStrict: true,
49+
modules: true,
50+
},
51+
},
52+
},
53+
54+
settings: {
55+
es: {
56+
aggressive: true,
57+
},
58+
},
59+
60+
rules: {
61+
"class-methods-use-this": "off",
62+
complexity: ["warn", 10],
63+
"max-statements": ["warn", 30],
64+
"no-empty-function": "off",
65+
66+
"no-use-before-define": ["error", {
67+
functions: false,
68+
}],
69+
70+
"es/no-import-meta": "off",
71+
"es/no-async-iteration": "error",
72+
"es/no-malformed-template-literals": "error",
73+
"es/no-regexp-lookbehind-assertions": "error",
74+
"es/no-regexp-named-capture-groups": "error",
75+
"es/no-regexp-s-flag": "error",
76+
"es/no-regexp-unicode-property-escapes": "error",
77+
"es/no-dynamic-import": "off",
78+
},
79+
},
80+
...compat.extends("chartjs", "plugin:@typescript-eslint/recommended").map(config => ({
81+
...config,
82+
files: ["**/*.ts"],
83+
})),
84+
{
85+
files: ["**/*.ts"],
86+
87+
plugins: {
88+
"@typescript-eslint": typescriptEslint,
89+
},
90+
91+
languageOptions: {
92+
parser: tsParser,
93+
},
94+
95+
rules: {
96+
complexity: ["warn", 10],
97+
"max-statements": ["warn", 30],
98+
indent: "off",
99+
"@typescript-eslint/indent": ["error", 2],
100+
"no-use-before-define": "off",
101+
"@typescript-eslint/no-use-before-define": "error",
102+
"no-shadow": "off",
103+
"@typescript-eslint/no-shadow": "error",
104+
"space-before-function-paren": "off",
105+
"@typescript-eslint/space-before-function-paren": [2, "never"],
106+
},
107+
}
108+
];

0 commit comments

Comments
 (0)