Skip to content

Commit 005bbce

Browse files
authored
Migrate to oxlint and oxfmt (#696)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description Migrates from eslint and prettier to oxlint and oxfmt + some rule hardening and - some rules that don't exist in oxlint, but I decided it probably wasn't worth running both in parallel just for a few rules. Notably, got rid of many "as any"s and swapped to .toSorted() for safer stuff and "type" in imports. Added comments to all the existing lint issues (console logging and the alert for app updates) and the few places "as any" was justified (test cases) and some message object whatnots. Also notably, fmt now takes a second or two, and linting now takes no more than a few seconds. Yay! Recommended vscode plugins, workflows, and configs should all be updated assuming I didn't miss anything. <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [x] Breaking change - breaking I guess since not all rules exist? I don't really know exactly what I uh... didn't include. - [ ] This change requires a documentation update ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings ### AI disclosure: - [x] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. --> I deployed a swarm of silly AIs to fix many of the simpler as any casts and subsequent typechecks because there were hundreds and I'm not doing that manually :p. I did review it, mostly just seamless swapping to the correct cast type instead of as any, nothing particularly complicated.
2 parents 4e9c349 + 8396fed commit 005bbce

616 files changed

Lines changed: 5596 additions & 5934 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.

.prettierignore

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

.prettierrc.json

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

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "webpro.vscode-knip"]
2+
"recommendations": ["webpro.vscode-knip", "oxc.oxc-vscode"]
33
}

.vscode/settings.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.oxc": "always"
4+
},
25
"editor.formatOnSave": true,
3-
"editor.defaultFormatter": "esbenp.prettier-vscode",
6+
"editor.defaultFormatter": "oxc.oxc-vscode",
7+
"oxc.fmt.configPath": "oxfmt.config.ts",
8+
"oxc.typeAware": true,
49
"typescript.tsdk": "node_modules/typescript/lib",
510
"[jsonc]": {
6-
"editor.defaultFormatter": "esbenp.prettier-vscode"
11+
"editor.defaultFormatter": "oxc.oxc-vscode"
712
},
813
"[json]": {
9-
"editor.defaultFormatter": "esbenp.prettier-vscode"
14+
"editor.defaultFormatter": "oxc.oxc-vscode"
1015
}
1116
}

eslint.config.js

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

knip.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"$schema": "https://unpkg.com/knip@5/schema.json",
33
"entry": ["src/sw.ts", "scripts/normalize-imports.js"],
4+
"ignore": ["oxlint.config.ts", "oxfmt.config.ts"],
45
"ignoreExportsUsedInFile": {
56
"interface": true,
67
"type": true
78
},
89
"ignoreDependencies": [
910
"buffer",
1011
"@sableclient/sable-call-embedded",
11-
"@matrix-org/matrix-sdk-crypto-wasm",
12-
"@testing-library/user-event"
12+
"@matrix-org/matrix-sdk-crypto-wasm"
1313
],
1414
"ignoreBinaries": ["knope"],
1515
"rules": {

knope.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
versioned_files = ["package.json"]
33
changelog = "CHANGELOG.md"
44
extra_changelog_sections = [
5-
{ name = "Documentation", types = ["docs"] },
6-
{ name = "Notes", types = ["note"] },
5+
{ name = "Documentation", types = [
6+
"docs",
7+
] },
8+
{ name = "Notes", types = [
9+
"note",
10+
] },
711
]
812
# assets = "marker" // TODO: add this later once we have assets
913

@@ -64,6 +68,6 @@ repo = "Sable"
6468
[release_notes]
6569
# The <!-- commit:$commit_hash --> marker is used by prepare-release.yml
6670
change_templates = [
67-
"### $summary <!-- commit:$commit_hash -->\n\n$details",
68-
"* $summary <!-- commit:$commit_hash -->",
71+
"### $summary <!-- commit:$commit_hash -->\n\n$details",
72+
"* $summary <!-- commit:$commit_hash -->",
6973
]

oxfmt.config.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { defineConfig } from 'oxfmt';
2+
3+
export default defineConfig({
4+
printWidth: 100,
5+
tabWidth: 2,
6+
singleQuote: true,
7+
trailingComma: 'es5',
8+
ignorePatterns: [
9+
'dist',
10+
'node_modules',
11+
'package.json',
12+
'pnpm-lock.yaml',
13+
'LICENSE',
14+
'README.md',
15+
'CHANGELOG.md',
16+
'./changeset',
17+
],
18+
});

oxlint.config.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { defineConfig } from 'oxlint';
2+
3+
export default defineConfig({
4+
options: {
5+
typeAware: true,
6+
},
7+
plugins: ['react', 'jsx-a11y', 'typescript', 'import', 'unicorn', 'oxc', 'vitest', 'promise'],
8+
categories: {
9+
correctness: 'error',
10+
suspicious: 'warn',
11+
perf: 'warn',
12+
style: 'off',
13+
},
14+
env: {
15+
browser: true,
16+
builtin: true,
17+
},
18+
rules: {
19+
'import/no-unassigned-import': 'off',
20+
'import/no-named-as-default': 'off',
21+
'import/no-named-as-default-member': 'off',
22+
'no-console': ['error', { allow: ['warn', 'error'] }],
23+
'react/react-in-jsx-scope': 'off',
24+
'react/jsx-filename-extension': ['error', { extensions: ['.tsx', '.jsx'] }],
25+
'react/rules-of-hooks': 'error',
26+
'react/exhaustive-deps': 'error',
27+
'react/iframe-missing-sandbox': 'off',
28+
'jsx-a11y/no-autofocus': 'off',
29+
'jsx-a11y/prefer-tag-over-role': 'off',
30+
'typescript/no-explicit-any': 'error',
31+
'typescript/consistent-type-imports': 'error',
32+
'typescript/only-throw-error': 'error',
33+
'typescript/no-unsafe-type-assertion': 'off',
34+
'typescript/no-floating-promises': 'off',
35+
'typescript/no-unnecessary-type-arguments': 'off',
36+
'oxc/no-map-spread': 'off',
37+
'promise/always-return': 'off',
38+
},
39+
overrides: [
40+
{
41+
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],
42+
rules: {
43+
'typescript/no-unused-vars': [
44+
'error',
45+
{
46+
args: 'after-used',
47+
ignoreRestSiblings: true,
48+
vars: 'all',
49+
},
50+
],
51+
'typescript/no-shadow': 'error',
52+
},
53+
},
54+
{
55+
files: ['**/*.test.ts', '**/*.test.tsx'],
56+
rules: {
57+
'typescript/unbound-method': 'off',
58+
'typescript/no-unsafe-enum-comparison': 'off',
59+
},
60+
},
61+
],
62+
});

