-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
145 lines (132 loc) · 4.16 KB
/
eslint.config.mjs
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
144
145
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { FlatCompat } from "@eslint/eslintrc"
import js from "@eslint/js"
import eslintPluginImportX from "eslint-plugin-import-x"
import noOnlyTests from "eslint-plugin-no-only-tests"
import path from "node:path"
import { fileURLToPath } from "node:url"
import tseslint from "typescript-eslint"
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 tseslint.config([
{
ignores: [
"eslint.config.mjs",
"packages/integration-tests/cypress.config.ts",
"packages/integration-tests/test-environment/**/*",
"vitest.workspace.js",
"packages/integration-tests/dist/",
"packages/library/dist/",
"packages/library/vite.config.js",
],
},
...compat.extends(
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/strict-type-checked",
"prettier"
),
eslintPluginImportX.flatConfigs.recommended,
eslintPluginImportX.flatConfigs.typescript,
{
files: ["packages/integration-tests/cypress/support/tui-sandbox.ts"],
rules: {
// it's important that no relative packages are imported in this file,
// because the end user does not have access to them in their own
// project.
"import-x/no-relative-packages": "error",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/unbound-method": "off",
},
},
{
plugins: {
"no-only-tests": noOnlyTests,
},
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
parserOptions: {
project: true,
},
},
rules: {
"no-only-tests/no-only-tests": "error",
"@typescript-eslint/require-await": "off",
"no-restricted-syntax": [
"error",
{
selector: "TSEnumDeclaration",
message: "Don't declare enums",
},
],
"@typescript-eslint/no-restricted-types": [
"error",
{
types: {
Omit: "Prefer using Except from type-fest instead. That one checks that the unwanted properties actually exist on the source object. See https://github.com/sindresorhus/type-fest",
},
},
],
"@typescript-eslint/restrict-template-expressions": [
"error",
{
allowNumber: true,
allowBoolean: true,
},
],
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-import-type-side-effects": "error",
"@typescript-eslint/explicit-module-boundary-types": ["warn"],
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],
"lines-between-class-members": [
"error",
"always",
{
exceptAfterSingleLine: true,
},
],
"no-empty-function": [
"error",
{
allow: ["constructors"],
},
],
"no-return-await": "off",
"@typescript-eslint/return-await": "error",
"no-useless-constructor": "off",
"no-void": [
"error",
{
allowAsStatement: true,
},
],
"@typescript-eslint/no-unused-vars": "off",
"import-x/no-extraneous-dependencies": [
"error",
{
// Forbid the import of external modules that are not declared in the
// package.json. This rule makes sure all the expected dependencies are
// available at runtime. Because we leave out devDependencies from
// production, there might be an issue if production code depended on a
// devDependency.
//
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-extraneous-dependencies.md
devDependencies: [
// don't check this in the files that match these
"**/*.test.ts",
],
optionalDependencies: false,
peerDependencies: false,
},
],
},
},
])