forked from YXL76/cloudmusic-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
100 lines (95 loc) · 2.91 KB
/
.eslintrc.cjs
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
// @ts-check
/**
* @type {Partial<import('eslint').Linter.RulesRecord>}
*/
const baseNodeTsRules = {
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/lines-between-class-members": "error",
"@typescript-eslint/member-ordering": "warn",
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/semi": "warn",
"no-empty": ["error", { allowEmptyCatch: true }],
};
/**
* @param {string} files -
* @param {string} project -
* @returns {import('eslint').Linter.ConfigOverride} -
*/
const nodeTsConfig = (files, project) => ({
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended",
],
files,
parserOptions: {
ecmaVersion: 10,
project: `${__dirname}${project}`,
sourceType: "module",
},
plugins: ["@typescript-eslint", "prettier"],
rules: baseNodeTsRules,
});
/**
* @param {string} files -
* @param {string} project -
* @returns {import('eslint').Linter.ConfigOverride} -
*/
const browserTsConfig = (files, project) => ({
env: { browser: true, node: false },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
],
files,
parserOptions: {
ecmaVersion: 10,
project: `${__dirname}${project}`,
sourceType: "module",
},
plugins: ["@typescript-eslint", "prettier", "react"],
rules: {
...baseNodeTsRules,
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
},
settings: { react: { version: "17.0" } },
});
/**@type {import('eslint').Linter.Config}*/
const config = {
env: { browser: false, node: true },
extends: ["eslint:recommended", "plugin:prettier/recommended"],
ignorePatterns: ["/packages/wasi/**/*.*", "/packages/wasm/**/*.*", "/scripts/**/*.*", "*.json"],
parser: "@typescript-eslint/parser",
plugins: ["prettier"],
rules: {
curly: "warn",
eqeqeq: "warn",
"no-empty": ["error", { allowEmptyCatch: true }],
"no-throw-literal": "warn",
semi: "warn",
"sort-imports": [
"warn",
{
allowSeparatedGroups: false,
ignoreCase: false,
ignoreDeclarationSort: false,
ignoreMemberSort: false,
memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
},
],
},
overrides: [
nodeTsConfig("./packages/@types/**/*.ts", "/packages/@types/tsconfig.json"),
nodeTsConfig("./packages/client/**/*.ts", "/packages/client/tsconfig.json"),
nodeTsConfig("./packages/server/**/*.ts", "/packages/server/tsconfig.json"),
nodeTsConfig("./packages/shared/**/*.ts", "/packages/shared/tsconfig.json"),
browserTsConfig("./packages/webview/**/*.ts*", "/packages/webview/tsconfig.json"),
],
};
module.exports = config;