package.json

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
"dev": "vite dev",
1313
"build": "vite build",
1414
"preview": "vite preview",
15-
"lint": "eslint .",
16-
"lint:fix": "eslint . --fix",
17-
"fmt": "prettier --write .",
18-
"fmt:check": "prettier --check .",
15+
"lint": "oxlint .",
16+
"lint:fix": "oxlint . --fix && oxfmt .",
17+
"fmt": "oxfmt .",
18+
"fmt:check": "oxfmt --check .",
1919
"typecheck": "tsc",
2020
"test": "vitest",
2121
"test:ui": "vitest --ui",
@@ -57,7 +57,6 @@
5757
"dompurify": "^3.3.3",
5858
"emojibase": "^15.3.1",
5959
"emojibase-data": "^15.3.2",
60-
"eslint-plugin-react": "7.37.5",
6160
"eventemitter3": "^5.0.4",
6261
"file-saver": "^2.0.5",
6362
"focus-trap-react": "^10.3.1",
@@ -96,8 +95,6 @@
9695
"devDependencies": {
9796
"@cloudflare/vite-plugin": "^1.26.0",
9897
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
99-
"@eslint/compat": "2.0.2",
100-
"@eslint/js": "9.39.3",
10198
"@rollup/plugin-inject": "^5.0.5",
10299
"@rollup/plugin-wasm": "^6.2.2",
103100
"@sableclient/sable-call-embedded": "v1.1.4",
@@ -118,14 +115,11 @@
118115
"@vitest/ui": "^4.1.0",
119116
"buffer": "^6.0.3",
120117
"cloudflared": "^0.7.1",
121-
"eslint": "9.39.3",
122-
"eslint-config-airbnb-extended": "3.0.1",
123-
"eslint-config-prettier": "10.1.8",
124-
"eslint-plugin-prettier": "5.5.5",
125-
"globals": "17.3.0",
126118
"jsdom": "^29.0.0",
127119
"knip": "5.85.0",
128-
"prettier": "3.8.1",
120+
"oxfmt": "^0.45.0",
121+
"oxlint": "^1.60.0",
122+
"oxlint-tsgolint": "^0.21.0",
129123
"typescript": "^5.9.3",
130124
"vite": "^7.3.1",
131125
"vite-plugin-compression2": "2.5.0",

0 commit comments

Comments
 (0)