-
-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy patheslint.config.mts
More file actions
168 lines (159 loc) · 4.58 KB
/
eslint.config.mts
File metadata and controls
168 lines (159 loc) · 4.58 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/* eslint-disable import/no-relative-packages */
import type { ConfigWithExtends, Plugin } from "@eslint/config-helpers";
import eslintJs from "@eslint/js";
import prettierConfig from "eslint-config-prettier/flat";
import importPlugin from "eslint-plugin-import";
import mochaPlugin from "eslint-plugin-mocha";
import unicornPlugin from "eslint-plugin-unicorn";
import unusedImportsPlugin from "eslint-plugin-unused-imports";
import { defineConfig } from "eslint/config";
import tsEslint from "typescript-eslint";
import { commonConfig } from "./packages/lib-common/eslintConfig";
import { cursorlessEngineConfig } from "./packages/lib-engine/eslintConfig";
import { cursorlessOrgConfig } from "./packages/app-web/eslintConfig";
import { cursorlessVscodeConfig } from "./packages/app-vscode/eslintConfig";
const ignoresConfig: ConfigWithExtends = {
ignores: [
// Workspace
".git/**",
"resources/playground/**",
// Packages
"packages/*/out/**",
"packages/*/dist/**",
"packages/app-web-docs/.docusaurus/**",
"packages/app-neovim/cursorless.nvim/**",
"packages/app-vscode/src/keyboard/grammar/generated/**",
"packages/lib-engine/src/customCommandGrammar/generated/**",
"packages/lib-engine/src/snippets/vendor/**",
// Anywhere
"**/node_modules/**",
],
};
const rootConfig: ConfigWithExtends = {
plugins: {
"unused-imports": unusedImportsPlugin,
import: importPlugin,
unicorn: unicornPlugin,
// eslint-plugin-mocha's type definitions don't match ESLint 9's Plugin type yet.
mocha: mochaPlugin as Plugin,
},
languageOptions: {
parser: tsEslint.parser,
ecmaVersion: 2022,
sourceType: "module",
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
settings: {
"import/resolver": {
typescript: {
// Always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
alwaysTryTypes: true,
noWarnOnMultipleProjects: true,
project: ["tsconfig.json", "packages/*/tsconfig.json"],
},
},
},
rules: {
"import/no-relative-packages": "error",
"import/no-duplicates": "error",
"unused-imports/no-unused-imports": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-assertions": [
"error",
{
assertionStyle: "as",
},
],
"@typescript-eslint/naming-convention": [
"error",
{
selector: ["objectLiteralProperty"],
format: ["camelCase"],
filter: {
regex: "[.]",
match: false,
},
},
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
curly: "error",
eqeqeq: [
"error",
"always",
{
null: "never",
},
],
"no-constant-condition": [
"error",
{
checkLoops: false,
},
],
"no-restricted-syntax": [
"error",
"MemberExpression[object.property.name='constructor'][property.name='name']",
],
"no-throw-literal": "error",
semi: "off",
"unicorn/prefer-module": "error",
"mocha/no-pending-tests": "error",
"mocha/no-exclusive-tests": "error",
},
};
const tsxConfig: ConfigWithExtends = {
files: ["**/*.tsx"],
rules: {
"@typescript-eslint/naming-convention": [
"error",
{
selector: ["function"],
format: ["PascalCase", "camelCase"],
},
],
},
};
const disabledTypeCheckConfig: ConfigWithExtends = {
files: [
// Workspace
"eslint.config.mts",
// Packages
"packages/*/vite.config.ts",
"packages/*/eslintConfig.ts",
"packages/*/jest.config.ts",
"packages/app-web-docs/docusaurus.config.mts",
// Anywhere
"**/*.js",
],
extends: [tsEslint.configs.disableTypeChecked],
};
export default defineConfig(
ignoresConfig,
eslintJs.configs.recommended,
// We want to enable this in the long run. For now there are a lot of errors that needs to be handled.
// eslintTs.configs.recommendedTypeChecked,
tsEslint.configs.recommended,
prettierConfig,
rootConfig,
tsxConfig,
disabledTypeCheckConfig,
commonConfig,
cursorlessEngineConfig,
cursorlessVscodeConfig,
cursorlessOrgConfig,
);