Skip to content

Commit 78d96d4

Browse files
Refactor lint config
1 parent a08f2e0 commit 78d96d4

File tree

2 files changed

+131
-125
lines changed

2 files changed

+131
-125
lines changed

eslint.config.mts

Lines changed: 131 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,150 @@
11
import eslintJs from "@eslint/js";
2-
import eslintPrettier from "eslint-config-prettier/flat";
3-
import path from "node:path";
4-
import eslintTs from "typescript-eslint";
5-
import unusedImportsPlugin from "eslint-plugin-unused-imports";
2+
import prettierConfig from "eslint-config-prettier/flat";
63
import importPlugin from "eslint-plugin-import";
74
import mochaPlugin from "eslint-plugin-mocha";
85
import unicornPlugin from "eslint-plugin-unicorn";
9-
import type { Linter } from "eslint";
6+
import unusedImportsPlugin from "eslint-plugin-unused-imports";
7+
import eslintTs, { type ConfigWithExtends } from "typescript-eslint";
108
import cursorlessOrgConfig from "./packages/cursorless-org/eslint.config.mts";
119

12-
export default eslintTs.config(
13-
{
14-
ignores: [
15-
"**/generated/**/*",
16-
"**/out/**/*",
17-
"**/dist/**/*",
18-
"**/build/**/*",
19-
"**/vendor/**/*",
20-
"**/.next/**/*",
21-
"**/.docusaurus/**/*",
22-
"data/playground/**/*",
23-
],
10+
const ignoresConfig: ConfigWithExtends = {
11+
ignores: [
12+
"**/generated/**/*",
13+
"**/out/**/*",
14+
"**/dist/**/*",
15+
"**/build/**/*",
16+
"**/vendor/**/*",
17+
"**/.next/**/*",
18+
"**/.docusaurus/**/*",
19+
"data/playground/**/*",
20+
],
21+
};
22+
23+
const rootConfig: ConfigWithExtends = {
24+
plugins: {
25+
"unused-imports": unusedImportsPlugin,
26+
import: importPlugin,
27+
unicorn: unicornPlugin,
28+
mocha: mochaPlugin,
2429
},
25-
eslintJs.configs.recommended,
26-
// We want to enable this in the long run. For now there are a lot of errors that needs to be handled.
27-
// eslintTs.configs.recommendedTypeChecked,
28-
eslintTs.configs.recommended,
29-
eslintPrettier,
30-
{
31-
plugins: {
32-
"unused-imports": unusedImportsPlugin,
33-
import: importPlugin,
34-
unicorn: unicornPlugin,
35-
mocha: mochaPlugin,
36-
},
3730

38-
languageOptions: {
39-
parser: eslintTs.parser,
40-
ecmaVersion: 6,
41-
sourceType: "module",
42-
parserOptions: {
43-
project: true,
44-
},
31+
languageOptions: {
32+
parser: eslintTs.parser,
33+
ecmaVersion: 6,
34+
sourceType: "module",
35+
parserOptions: {
36+
project: true,
4537
},
38+
},
4639

47-
settings: {
48-
"import/resolver": {
49-
typescript: {
50-
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
51-
project: ["tsconfig.json", "packages/*/tsconfig.json"],
52-
},
40+
settings: {
41+
"import/resolver": {
42+
typescript: {
43+
// Always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
44+
alwaysTryTypes: true,
45+
project: ["tsconfig.json", "packages/*/tsconfig.json"],
5346
},
5447
},
55-
56-
rules: {
57-
"import/no-relative-packages": "error",
58-
"@typescript-eslint/consistent-type-imports": "error",
59-
"@typescript-eslint/consistent-type-assertions": [
60-
"error",
61-
{
62-
assertionStyle: "as",
63-
},
64-
],
65-
"@typescript-eslint/naming-convention": [
66-
"error",
67-
{
68-
selector: ["objectLiteralProperty"],
69-
format: ["camelCase"],
70-
filter: {
71-
regex: "[.]",
72-
match: false,
73-
},
74-
},
75-
],
76-
"@typescript-eslint/no-floating-promises": "error",
77-
"@typescript-eslint/no-explicit-any": "off",
78-
"@typescript-eslint/no-inferrable-types": "off",
79-
"@typescript-eslint/no-non-null-assertion": "off",
80-
"unused-imports/no-unused-imports": "error",
81-
"@typescript-eslint/no-unused-vars": [
82-
"error",
83-
{
84-
argsIgnorePattern: "^_",
85-
varsIgnorePattern: "^_",
86-
caughtErrorsIgnorePattern: "^_",
87-
ignoreRestSiblings: true,
88-
},
89-
],
90-
curly: "error",
91-
eqeqeq: [
92-
"error",
93-
"always",
94-
{
95-
null: "never",
96-
},
97-
],
98-
"no-constant-condition": [
99-
"error",
100-
{
101-
checkLoops: false,
102-
},
103-
],
104-
"no-restricted-syntax": [
105-
"error",
106-
"MemberExpression[object.property.name='constructor'][property.name='name']",
107-
],
108-
"no-throw-literal": "error",
109-
semi: "off",
110-
"unicorn/prefer-module": "error",
111-
"mocha/no-pending-tests": "error",
112-
"mocha/no-exclusive-tests": "error",
113-
},
11448
},
115-
{
116-
files: ["**/*.tsx"],
117-
rules: {
118-
"@typescript-eslint/naming-convention": [
119-
"error",
120-
{
121-
selector: ["function"],
122-
format: ["PascalCase", "camelCase"],
49+
50+
rules: {
51+
"import/no-relative-packages": "error",
52+
"@typescript-eslint/consistent-type-imports": "error",
53+
"@typescript-eslint/consistent-type-assertions": [
54+
"error",
55+
{
56+
assertionStyle: "as",
57+
},
58+
],
59+
"@typescript-eslint/naming-convention": [
60+
"error",
61+
{
62+
selector: ["objectLiteralProperty"],
63+
format: ["camelCase"],
64+
filter: {
65+
regex: "[.]",
66+
match: false,
12367
},
124-
],
125-
},
126-
},
127-
{
128-
files: [
129-
"**/jest.config.ts",
130-
"**/docusaurus.config.mts",
131-
"**/mdx-components.tsx",
132-
"**/scripts/**",
133-
"**/resources/**",
134-
"typings/**",
135-
"**/*.js",
136-
"**/*.mjs",
137-
"eslint.config.mts",
68+
},
69+
],
70+
"@typescript-eslint/no-floating-promises": "error",
71+
"@typescript-eslint/no-explicit-any": "off",
72+
"@typescript-eslint/no-inferrable-types": "off",
73+
"@typescript-eslint/no-non-null-assertion": "off",
74+
"unused-imports/no-unused-imports": "error",
75+
"@typescript-eslint/no-unused-vars": [
76+
"error",
77+
{
78+
argsIgnorePattern: "^_",
79+
varsIgnorePattern: "^_",
80+
caughtErrorsIgnorePattern: "^_",
81+
ignoreRestSiblings: true,
82+
},
83+
],
84+
curly: "error",
85+
eqeqeq: [
86+
"error",
87+
"always",
88+
{
89+
null: "never",
90+
},
91+
],
92+
"no-constant-condition": [
93+
"error",
94+
{
95+
checkLoops: false,
96+
},
97+
],
98+
"no-restricted-syntax": [
99+
"error",
100+
"MemberExpression[object.property.name='constructor'][property.name='name']",
138101
],
102+
"no-throw-literal": "error",
103+
semi: "off",
104+
"unicorn/prefer-module": "error",
105+
"mocha/no-pending-tests": "error",
106+
"mocha/no-exclusive-tests": "error",
107+
},
108+
};
139109

140-
extends: [eslintTs.configs.disableTypeChecked],
110+
const tsxConfig: ConfigWithExtends = {
111+
files: ["**/*.tsx"],
112+
rules: {
113+
"@typescript-eslint/naming-convention": [
114+
"error",
115+
{
116+
selector: ["function"],
117+
format: ["PascalCase", "camelCase"],
118+
},
119+
],
141120
},
121+
};
122+
123+
const disabledTypeCheckConfig: ConfigWithExtends = {
124+
files: [
125+
"**/jest.config.ts",
126+
"**/docusaurus.config.mts",
127+
"**/mdx-components.tsx",
128+
"**/scripts/**",
129+
"**/resources/**",
130+
"typings/**",
131+
"**/*.js",
132+
"**/*.mjs",
133+
"eslint.config.mts",
134+
],
135+
136+
extends: [eslintTs.configs.disableTypeChecked],
137+
};
138+
139+
export default eslintTs.config(
140+
ignoresConfig,
141+
eslintJs.configs.recommended,
142+
// We want to enable this in the long run. For now there are a lot of errors that needs to be handled.
143+
// eslintTs.configs.recommendedTypeChecked,
144+
eslintTs.configs.recommended,
145+
prettierConfig,
146+
rootConfig,
147+
tsxConfig,
148+
disabledTypeCheckConfig,
142149
cursorlessOrgConfig,
143150
);

packages/cursorless-org-docs/src/plugins/scope-tests-plugin.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export default function prepareAssetsPlugin(
2121
name: "scope-tests-plugin",
2222

2323
loadContent(): ScopeTests {
24-
// eslint-disable-next-line unicorn/prefer-module
2524
const repoRoot = path.join(__dirname, "../../../..");
2625
process.env.CURSORLESS_REPO_ROOT = repoRoot;
2726
return prepareAssets();

0 commit comments

Comments
 (0)