Skip to content

Commit

Permalink
chore: Add oxlint for linting (#947)
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 authored Aug 30, 2024
1 parent 2a97c06 commit 0bd94fc
Show file tree
Hide file tree
Showing 19 changed files with 133 additions and 40 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.1",
"@aklinker1/check": "^1.3.1",
"@aklinker1/check": "^1.4.5",
"@types/fs-extra": "^11.0.4",
"@vitest/coverage-v8": "^2.0.4",
"changelogen": "^0.5.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/auto-icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"wxt": ">=0.19.0"
},
"devDependencies": {
"@aklinker1/check": "^1.3.1",
"@aklinker1/check": "^1.4.5",
"oxlint": "^0.9.1",
"publint": "^0.2.9",
"typescript": "^5.5.4",
"unbuild": "^2.0.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@
}
},
"devDependencies": {
"@aklinker1/check": "^1.3.1",
"@aklinker1/check": "^1.4.5",
"@types/chrome": "^0.0.268",
"@types/node": "^20.14.2",
"oxlint": "^0.9.1",
"publint": "^0.2.8",
"typescript": "^5.4.5",
"unbuild": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function applyChromeMessagePlaceholders(message: ChromeMessage): string {
export function getSubstitionCount(message: string): number {
return (
1 +
new Array(MAX_SUBSTITUTIONS).findLastIndex((_, i) =>
Array.from({ length: MAX_SUBSTITUTIONS }).findLastIndex((_, i) =>
message.match(new RegExp(`(?<!\\$)\\$${i + 1}`)),
)
);
Expand Down
2 changes: 1 addition & 1 deletion packages/module-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@vitejs/plugin-react": "^4.3.1"
},
"devDependencies": {
"@aklinker1/check": "^1.3.1",
"@aklinker1/check": "^1.4.5",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"publint": "^0.2.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/module-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"vite-plugin-solid": "^2.10.2"
},
"devDependencies": {
"@aklinker1/check": "^1.3.1",
"@aklinker1/check": "^1.4.5",
"publint": "^0.2.9",
"solid-js": "^1.8.19",
"typescript": "^5.5.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/module-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@sveltejs/vite-plugin-svelte": "^3.1.1"
},
"devDependencies": {
"@aklinker1/check": "^1.3.1",
"@aklinker1/check": "^1.4.5",
"publint": "^0.2.9",
"typescript": "^5.5.4",
"unbuild": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/module-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@vitejs/plugin-vue": "^5.1.1"
},
"devDependencies": {
"@aklinker1/check": "^1.3.1",
"@aklinker1/check": "^1.4.5",
"publint": "^0.2.9",
"typescript": "^5.5.4",
"unbuild": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/wxt/.oxlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/core/utils/building/__tests__/test-entrypoints
3 changes: 2 additions & 1 deletion packages/wxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"webextension-polyfill": "^0.12.0"
},
"devDependencies": {
"@aklinker1/check": "^1.3.1",
"@aklinker1/check": "^1.4.5",
"@faker-js/faker": "^8.4.1",
"@types/chrome": "^0.0.269",
"@types/fs-extra": "^11.0.4",
Expand All @@ -137,6 +137,7 @@
"extract-zip": "^2.0.1",
"happy-dom": "^14.12.3",
"lodash.merge": "^4.6.2",
"oxlint": "^0.9.1",
"p-map": "^7.0.2",
"publint": "^0.2.9",
"tsx": "4.15.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/wxt/src/core/create-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function createFileReloader(server: WxtDevServer) {
wxt.logger.success(`Reloaded: ${getFilenameList(rebuiltNames)}`);
break;
}
} catch (err) {
} catch {
// Catch build errors instead of crashing. Don't log error either, builder should have already logged it
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/wxt/src/core/utils/building/resolve-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export async function resolveConfig(
if (await isDirMissing(entrypointsDir)) {
logMissingDir(logger, 'Entrypoints', entrypointsDir);
}
const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length
const filterEntrypoints = mergedConfig.filterEntrypoints?.length
? new Set(mergedConfig.filterEntrypoints)
: undefined;
const publicDir = path.resolve(srcDir, mergedConfig.publicDir ?? 'public');
Expand Down
2 changes: 1 addition & 1 deletion packages/wxt/src/core/utils/entrypoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function getEntrypointName(
): string {
const relativePath = path.relative(entrypointsDir, inputPath);
// Grab the string up to the first . or / or \\
const name = relativePath.split(/[\.\/\\]/, 2)[0];
const name = relativePath.split(/[./\\]/, 2)[0];

return name;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/wxt/src/core/utils/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function applyGlobals(globals: EnvGlobals): void {
try {
// @ts-expect-error: Untyped key on globalThis
globalThis[key] = envValue;
} catch (err) {
} catch {
// ignore any globals that can't be set
}
});
Expand Down
3 changes: 2 additions & 1 deletion packages/wxt/src/core/utils/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export async function getEslintVersion(): Promise<string[]> {
);
const { ESLint } = require('eslint');
return ESLint.version?.split('.') ?? [];
} catch (error) {
} catch {
// Return an empty version when there's an error importing ESLint
return [];
}
}
8 changes: 4 additions & 4 deletions packages/wxt/src/core/utils/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,14 @@ function addEntrypoints(
options.browser_style = popup.options.browserStyle;
if (manifest.manifest_version === 3) {
manifest.action = {
...(manifest.action ?? {}),
...manifest.action,
...options,
default_popup,
};
} else {
const key = popup.options.mv2Key ?? 'browser_action';
manifest[key] = {
...(manifest[key] ?? {}),
...manifest[key],
...options,
default_popup,
};
Expand Down Expand Up @@ -434,8 +434,8 @@ function discoverIcons(
/^icon@([0-9]+)w\.png$/, // [email protected]
/^icon@([0-9]+)h\.png$/, // [email protected]
/^icon@([0-9]+)\.png$/, // [email protected]
/^icons?[\/\\]([0-9]+)\.png$/, // icon/16.png | icons/16.png
/^icons?[\/\\]([0-9]+)x[0-9]+\.png$/, // icon/16x16.png | icons/16x16.png
/^icons?[/\\]([0-9]+)\.png$/, // icon/16.png | icons/16.png
/^icons?[/\\]([0-9]+)x[0-9]+\.png$/, // icon/16x16.png | icons/16x16.png
];
// #endregion snippet

Expand Down
1 change: 1 addition & 0 deletions packages/wxt/src/core/utils/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export async function getPackageJson(): Promise<
} catch (err) {
wxt.logger.debug(
`Failed to read package.json at: ${file}. Returning undefined.`,
err,
);
return {};
}
Expand Down
4 changes: 1 addition & 3 deletions packages/wxt/src/core/utils/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ function getSimpleAstJson(ast: any): any {
} else if (typeof ast === 'object') {
return Object.fromEntries(
Object.entries(ast)
.filter(
([key, value]) => key !== 'loc' && key !== 'start' && key !== 'end',
)
.filter(([key]) => key !== 'loc' && key !== 'start' && key !== 'end')
.map(([key, value]) => [key, getSimpleAstJson(value)]),
);
} else {
Expand Down
Loading

0 comments on commit 0bd94fc

Please sign in to comment.