Skip to content

Commit cc60725

Browse files
committed
build: introduce oxlint
1 parent 6fc087f commit cc60725

File tree

13 files changed

+365
-21
lines changed

13 files changed

+365
-21
lines changed

.oxlintrc.jsonc

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"ignorePatterns": ["packages/*/lib/**"],
4+
"categories": {
5+
"correctness": "error",
6+
"suspicious": "warn",
7+
"pedantic": "warn",
8+
"perf": "warn",
9+
"style": "warn",
10+
"restriction": "off",
11+
},
12+
"plugins": [
13+
"import",
14+
"unicorn",
15+
"oxc",
16+
"promise",
17+
"jsdoc",
18+
"vitest",
19+
"node",
20+
"vue",
21+
],
22+
"rules": {
23+
"catch-error-name": ["warn", { "name": "err" }],
24+
"curly": ["off", "multi-line"],
25+
"group-exports": "off",
26+
"id-length": [
27+
"warn",
28+
{ "exceptions": ["_", "a", "b", "d", "h", "i", "x", "y", "z"] },
29+
],
30+
"init-declarations": "off",
31+
"max-dependencies": "off",
32+
"max-lines": "off",
33+
"max-lines-per-function": "off",
34+
"max-params": ["warn", 4],
35+
"no-continue": "off",
36+
"no-console": "warn",
37+
"no-duplicate-imports": "off",
38+
"no-magic-numbers": "off",
39+
// "no-magic-numbers": ["warn", { "ignore": [-1, 0, 1, 2] }],
40+
"no-nested-ternary": "off",
41+
"no-null": "off",
42+
"no-ternary": "off",
43+
"no-warning-comments": "off",
44+
"no-unused-vars": ["warn", { "ignoreRestSiblings": true }],
45+
"sort-imports": "off",
46+
"sort-keys": "off",
47+
48+
"import/exports-last": "off",
49+
// usually we just export vue components as default export without naming it
50+
"import/no-anonymous-default-export": "off",
51+
// a rule that shall not be enabled anyway
52+
"import/no-named-export": "off",
53+
"import/no-unassigned-import": [
54+
"error",
55+
{ "allow": ["**/*.css", "**/*.scss"] },
56+
],
57+
// named export is preferred in our codebase
58+
"import/prefer-default-export": "off",
59+
"jsdoc/require-param": "off",
60+
"jsdoc/require-param-type": "off",
61+
"jsdoc/require-returns": "off",
62+
"jsdoc/require-returns-type": "off",
63+
"promise/always-return": "off",
64+
"promise/avoid-new": "off",
65+
"promise/prefer-await-to-then": "off",
66+
"unicorn/filename-case": "off",
67+
// toReversed can introduce memory overhead
68+
"unicorn/no-array-reverse": "off",
69+
// toSorted can introduce memory overhead
70+
"unicorn/no-array-sort": "off",
71+
"unicorn/no-nested-ternary": "off",
72+
// at is not supported by our target environments
73+
"unicorn/prefer-at": "off",
74+
"unicorn/prefer-global-this": "off",
75+
76+
// seems conflicts with prettier
77+
"number-literal-case": "off",
78+
"numeric-separators-style": "off",
79+
80+
// style rules
81+
"capitalized-comments": "off",
82+
"max-statements": ["warn", { "max": 30 }],
83+
"no-inline-comments": "off",
84+
85+
// the following rules are still not supported by oxlint yet
86+
// "import-x/no-restricted-paths": [
87+
// "error",
88+
// {
89+
// "zones": [
90+
// {
91+
// "target": "packages/*/src/client/**",
92+
// "from": "packages/*/src/node/**",
93+
// },
94+
// {
95+
// "target": "packages/*/src/node/**",
96+
// "from": "packages/*/src/client/**",
97+
// },
98+
// ],
99+
// },
100+
// ],
101+
// "vue/multi-word-component-names": [
102+
// "error",
103+
// { "ignores": ["Blog", "Layout", "Slides"] },
104+
// ],
105+
},
106+
"overrides": [
107+
{
108+
"files": ["**/*.ts"],
109+
"plugins": ["typescript"],
110+
"rules": {
111+
// we make type casts only when necessary
112+
"typescript/no-unsafe-type-assertion": "off",
113+
// skipping it for now, may enable it later
114+
"typescript/switch-exhaustiveness-check": "off",
115+
// a lot of time we are just want to check existence
116+
"typescript/strict-boolean-expressions": "off",
117+
},
118+
},
119+
{
120+
"files": ["**/node/**/*.ts"],
121+
"plugins": ["node"],
122+
"rules": {
123+
"no-restricted-imports": [
124+
"error",
125+
"@vuepress/helper/client",
126+
"vuepress/client",
127+
],
128+
},
129+
},
130+
{
131+
"files": ["**/client/**/*.ts"],
132+
"plugins": ["vue"],
133+
"rules": {
134+
"no-restricted-imports": [
135+
"error",
136+
"@vuepress/helper",
137+
"@vuepress/helper/node",
138+
"vuepress/core",
139+
"vuepress/markdown",
140+
"vuepress/utils",
141+
],
142+
"typescript/prefer-nullish-coalescing": [
143+
"warn",
144+
{ "ignoreConditionalTests": true },
145+
],
146+
},
147+
},
148+
{
149+
"files": ["**/__tests__/**"],
150+
"plugins": ["vitest"],
151+
},
152+
{
153+
"files": ["**/create/src/**/*.ts"],
154+
"rules": {
155+
"no-console": "off",
156+
},
157+
},
158+
],
159+
}

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"format": "prettier --write .",
1414
"lint": "eslint . && prettier --check . && stylelint **/*.{css,html,scss,vue}",
1515
"lint:fix": "eslint . --fix && prettier --check --write . && stylelint **/*.{css,html,scss,vue} --fix",
16+
"lint:ox": "oxlint . --type-aware",
1617
"prepare": "husky",
1718
"release": "pnpm release:check && pnpm release:version && pnpm release:publish",
1819
"release:check": "pnpm lint && pnpm clean && pnpm build && pnpm test",
@@ -30,6 +31,10 @@
3031
"package.json": "sort-package-json"
3132
},
3233
"prettier": "prettier-config-vuepress",
34+
"dependencies": {
35+
"oxlint": "^1.37.0",
36+
"oxlint-tsgolint": "^0.10.1"
37+
},
3338
"devDependencies": {
3439
"@commitlint/cli": "^20.3.0",
3540
"@commitlint/config-conventional": "^20.3.0",

plugins/features/plugin-notice/src/client/components/Notice.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,7 @@ export const Notice = defineComponent({
3434

3535
if (!option) return null
3636

37-
const {
38-
noticeKey,
39-
actions = [],
40-
title = '',
41-
content = '',
42-
...rest
43-
} = option
37+
const { noticeKey, actions = [], title, content = '', ...rest } = option
4438

4539
return {
4640
...rest,
@@ -64,7 +58,7 @@ export const Notice = defineComponent({
6458

6559
const footerAction = (link?: string): void => {
6660
if (link)
67-
if (isLinkAbsolute(link)) router.push(link)
61+
if (isLinkAbsolute(link)) void router.push(link)
6862
else if (isLinkHttp(link)) window.open(link)
6963

7064
closeModal()

plugins/search/plugin-docsearch/src/client/composables/useDocSearchSlim.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const useDocSearchShim = (): Partial<DocSearchProps> => {
2929
navigator: {
3030
// when pressing Enter without metaKey
3131
navigate: ({ itemUrl }) => {
32-
router.push(itemUrl.replace(__VUEPRESS_BASE__, '/'))
32+
void router.push(itemUrl.replace(__VUEPRESS_BASE__, '/'))
3333
},
3434
},
3535

plugins/tools/plugin-redirect/src/client/components/RedirectModal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default defineComponent({
134134
class: 'redirect-modal-action primary',
135135
onClick: () => {
136136
updateState()
137-
router.replace(
137+
void router.replace(
138138
routePath.value.replace(
139139
routeLocale.value,
140140
redirectInfo.value!.localePath,

plugins/tools/plugin-redirect/src/client/composables/setupDevServerRedirect.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ export const setupDevServerRedirect = ({
8787
: // as is to get a 404 page of that locale
8888
localeRoute
8989

90-
router.replace(redirectPath)
90+
void router.replace(redirectPath)
9191
}
9292
// we have a default page
9393
else if (defaultRoute) {
94-
router.replace(defaultRoute)
94+
void router.replace(defaultRoute)
9595
} else if (routePath.value !== '/404.html') {
96-
router.replace('/404.html')
96+
void router.replace('/404.html')
9797
}
9898
}
9999

@@ -102,7 +102,7 @@ export const setupDevServerRedirect = ({
102102
for (const [from, to] of entries(redirectMap))
103103
if (normalizePath(path.toLowerCase()) === from.toLowerCase()) {
104104
if (isLinkHttp(to)) window.open(to)
105-
else router.replace(to)
105+
else void router.replace(to)
106106

107107
return
108108
}

plugins/tools/plugin-redirect/src/client/composables/setupRedirect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const setupRedirect = (behaviorConfig: RedirectBehaviorConfig): void => {
1616

1717
onMounted(() => {
1818
if (redirectInfo.value && !statusSessionStorage.value[routeLocale.value]) {
19-
router.replace(
19+
void router.replace(
2020
routePath.value.replace(
2121
routeLocale.value,
2222
redirectInfo.value.localePath,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {}

0 commit comments

Comments
 (0)