Skip to content

Commit dad9837

Browse files
Started working on flat config for eslint
1 parent 6039ab8 commit dad9837

File tree

13 files changed

+243
-296
lines changed

13 files changed

+243
-296
lines changed

.eslintrc.json

Lines changed: 0 additions & 120 deletions
This file was deleted.

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
runs-on: ubuntu-latest
1818
env:
1919
CURSORLESS_REPO_ROOT: ${{ github.workspace }}
20-
ESLINT_USE_FLAT_CONFIG: false
2120

2221
steps:
2322
- name: Checkout repository

eslint.config.mts

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
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 unusedImports from "eslint-plugin-unused-imports";
6+
import importPlugin from "eslint-plugin-import";
7+
import mochaPlugin from "eslint-plugin-mocha";
8+
import eslintPluginUnicorn from "eslint-plugin-unicorn";
9+
import type { Linter } from "eslint";
10+
import cursorlessOrgConfig from "./packages/cursorless-org/eslint.config.mts";
11+
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+
],
24+
},
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": unusedImports,
33+
import: importPlugin,
34+
unicorn: eslintPluginUnicorn,
35+
mocha: mochaPlugin,
36+
},
37+
38+
languageOptions: {
39+
parser: eslintTs.parser,
40+
ecmaVersion: 6,
41+
sourceType: "module",
42+
parserOptions: {
43+
project: true,
44+
},
45+
},
46+
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+
},
53+
},
54+
},
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+
},
114+
},
115+
{
116+
files: ["**/*.tsx"],
117+
rules: {
118+
"@typescript-eslint/naming-convention": [
119+
"error",
120+
{
121+
selector: ["function"],
122+
format: ["PascalCase", "camelCase"],
123+
},
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",
138+
],
139+
140+
extends: [eslintTs.configs.disableTypeChecked],
141+
},
142+
cursorlessOrgConfig,
143+
);

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"fix:syncpack": "pnpm syncpack fix-mismatches",
1919
"init-vscode-sandbox": "pnpm --filter=@cursorless/cursorless-vscode init-launch-sandbox",
2020
"lint:meta": "pnpm run meta-updater:base --test",
21-
"lint:ts": "cross-env ESLINT_USE_FLAT_CONFIG=false eslint packages --ext ts,tsx,mts",
21+
"lint:ts": "eslint packages --ext ts,tsx,mts",
2222
"lint": "pnpm run lint:meta && syncpack list-mismatches && pnpm run lint:ts",
2323
"meta-updater:base": "pnpm --filter=@cursorless/meta-updater build && meta-updater",
2424
"preinstall": "npx only-allow pnpm",
@@ -31,23 +31,23 @@
3131
"watch:tsc": "tsc --build --watch"
3232
},
3333
"devDependencies": {
34+
"@eslint/js": "^9.31.0",
35+
"@eslint/eslintrc": "^3.3.1",
3436
"@pnpm/meta-updater": "^2.0.6",
3537
"@types/node": "^24.0.15",
36-
"@typescript-eslint/eslint-plugin": "^8.38.0",
37-
"@typescript-eslint/parser": "^8.38.0",
38-
"cross-env": "^7.0.3",
3938
"esbuild": "^0.25.8",
4039
"eslint": "^9.31.0",
4140
"eslint-config-prettier": "^10.1.8",
4241
"eslint-import-resolver-typescript": "^4.4.4",
4342
"eslint-plugin-import": "^2.32.0",
44-
"eslint-plugin-mocha": "^10.5.0",
45-
"eslint-plugin-unicorn": "^56.0.1",
43+
"eslint-plugin-mocha": "^11.1.0",
44+
"eslint-plugin-unicorn": "^60.0.0",
4645
"eslint-plugin-unused-imports": "^4.1.4",
4746
"prettier": "~3.3.3",
4847
"prettier-plugin-tailwindcss": "^0.6.14",
4948
"syncpack": "^13.0.4",
50-
"typescript": "^5.8.3"
49+
"typescript": "^5.8.3",
50+
"typescript-eslint": "^8.38.0"
5151
},
5252
"pnpm": {
5353
"patchedDependencies": {

packages/cursorless-engine/src/processTargets/.eslintrc.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/BaseScopeHandler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports
21
import type {
32
Direction,
43
Position,

packages/cursorless-engine/src/typings/target.types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// - https://github.com/microsoft/TypeScript/issues/43950
66
// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports
77
import type { ModifyIfUntypedStage } from "../processTargets/modifiers/ConditionalModifierStages";
8-
// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports
98
import type {
109
GeneralizedRange,
1110
InsertionMode,

packages/cursorless-org/.eslintrc.json

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { FlatCompat } from "@eslint/eslintrc";
2+
3+
const compat = new FlatCompat({
4+
baseDirectory: import.meta.dirname,
5+
});
6+
7+
export default {
8+
files: ["packages/cursorless-org/src/**/*"],
9+
10+
extends: [...compat.extends("next/core-web-vitals")],
11+
12+
settings: {
13+
next: {
14+
rootDir: "packages/cursorless-org",
15+
},
16+
},
17+
};

packages/cursorless-vscode-e2e/src/suite/crossCellsSetSelection.vscode.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ async function runTest() {
4343
],
4444
});
4545

46-
// eslint-disable-next-line no-restricted-properties
4746
const editor = window.activeTextEditor;
4847

4948
if (editor == null) {

0 commit comments

Comments
 (0)