Skip to content

Commit 894c5e8

Browse files
authored
chore: introduce oxlint for faster linting (#5416)
1 parent bcb4dea commit 894c5e8

File tree

16 files changed

+139
-185
lines changed

16 files changed

+139
-185
lines changed

.oxlintrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"ignorePatterns": [
4+
"**/*.vue"
5+
],
6+
"rules": {
7+
"curly": "warn",
8+
"no-unused-expressions": "warn",
9+
"require-await": "warn"
10+
}
11+
}

.vscode/settings.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
{
2-
"typescript.format.semicolons": "insert",
3-
"editor.insertSpaces": false,
4-
"editor.detectIndentation": false,
5-
"editor.codeActionsOnSave": {
6-
"source.organizeImports": "always"
7-
},
8-
"json.format.keepLines": true,
9-
"typescript.tsdk": "node_modules/typescript/lib",
10-
"[typescript]": {
11-
"editor.defaultFormatter": "vscode.typescript-language-features"
12-
},
132
"[javascript]": {
143
"editor.defaultFormatter": "vscode.typescript-language-features"
154
},
@@ -19,12 +8,23 @@
198
"[jsonc]": {
209
"editor.defaultFormatter": "vscode.json-language-features"
2110
},
11+
"[typescript]": {
12+
"editor.defaultFormatter": "vscode.typescript-language-features"
13+
},
14+
"editor.codeActionsOnSave": {
15+
"source.organizeImports": "always"
16+
},
17+
"editor.detectIndentation": false,
18+
"editor.insertSpaces": false,
2219
"files.exclude": {
2320
"packages/*/*.d.ts": true,
2421
"packages/*/*.js": true,
2522
"packages/*/*.map": true,
2623
"packages/*/lib/**/*.d.ts": true,
2724
"packages/*/lib/**/*.js": true,
2825
"packages/*/lib/**/*.map": true
29-
}
26+
},
27+
"json.format.keepLines": true,
28+
"typescript.format.semicolons": "insert",
29+
"typescript.tsdk": "node_modules/typescript/lib"
3030
}

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
"release:next-vue": "cd ./extensions/vscode && pnpm run release:next",
1616
"test": "vitest run",
1717
"test:update": "vitest run --update",
18-
"lint": "tsslint --project {tsconfig.json,packages/*/tsconfig.json,extensions/*/tsconfig.json}",
19-
"lint:fix": "pnpm run lint -- --fix --vscode-settings .vscode/settings.json"
18+
"lint": "pnpm run oxlint && pnpm run tsslint",
19+
"lint:fix": "pnpm run oxlint:fix && pnpm run tsslint:fix",
20+
"oxlint": "oxlint",
21+
"oxlint:fix": "oxlint --fix",
22+
"tsslint": "tsslint --project {tsconfig.json,packages/*/tsconfig.json,extensions/*/tsconfig.json}",
23+
"tsslint:fix": "pnpm run lint -- --fix --vscode-settings .vscode/settings.json"
2024
},
2125
"devDependencies": {
2226
"@lerna-lite/cli": "^4.1.2",
@@ -25,6 +29,7 @@
2529
"@tsslint/config": "^1.5.0",
2630
"@tsslint/eslint": "^1.5.0",
2731
"@typescript-eslint/eslint-plugin": "^8.19.0",
32+
"oxlint": "^1.0.0",
2833
"typescript": "latest",
2934
"vitest": "^3.1.3"
3035
},

