Skip to content

Commit 4096d7d

Browse files
Enable oxlint categories (#3261)
Enable all categories except `nursery` in oxlint configuration
1 parent 8641197 commit 4096d7d

331 files changed

Lines changed: 1796 additions & 1462 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Engine code is in `/packages/lib-engine/`
1313
- Tests are in `resources/fixtures/recorded` and `resources/fixtures/scopes`
1414
- Language-specific parsing is defined in the `resources/queries/*.scm` files
15+
- Packages starting `lib-` are only used internally in this monorepo and are not published to npm. Changing the api surface is fine as long as every place that consumes the api within this repository is updated.
1516

1617
## Build and test
1718

oxlint.config.mts

Lines changed: 81 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
1+
import type { OxlintConfig } from "oxlint";
12
import { defineConfig } from "oxlint";
23

4+
// These rules should probably be re-enabled eventually
5+
const temporarilyDisabled = [
6+
"eslint/no-param-reassign",
7+
"eslint/no-shadow",
8+
"eslint/prefer-template",
9+
"import/no-default-export",
10+
"typescript/no-unsafe-type-assertion",
11+
"unicorn/no-array-reduce",
12+
];
13+
314
const disabledRules = [
15+
...temporarilyDisabled,
416
"eslint/arrow-body-style",
517
"eslint/capitalized-comments",
618
"eslint/class-methods-use-this",
719
"eslint/complexity",
20+
"eslint/func-names",
821
"eslint/id-length",
922
"eslint/init-declarations",
1023
"eslint/max-classes-per-file",
1124
"eslint/max-lines-per-function",
1225
"eslint/max-lines",
1326
"eslint/max-params",
1427
"eslint/max-statements",
28+
"eslint/no-await-in-loop",
1529
"eslint/no-console",
1630
"eslint/no-continue",
1731
"eslint/no-eq-null",
32+
"eslint/no-lonely-if",
33+
"eslint/no-loop-func",
1834
"eslint/no-magic-numbers",
1935
"eslint/no-negated-condition",
2036
"eslint/no-plusplus",
@@ -36,15 +52,20 @@ const disabledRules = [
3652
"import/no-relative-parent-imports",
3753
"import/prefer-default-export",
3854
"oxc/no-async-await",
55+
"oxc/no-barrel-file",
56+
"oxc/no-map-spread",
3957
"oxc/no-optional-chaining",
4058
"oxc/no-rest-spread-properties",
59+
"promise/always-return",
4160
"promise/avoid-new",
4261
"promise/prefer-await-to-callbacks",
4362
"react-perf/jsx-no-new-function-as-prop",
4463
"react/jsx-max-depth",
64+
"react/no-danger",
4565
"react/no-multi-comp",
4666
"react/only-export-components",
4767
"react/react-in-jsx-scope",
68+
"react/rules-of-hooks",
4869
"typescript/explicit-function-return-type",
4970
"typescript/parameter-properties",
5071
"typescript/prefer-readonly-parameter-types",
@@ -53,14 +74,33 @@ const disabledRules = [
5374
"unicorn/filename-case",
5475
"unicorn/no-array-callback-reference",
5576
"unicorn/no-array-for-each",
77+
"unicorn/no-array-reverse",
78+
"unicorn/no-array-sort",
79+
"unicorn/no-lonely-if",
5680
"unicorn/no-null",
81+
"unicorn/no-object-as-default-parameter",
82+
"unicorn/no-useless-undefined",
5783
"unicorn/prefer-at",
84+
"unicorn/prefer-event-target",
5885
"unicorn/prefer-module",
86+
"unicorn/prefer-query-selector",
5987
"unicorn/prefer-spread",
6088
"unicorn/prefer-ternary",
89+
"unicorn/require-post-message-target-origin",
6190
"unicorn/switch-case-braces",
6291
];
6392

93+
const plugins: OxlintConfig["plugins"] = [
94+
"eslint",
95+
"unicorn",
96+
"oxc",
97+
"import",
98+
"node",
99+
"promise",
100+
"react",
101+
"react-perf",
102+
];
103+
64104
// oxlint-disable-next-line import/no-default-export
65105
export default defineConfig({
66106
ignorePatterns: [
@@ -69,43 +109,36 @@ export default defineConfig({
69109
"packages/app-vscode/src/keyboard/grammar/generated/**",
70110
"packages/lib-engine/src/customCommandGrammar/generated/**",
71111
"packages/lib-engine/src/snippets/vendor/**",
112+
"**/*.d.ts",
72113
],
73114
options: {
74115
typeAware: true,
75116
typeCheck: false,
76117
},
77-
plugins: [
78-
"eslint",
79-
"typescript",
80-
"unicorn",
81-
"oxc",
82-
"import",
83-
"node",
84-
"promise",
85-
"react",
86-
"react-perf",
87-
],
118+
plugins,
88119
jsPlugins: [
89120
{
90121
name: "mocha",
91122
specifier: "eslint-plugin-mocha",
92123
},
93124
],
125+
categories: {
126+
correctness: "warn",
127+
suspicious: "warn",
128+
pedantic: "warn",
129+
perf: "warn",
130+
style: "warn",
131+
restriction: "warn",
132+
// Disabled since nursery contains rules under development that may change
133+
// nursery: "warn",
134+
},
94135

95136
rules: {
96137
...Object.fromEntries(disabledRules.map((r) => [r, "off"])),
97-
curly: "warn",
98-
eqeqeq: [
99-
"warn",
100-
"always",
101-
{
102-
null: "never",
103-
},
104-
],
105-
"eslint/no-constant-condition": [
138+
"eslint/no-duplicate-imports": [
106139
"warn",
107140
{
108-
checkLoops: false,
141+
allowSeparateTypeImports: true,
109142
},
110143
],
111144
"eslint/no-restricted-imports": [
@@ -125,41 +158,54 @@ export default defineConfig({
125158
],
126159
},
127160
],
128-
"eslint/no-throw-literal": "warn",
129161
"eslint/no-unused-vars": [
130162
"warn",
131163
{
132164
argsIgnorePattern: "^_",
133165
varsIgnorePattern: "^_",
134-
caughtErrorsIgnorePattern: "^_",
135166
ignoreRestSiblings: true,
136167
},
137168
],
138-
"import/no-duplicates": "warn",
139-
"mocha/no-exclusive-tests": "warn",
140-
"mocha/no-pending-tests": "warn",
169+
"import/no-unassigned-import": [
170+
"warn",
171+
{
172+
allow: ["**/*.css"],
173+
},
174+
],
141175
"no-warning-comments": [
142176
"warn",
143177
{
144178
terms: ["todo"],
145179
},
146180
],
147-
"typescript/consistent-type-assertions": [
181+
"react/jsx-filename-extension": [
182+
"warn",
183+
{
184+
extensions: [".tsx"],
185+
},
186+
],
187+
eqeqeq: [
148188
"warn",
189+
"always",
149190
{
150-
assertionStyle: "as",
191+
null: "never",
151192
},
152193
],
153-
"typescript/consistent-type-imports": "warn",
154-
"typescript/no-base-to-string": "off",
155-
"typescript/restrict-template-expressions": "off",
156-
"typescript/unbound-method": "off",
157-
"unicorn/prefer-module": "warn",
158-
"unicorn/prefer-node-protocol": "warn",
159-
"unicorn/throw-new-error": "warn",
160194
},
161195

162196
overrides: [
197+
{
198+
files: ["**/*.js"],
199+
rules: {
200+
"import/unambiguous": "off",
201+
},
202+
},
203+
204+
{
205+
files: ["**/*.{ts,cts,mts,tsx}"],
206+
plugins: [...plugins, "typescript"],
207+
},
208+
163209
{
164210
files: ["packages/app-vscode/src/scripts/**/*.ts"],
165211
rules: {

packages/app-neovim/src/NeovimCommandServerApi.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ export class NeovimCommandServerApi implements CommandServerApi {
99
signals: { prePhrase: InboundSignal };
1010

1111
constructor(private client: NeovimClient) {
12-
this.signals = { prePhrase: { getVersion: async () => null } };
12+
this.signals = {
13+
prePhrase: {
14+
getVersion: () => Promise.resolve(null),
15+
},
16+
};
1317
}
1418

1519
// for vscode, it is actually stored into the command-server
@@ -19,8 +23,7 @@ export class NeovimCommandServerApi implements CommandServerApi {
1923
const currentMode = await this.client.mode;
2024
if (currentMode.mode === "t" || currentMode.mode === "nt") {
2125
return "terminal";
22-
} else {
23-
return "textEditor";
2426
}
27+
return "textEditor";
2528
}
2629
}

packages/app-neovim/src/constructTestHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function constructTestHelpers(
3030
injectIde: (ide: IDE) => void,
3131
): NeovimTestHelpers | undefined {
3232
return {
33-
commandServerApi: commandServerApi!,
33+
commandServerApi,
3434
ide: normalizedIde,
3535
neovimIDE,
3636
injectIde,

0 commit comments

Comments
 (0)