Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
130 lines (128 loc) · 3.68 KB
/
Copy patheslint.config.js
File metadata and controls
130 lines (128 loc) · 3.68 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// @ts-check
import pluginVitest from "@vitest/eslint-plugin";
import skipFormatting from "@vue/eslint-config-prettier/skip-formatting";
import {
defineConfigWithVueTs,
vueTsConfigs,
} from "@vue/eslint-config-typescript";
import pluginCypress from "eslint-plugin-cypress";
import pluginVue from "eslint-plugin-vue";
export default defineConfigWithVueTs(
pluginVue.configs["flat/recommended"],
vueTsConfigs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: [
"eslint.config.js",
"isomorphic-{wrtc,ws}/{{browser,node}.js,types.d.ts}",
"testSetupImportTFJSNode.ts",
"vitest.config.ts",
],
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: 9, // Increased from 8 for more default project files (isomorphic-ws)
},
},
},
},
{
rules: {
// taken from https://typescript-eslint.io/rules/no-unused-vars/
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
// allow for nicer names
"@typescript-eslint/no-namespace": "off",
// rule is buggy, might be necessary to disable it entirely
"@typescript-eslint/no-unnecessary-type-assertion": [
"error",
{
typesToIgnore: ["Model", "DataType"],
},
],
"@typescript-eslint/consistent-type-imports": "error",
},
},
{
files: ["webapp/**"],
rules: {
// Buggy rule in typescript-eslint 8.59 and at least until 8.62. Check if future versions fix it
"@typescript-eslint/no-unnecessary-type-assertion": "off",
},
},
{
// allow relative imports only in index.ts barrel files in discojs
files: ["discojs/**"],
ignores: ["**/index.ts"],
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["./*", "../*"],
message:
"Use alias imports ('#/...') instead of relative imports.",
},
{
group: ["#/index"],
message:
"Do not import the root barrel from within src. Import the specific subfolder barrel instead (#/subfolder/index).",
},
],
},
],
},
},
{
// barrel files in discojs should contain only re-exports, and no `export *`
files: ["discojs/**/index.ts"],
rules: {
"no-restricted-syntax": [
"error",
{
selector:
"Program > :not(ExportNamedDeclaration, ExportAllDeclaration)",
message: "Barrel files may only re-export.",
},
{
selector: "ExportNamedDeclaration:not([source])",
message: "Barrel files may only re-export.",
},
{
selector: "ExportAllDeclaration",
message: "No `export *`. Use explicit named re-exports.",
},
],
},
},
{
files: ["src/**/*.ts"],
},
{
...pluginVitest.configs.recommended,
files: ["**/*.spec.ts"],
rules: {
// broken w/ BDD https://github.com/vitest-dev/eslint-plugin-vitest/issues/675
"vitest/valid-expect": "off",
"@typescript-eslint/no-unused-expressions": "off",
},
},
{
...pluginCypress.configs.recommended,
files: ["webapp/cypress/**/*.ts"],
},
{ ignores: ["**/dist/*"] },
{ ignores: ["**/src/protobuf/"] },
// don't use linter for formatting
skipFormatting,
);