packages/language-core/lib/codegen/template/elementProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export function* generateElementProps(
168168
if (isComponent && prop.name === 'model' && prop.modifiers.length) {
169169
const propertyName = prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
170170
? !prop.arg.isStatic
171-
? `[__VLS_tryAsConstant(\`$\{${prop.arg.content}\}Modifiers\`)]`
171+
? `[__VLS_tryAsConstant(\`\${${prop.arg.content}}Modifiers\`)]`
172172
: camelize(propName) + `Modifiers`
173173
: `modelModifiers`;
174174
const codes = [...generateModifiers(

packages/language-core/lib/plugins/file-html.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { SFCParseResult } from '@vue/compiler-sfc';
22
import type { VueLanguagePlugin } from '../types';
33

4-
const sfcBlockReg = /\<(script|style)\b([\s\S]*?)\>([\s\S]*?)\<\/\1\>/g;
5-
const langReg = /\blang\s*=\s*(['\"]?)(\S*)\b\1/;
4+
const sfcBlockReg = /<(script|style)\b([\s\S]*?)>([\s\S]*?)<\/\1>/g;
5+
const langReg = /\blang\s*=\s*(['"]?)(\S*)\b\1/;
66

77
const plugin: VueLanguagePlugin = ({ vueCompilerOptions }) => {
88

packages/language-core/lib/plugins/file-md.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const frontmatterReg = /^---[\s\S]*?\n---(?:\r?\n|$)/;
99
const codeblockReg = /(`{3,})[\s\S]+?\1/g;
1010
const inlineCodeblockReg = /`[^\n`]+?`/g;
1111
const latexBlockReg = /(\${2,})[\s\S]+?\1/g;
12-
const scriptSetupReg = /\\\<[\s\S]+?\>\n?/g;
13-
const sfcBlockReg = /\<(script|style)\b[\s\S]*?\>([\s\S]*?)\<\/\1\>/g;
14-
const angleBracketReg = /\<\S*\:\S*\>/g;
12+
const scriptSetupReg = /\\<[\s\S]+?>\n?/g;
13+
const sfcBlockReg = /<(script|style)\b[\s\S]*?>([\s\S]*?)<\/\1>/g;
14+
const angleBracketReg = /<\S*:\S*>/g;
1515
const linkReg = /\[[\s\S]*?\]\([\s\S]*?\)/g;
1616
const codeSnippetImportReg = /^\s*<<<\s*.+/gm;
1717

packages/language-core/lib/utils/ts.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function createParsedCommandLineByJson(
3232
const obj = ts.convertToObject(configFile, []);
3333
const rawOptions: RawVueCompilerOptions = obj?.vueCompilerOptions ?? {};
3434
resolver.addConfig(rawOptions, path.dirname(configFile.fileName));
35-
} catch (err) { }
35+
} catch { }
3636
}
3737

3838
const resolvedVueOptions = resolver.build();
@@ -88,7 +88,7 @@ export function createParsedCommandLine(
8888
const obj = ts.convertToObject(configFile, []);
8989
const rawOptions: RawVueCompilerOptions = obj?.vueCompilerOptions ?? {};
9090
resolver.addConfig(rawOptions, path.dirname(configFile.fileName));
91-
} catch (err) { }
91+
} catch { }
9292
}
9393

9494
const resolvedVueOptions = resolver.build();
@@ -124,7 +124,7 @@ export function createParsedCommandLine(
124124
vueOptions: resolvedVueOptions,
125125
};
126126
}
127-
catch (err) {
127+
catch {
128128
// console.warn('Failed to resolve tsconfig path:', tsConfigPath, err);
129129
return {
130130
fileNames: [],
@@ -254,7 +254,7 @@ function resolvePath(scriptPath: string, root: string) {
254254
// console.warn('failed to resolve path:', scriptPath, 'require.resolve is not supported in web');
255255
}
256256
}
257-
catch (error) {
257+
catch {
258258
// console.warn(error);
259259
}
260260
}

packages/language-server/lib/reactionsAnalyze.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ function collect(ts: typeof import('typescript'), sourceFile: ts.SourceFile) {
308308
}
309309
}
310310
else if (ts.isParameter(node)) {
311-
if (node.type && node.type && ts.isTypeReferenceNode(node.type)) {
311+
if (node.type && ts.isTypeReferenceNode(node.type)) {
312312
const typeName = node.type.typeName.getText(sourceFile);
313313
if (typeName.endsWith('Ref')) {
314314
signals.push({

packages/language-service/lib/plugins/data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export function loadTemplateData(lang: string) {
4141

4242
resolveReferences(data);
4343

44+
// oxlint-disable-next-line no-useless-spread
4445
for (const attr of [...data.globalAttributes ?? []]) {
4546
if (!attr.name.startsWith('v-')) {
4647
data.globalAttributes?.push(

packages/language-service/lib/plugins/vue-inlayhints.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ export function findDestructuredProps(
221221
});
222222

223223
function enter(node: ts.Node) {
224-
parent && parentStack.push(parent);
224+
if (parent) {
225+
parentStack.push(parent);
226+
}
225227

226228
if (
227229
ts.isTypeLiteralNode(node) ||
@@ -273,7 +275,10 @@ export function findDestructuredProps(
273275
}
274276

275277
function leave(node: ts.Node) {
276-
parent && parentStack.pop();
278+
if (parent) {
279+
parentStack.pop();
280+
}
281+
277282
if (
278283
ts.isFunctionLike(node)
279284
|| ts.isCatchClause(node)

packages/language-service/scripts/update-html-data.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ const langs = [
8282
},
8383
];
8484

85+
localeWorker();
8586
for (const lang of langs) {
8687
if (lang.supported) {
87-
localeWorker(lang);
8888
templateWorker(lang);
8989
sfcWorker(lang);
9090
modelWorker(lang);
9191
}
9292
}
9393

94-
function localeWorker(lang) {
94+
function localeWorker() {
9595

9696
const data = langs.map(({ name, url }) => ({ name, url }));
9797

@@ -417,7 +417,7 @@ async function templateWorker(lang) {
417417
async function fetchText(url, baseUrl) {
418418
let text = await (await fetch(url)).text();
419419
text = text.replace(/```vue-html/g, '```html');
420-
text = text.replace(/\{\#.*?\}/g, '')
420+
text = text.replace(/\{#.*?\}/g, '')
421421
text = resolveMarkdownLinks(text, baseUrl);
422422
return text;
423423
}

packages/language-service/tests/utils/format.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function defineFormatTest(options: {
2222
languageId: string;
2323
settings?: any;
2424
}) {
25-
describe(`format: ${options.title}`, async () => {
25+
describe(`format: ${options.title}`, () => {
2626

2727
it(`format`, async () => {
2828

packages/tsc/tests/typecheck.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function getTscOutput() {
4444
{ paths: [path.resolve(__dirname, '../../../test-workspace')] }
4545
);
4646
run(tscPath);
47-
} catch (err) { }
47+
} catch { }
4848
process.stdout.write = originalConsoleLog;
4949
process.argv = originalArgv;
5050
return consoleOutput;

packages/typescript-plugin/lib/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function getCompletionEntryDetails<T>(
142142
// @ts-expect-error
143143
if (args[6]?.__isComponentAutoImport) {
144144
// @ts-expect-error
145-
const { ext, suffix, originalName, newName } = args[6]?.__isComponentAutoImport;
145+
const { originalName, newName } = args[6].__isComponentAutoImport;
146146
for (const codeAction of details?.codeActions ?? []) {
147147
for (const change of codeAction.changes) {
148148
for (const textChange of change.textChanges) {
@@ -154,7 +154,7 @@ function getCompletionEntryDetails<T>(
154154
// @ts-expect-error
155155
if (args[6]?.__isAutoImport) {
156156
// @ts-expect-error
157-
const { fileName } = args[6]?.__isAutoImport;
157+
const { fileName } = args[6].__isAutoImport;
158158
const sourceScript = language.scripts.get(asScriptId(fileName));
159159
if (sourceScript?.generated?.root instanceof VueVirtualCode) {
160160
const sfc = sourceScript.generated.root.vueSfc;

pnpm-lock.yaml

Lines changed: 83 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)