-
Notifications
You must be signed in to change notification settings - Fork 198
/
eslint.config.js
110 lines (97 loc) · 3.16 KB
/
eslint.config.js
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import es from "eslint-plugin-es-x";
import html from "eslint-plugin-html";
import markdown from "eslint-plugin-markdown";
import globals from "globals";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default [
{ ignores: ["**/*\\{.,-}min.js", "docs/Chart.Financial.js"] },
...compat.extends("chartjs", "plugin:es-x/restrict-to-es2022"),
...markdown.configs.recommended,
{
files: ["**/*.html"],
plugins: { html },
},
{
plugins: {
es
},
languageOptions: {
globals: {
...globals.browser,
...globals.node,
// TODO: it would be nicer to apply these only to tests
afterEach: "readonly",
describe: "readonly",
expect: "readonly",
it: "readonly"
},
ecmaVersion: 2022,
sourceType: "module",
parserOptions: {
ecmaFeatures: {
impliedStrict: true,
modules: true,
},
},
},
settings: {
es: {
aggressive: true,
},
},
rules: {
"class-methods-use-this": "off",
complexity: ["warn", 10],
"max-statements": ["warn", 30],
"no-empty-function": "off",
"no-use-before-define": ["error", {
functions: false,
}],
"es/no-import-meta": "off",
"es/no-async-iteration": "error",
"es/no-malformed-template-literals": "error",
"es/no-regexp-lookbehind-assertions": "error",
"es/no-regexp-named-capture-groups": "error",
"es/no-regexp-s-flag": "error",
"es/no-regexp-unicode-property-escapes": "error",
"es/no-dynamic-import": "off",
},
},
...compat.extends("chartjs", "plugin:@typescript-eslint/recommended").map(config => ({
...config,
files: ["**/*.ts"],
})),
{
files: ["**/*.ts"],
plugins: {
"@typescript-eslint": typescriptEslint,
},
languageOptions: {
parser: tsParser,
},
rules: {
complexity: ["warn", 10],
"max-statements": ["warn", 30],
indent: "off",
"@typescript-eslint/indent": ["error", 2],
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "error",
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error",
"space-before-function-paren": "off",
"@typescript-eslint/space-before-function-paren": [2, "never"],
},
}
];