-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy patheslint.config.mjs
More file actions
143 lines (140 loc) · 4.89 KB
/
Copy patheslint.config.mjs
File metadata and controls
143 lines (140 loc) · 4.89 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
131
132
133
134
135
136
137
138
139
140
141
142
143
// SPDX-FileCopyrightText: 2024 Gnuxie <Gnuxie@protonmail.com>
//
// SPDX-License-Identifier: 0BSD
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import tsplugin from "@typescript-eslint/eslint-plugin";
// this configuration file stilli includes random shite from these directories
// and I do not understand why. It is one of the most frustraiting things
// my guess is that there is some hidden ambient config that is included
// full of eslint defaults that we can't intercept??
// I don't know, but it's one of the most frustraiting things ever.
const ignores = [
"**/docs/**",
"**/.husky/**",
"**/coverage/**",
"**/dist/**",
"**/lib/**",
"**/node_modules/**",
"**/*.js",
"**/*.jsx",
];
export default tseslint.config(
{
ignores,
},
{
// This is a typescript-eslint configurartion for typescript files.
// This will not work against js files.
files: [
"packages/**/src/**/*.ts",
"packages/**/src/**/*.tsx",
"packages/**/test/**/*.ts",
"packages/**/test/**/*.tsx",
"apps/**/src/**/*.ts",
"apps/**/src/**/*.tsx",
"apps/**/test/**/*.ts",
"apps/**/test/**/*.tsx",
],
extends: [
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
],
languageOptions: {
parserOptions: {
project: [
"./apps/*/tsconfig.test.json",
"./apps/*/tsconfig.json",
"./packages/*/tsconfig.test.json",
"./packages/*/tsconfig.json",
],
tsconfigRootDir: import.meta.dirname,
},
},
// This is needed in order to specify the desired behavior for its rules
plugins: {
"@typescript-eslint": tsplugin,
},
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" },
],
// we implement a lot of interfaces that return promises with synchronous functions.
"require-await": "off",
"@typescript-eslint/require-await": "off",
// we need never because our code can be wrong!
"@typescript-eslint/restrict-template-expressions": [
"error",
{ allowNever: true },
],
// stylistic recommendation that doesn't play well with event emitter interfaces.
"@typescript-eslint/unified-signatures": "off",
// There are some compelling arguments for including this rule,
// but other than using namespaces, we don't have granular enough modules
// to be able to depend on their behaviour. This should be revisited.
"@typescript-eslint/no-extraneous-class": "off",
"@typescript-eslint/unbound-method": ["error", { ignoreStatic: true }],
// We want to be able to create infinite loops.
"@typescript-eslint/no-unnecessary-condition": [
"error",
{ allowConstantLoopConditions: true },
],
// This rule is unstable as hell and tries to apply itself to interfaces.
"@typescript-eslint/no-unnecessary-type-parameters": "off",
"@typescript-eslint/no-empty-object-type": [
"error",
{ allowInterfaces: "with-single-extends" },
],
"@typescript-eslint/no-deprecated": [
"error",
{
allow: [
// Idk why they did this but whatever https://github.com/element-hq/matrix-bot-sdk/pull/66/changes#r2965217095
{
from: "package",
name: "getRoomStateEvent",
package: "@vector-im/matrix-bot-sdk",
},
],
},
],
// We intentionally use enums to compare against non enum values, but no doubt this one will bite us in the ass later
},
ignores,
},
{
files: ["packages/matrix-protection-suite/**/*.{ts,tsx}"],
rules: {
// We intentionally compare enums to non enum values but no doubt it will bite us in the ass later
"@typescript-eslint/no-unsafe-enum-comparison": "off",
},
ignores,
},
{
files: ["apps/draupnir/**/*.{ts,tsx}"],
rules: {
"@typescript-eslint/no-deprecated": [
"error",
{
allow: [
{ from: "file", name: "logMessage" },
{ from: "file", name: "allocateProtection" },
// Idk why they did this but whatever https://github.com/element-hq/matrix-bot-sdk/pull/66/changes#r2965217095
{
from: "package",
name: "getRoomStateEvent",
package: "@vector-im/matrix-bot-sdk",
},
],
},
],
// We intentionally compare enums to non enum values but no doubt it will bite us in the ass later
"@typescript-eslint/no-unsafe-enum-comparison": "off",
},
ignores,
}
);