Skip to content

Commit 7dc299d

Browse files
authored
refactor: replace eslint with oxlint (#271)
* refactor: replace eslint with oxlint * chore: f * chore: f
1 parent 2099b10 commit 7dc299d

108 files changed

Lines changed: 3639 additions & 3975 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.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
- name: Run lint
3333
run: pnpm lint
3434

35-
- name: Run prettier
36-
run: pnpm prettier
35+
- name: Run format check
36+
run: pnpm format:check
3737

3838
build:
3939
runs-on: ubuntu-latest

.lintstagedrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
"*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write --ignore-unknown"],
3-
};
2+
'*.{js,jsx,ts,tsx}': ['oxlint -c .oxlintrc.json --fix', 'oxfmt --write'],
3+
}

.oxfmtrc.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"trailingComma": "es5",
4+
"tabWidth": 2,
5+
"semi": false,
6+
"singleQuote": true,
7+
"printWidth": 80,
8+
"sortImports": {
9+
"groups": [
10+
"type-import",
11+
["value-builtin", "value-external"],
12+
"type-internal",
13+
"value-internal",
14+
["type-parent", "type-sibling", "type-index"],
15+
["value-parent", "value-sibling", "value-index"],
16+
"unknown"
17+
]
18+
},
19+
"ignorePatterns": [
20+
"pnpm-lock.yaml",
21+
"**/storybook-static",
22+
"**/lib",
23+
"**/.storybook",
24+
"**/tests/data/*.md",
25+
"**/templates/*.md"
26+
]
27+
}

.oxlintrc.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["react", "nextjs", "jsx-a11y", "import", "typescript"],
4+
"categories": {
5+
"correctness": "error",
6+
"suspicious": "warn",
7+
"perf": "warn"
8+
},
9+
"rules": {
10+
"no-unused-vars": "off",
11+
"react/react-in-jsx-scope": "off",
12+
"jsx-a11y/click-events-have-key-events": "warn",
13+
"jsx-a11y/no-static-element-interactions": "warn",
14+
"import/order": "error"
15+
},
16+
"settings": {
17+
"next": {
18+
"rootDir": ["."]
19+
},
20+
"react": {
21+
"formComponents": [],
22+
"linkComponents": [{ "name": "Link", "linkAttribute": "href" }]
23+
}
24+
},
25+
"ignorePatterns": [".next", "out", "build", "milkdown", "next-env.d.ts"]
26+
}

.prettierignore

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

docs/blogs/announcing-telemetry-inspector.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,47 @@ You can even use visualizer to visualize the data. We create a simple example on
1313
Inspector will be a top-level API in Milkdown. You can use it like this:
1414

1515
```ts
16-
import { Editor } from "@milkdown/core";
17-
import { Telemetry } from "@milkdown/ctx";
16+
import { Editor } from '@milkdown/core'
17+
import { Telemetry } from '@milkdown/ctx'
1818

1919
const editor = await Editor.make()
2020
// Inspector is disabled by default considering performance. You need to enable it manually.
2121
.enableInspector()
2222
// ...
23-
.create();
23+
.create()
2424

25-
const telemetry: Telemetry[] = editor.inspect();
25+
const telemetry: Telemetry[] = editor.inspect()
2626
```
2727

2828
The `Telemetry` interface will have the following fields:
2929

3030
```ts
3131
interface Telemetry {
3232
// User defined information for the plugin.
33-
metadata: Meta;
33+
metadata: Meta
3434

3535
// The slices and their current value defined by the plugin.
36-
injectedSlices: { name: string; value: unknown }[];
36+
injectedSlices: { name: string; value: unknown }[]
3737

3838
// The slices and their current value consumed by the plugin.
39-
consumedSlices: { name: string; value: unknown }[];
39+
consumedSlices: { name: string; value: unknown }[]
4040

4141
// The timers and their duration defined by the plugin.
42-
recordedTimers: { name: string; duration: number; status: TimerStatus }[];
42+
recordedTimers: { name: string; duration: number; status: TimerStatus }[]
4343

4444
// The timers and their duration consumed by the plugin.
4545
// Generally, the plugin will wait for them.
46-
waitTimers: { name: string; duration: number; status: TimerStatus }[];
46+
waitTimers: { name: string; duration: number; status: TimerStatus }[]
4747
}
4848

49-
type TimerStatus = "pending" | "resolved" | "rejected";
49+
type TimerStatus = 'pending' | 'resolved' | 'rejected'
5050

5151
interface Meta {
52-
displayName: string;
53-
description?: string;
54-
package: string;
55-
group?: string;
56-
additional?: Record<string, any>;
52+
displayName: string
53+
description?: string
54+
package: string
55+
group?: string
56+
additional?: Record<string, any>
5757
}
5858
```
5959

@@ -62,52 +62,52 @@ With the data, you'll know the sequence of the plugins loaded, the slices and ti
6262
For example:
6363

6464
```ts
65-
[
65+
;[
6666
{
6767
metadata: {
68-
displayName: "Config",
69-
package: "@milkdown/core",
70-
group: "System",
68+
displayName: 'Config',
69+
package: '@milkdown/core',
70+
group: 'System',
7171
},
7272
injectedSlices: [],
7373
consumedSlices: [
7474
/* ... */
7575
],
7676
recordedTimers: [
7777
{
78-
name: "ConfigReady",
78+
name: 'ConfigReady',
7979
duration: 3,
80-
status: "resolved",
80+
status: 'resolved',
8181
},
8282
],
8383
waitTimers: [],
8484
},
8585
{
8686
metadata: {
87-
displayName: "Init",
88-
package: "@milkdown/core",
89-
group: "System",
87+
displayName: 'Init',
88+
package: '@milkdown/core',
89+
group: 'System',
9090
},
9191
injectedSlices: [],
9292
consumedSlices: [
9393
/* ... */
9494
],
9595
recordedTimers: [
9696
{
97-
name: "InitReady",
97+
name: 'InitReady',
9898
duration: 5,
99-
status: "resolved",
99+
status: 'resolved',
100100
},
101101
],
102102
waitTimers: [
103103
{
104-
name: "ConfigReady",
104+
name: 'ConfigReady',
105105
duration: 5,
106-
status: "resolved",
106+
status: 'resolved',
107107
},
108108
],
109109
},
110-
];
110+
]
111111
```
112112

113113
From above information, we can know that the `Init` plugin wait for `Config` plugin to be ready.
@@ -120,23 +120,23 @@ We can build a sequence diagram from the data.
120120
For plugin maintainers, you can add metadata to your plugin to make it more friendly to the inspector.
121121

122122
```ts
123-
import { MilkdownPlugin } from "@milkdown/ctx";
123+
import { MilkdownPlugin } from '@milkdown/ctx'
124124

125125
const yourMilkdownPlugin: MilkdownPlugin = () => {
126126
/* your implementation */
127-
};
127+
}
128128

129129
yourMilkdownPlugin.metadata = {
130-
displayName: "Your Plugin",
131-
package: "your-plugin-package",
132-
description: "Your plugin description",
133-
group: "If you have a lot of plugins in your package, you can group them.",
130+
displayName: 'Your Plugin',
131+
package: 'your-plugin-package',
132+
description: 'Your plugin description',
133+
group: 'If you have a lot of plugins in your package, you can group them.',
134134
addtitional: {
135135
/* You can add any additional information here. */
136-
version: "1.0.0",
137-
authror: "Mike",
136+
version: '1.0.0',
137+
authror: 'Mike',
138138
},
139-
};
139+
}
140140
```
141141

142142
With metadata, your plugin will report telemetry correctly to the inspector.

0 commit comments

Comments
 (0)