Skip to content

Commit 03d38aa

Browse files
authored
style: 💄 enable more oxlint rules (#1767)
1 parent be11207 commit 03d38aa

File tree

5 files changed

+137
-56
lines changed

5 files changed

+137
-56
lines changed

Diff for: .oxlintrc.json

+84-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,65 @@
22
"plugins": ["import", "typescript", "unicorn", "promise"],
33
"rules": {
44
"no-console": "error",
5+
"for-direction": "error",
6+
"require-yield": "error",
7+
"use-isnan": "error",
8+
"valid-typeof": "error",
9+
"no-empty-character-class": "error",
10+
"no-self-compare": "error",
11+
"no-empty": [
12+
"error",
13+
{
14+
"allowEmptyCatch": true
15+
}
16+
],
17+
"no-constant-binary-expression": "error",
18+
"no-constructor-return": "error",
19+
"no-func-assign": "error",
20+
"no-global-assign": "error",
21+
"no-ex-assign": "error",
22+
"no-loss-of-precision": "error",
23+
"no-fallthrough": "error",
24+
"no-nonoctal-decimal-escape": "error",
25+
"no-irregular-whitespace": "error",
26+
"no-control-regex": "error",
27+
"no-with": "error",
28+
"no-debugger": "error",
29+
"no-const-assign": "error",
30+
"no-setter-return": "error",
31+
"no-obj-calls": "error",
32+
"no-unsafe-negation": "error",
33+
"no-dupe-class-members": "error",
34+
"no-dupe-keys": "error",
35+
"no-this-before-super": "error",
36+
"no-useless-catch": "error",
37+
"no-async-promise-executor": "error",
38+
"no-unreachable": "error",
39+
"no-duplicate-case": "error",
40+
"no-empty-pattern": "error",
41+
"no-unused-labels": "error",
42+
"no-sparse-arrays": "error",
43+
"no-delete-var": "error",
44+
"no-compare-neg-zero": "error",
45+
"no-case-declarations": "error",
46+
"no-class-assign": "error",
47+
"no-var": "error",
48+
"no-self-assign": "error",
49+
"no-inner-declarations": "error",
50+
"no-dupe-else-if": "error",
51+
"no-invalid-regexp": "error",
52+
"no-unsafe-finally": "error",
53+
"no-prototype-builtins": "error",
54+
"no-array-constructor": "error",
55+
"no-shadow-restricted-names": "error",
56+
"no-constant-condition": "error",
57+
"no-useless-escape": "error",
58+
"no-unsafe-optional-chaining": "error",
59+
"no-extra-boolean-cast": "error",
60+
"no-regex-spaces": "error",
61+
562
"eslint/no-unused-vars": "off",
63+
664
"unicorn/prefer-array-some": "error",
765
"unicorn/no-useless-promise-resolve-reject": "error",
866
"unicorn/no-unnecessary-await": "error",
@@ -17,17 +75,42 @@
1775
"unicorn/prefer-blob-reading-methods": "error",
1876
"unicorn/no-typeof-undefined": "error",
1977
"unicorn/no-new-array": "error",
78+
2079
"import/no-cycle": [
2180
"error",
2281
{
2382
"ignoreTypes": true
2483
}
2584
],
85+
"import/named": "error",
2686
"import/sort-imports": "error",
2787
"import/no-duplicates": "error",
2888
"import/no-import-assign": "error",
2989
"import/no-self-import": "error",
90+
3091
"typescript/consistent-type-imports": "error",
31-
"typescript/no-import-type-side-effects": "error"
92+
"typescript/triple-slash-reference": "error",
93+
"typescript/no-non-null-asserted-optional-chain": "error",
94+
"typescript/no-import-type-side-effects": "error",
95+
"typescript/no-duplicate-enum-values": "error",
96+
"typescript/no-extra-non-null-assertion": "error",
97+
"typescript/no-misused-new": "error",
98+
"typescript/prefer-for-of": "error",
99+
"typescript/no-unsafe-declaration-merging": "error",
100+
"typescript/no-this-alias": [
101+
"error",
102+
{
103+
"allowDestructuring": true
104+
}
105+
],
106+
"typescript/prefer-as-const": "error",
107+
"typescript/no-var-requires": "error",
108+
"typescript/no-namespace": [
109+
"error",
110+
{
111+
"allowDeclarations": true
112+
}
113+
],
114+
"typescript/no-unnecessary-type-constraint": "error"
32115
}
33116
}

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"jsdom": "^26.0.0",
6262
"lint-staged": "^15.0.0",
6363
"nx": "20.6.4",
64-
"oxlint": "^0.16.0",
64+
"oxlint": "^0.16.3",
6565
"pathe": "^2.0.0",
6666
"postcss": "^8.4.38",
6767
"postcss-cli": "^11.0.0",

Diff for: packages/plugins/preset-commonmark/src/node/paragraph.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function shouldPreserveEmptyLine(ctx: Ctx) {
5151
try {
5252
ctx.get(remarkPreserveEmptyLinePlugin.id)
5353
shouldPreserveEmptyLine = true
54-
} catch (e) {
54+
} catch {
5555
shouldPreserveEmptyLine = false
5656
}
5757
return shouldPreserveEmptyLine

Diff for: packages/prose/src/toolkit/input-rules/custom-input-rules.ts

+14-16
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,24 @@ function run(
2222
undefined,
2323
'\uFFFC'
2424
) + text
25-
for (let i = 0; i < rules.length; i++) {
26-
const match = (rules[i] as unknown as { match: RegExp }).match.exec(
27-
textBefore
28-
)
25+
for (let _matcher of rules) {
26+
const matcher = _matcher as unknown as {
27+
match: RegExp
28+
handler: (
29+
state: EditorState,
30+
match: string[],
31+
from: number,
32+
to: number
33+
) => Transaction
34+
undoable?: boolean
35+
}
36+
const match = matcher.match.exec(textBefore)
2937
const tr =
3038
match &&
3139
match[0] &&
32-
(
33-
rules[i] as unknown as {
34-
handler: (
35-
state: EditorState,
36-
match: string[],
37-
from: number,
38-
to: number
39-
) => Transaction
40-
}
41-
).handler(state, match, from - (match[0].length - text.length), to)
40+
matcher.handler(state, match, from - (match[0].length - text.length), to)
4241
if (!tr) continue
43-
// @ts-expect-error Internal property that should be in the class; only relevant if explicitly false.
44-
if (rules[i]?.undoable !== false)
42+
if (matcher.undoable !== false)
4543
tr.setMeta(plugin, { transform: tr, from, to, text })
4644
view.dispatch(tr)
4745
return true

Diff for: pnpm-lock.yaml

+37-37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)