diff --git a/biome.json b/biome.json index e31c7e966a..3c5eb5a759 100644 --- a/biome.json +++ b/biome.json @@ -1,15 +1,11 @@ { - "$schema": "https://biomejs.dev/schemas/1.8.0/schema.json", - "organizeImports": { - "enabled": true, - "include": [ - "./**/*.js", - "./**/*.jsx", - "./**/*.ts", - "./**/*.tsx", - "./**/*.mjs", - "./**/*.cjs" - ] + "$schema": "https://biomejs.dev/schemas/2.0.0/schema.json", + "assist": { + "actions": { + "source": { + "organizeImports": "on" + } + } }, "vcs": { "enabled": true, @@ -18,12 +14,13 @@ "useIgnoreFile": true }, "files": { - "ignore": [ - "*.vue", - "*.svelte", - "template-lit-*/src/my-element.*", - "tsconfig.json", - "tsconfig.*.json" + "includes": [ + "**", + "!**/*.vue", + "!**/*.svelte", + "!**/template-lit-*/src/my-element.*", + "!**/tsconfig.json", + "!**/tsconfig.*.json" ], "ignoreUnknown": true }, @@ -46,7 +43,17 @@ "options": { "filenameCases": ["camelCase", "PascalCase", "export"] } - } + }, + "noParameterAssign": "error", + "useAsConstAssertion": "error", + "useDefaultParameterLast": "error", + "useEnumInitializers": "error", + "useSelfClosingElements": "error", + "useSingleVarDeclarator": "error", + "noUnusedTemplateLiteral": "error", + "useNumberNamespace": "error", + "noInferrableTypes": "error", + "noUselessElse": "error" }, "suspicious": { "noExplicitAny": "off", @@ -54,6 +61,12 @@ }, "performance": { "noDelete": "off" + }, + "nursery": { + "useUniqueElementIds": "off" + }, + "correctness": { + "useHookAtTopLevel": "off" } } } diff --git a/e2e/cases/assets/emit-assets/src/index.js b/e2e/cases/assets/emit-assets/src/index.js index b35c2e8e26..44e36361b6 100644 --- a/e2e/cases/assets/emit-assets/src/index.js +++ b/e2e/cases/assets/emit-assets/src/index.js @@ -1,4 +1,5 @@ import small from '../../../../assets/icon.png?url'; + const testJson = new URL('./assets/test.json', import.meta.url).href; console.log(small); diff --git a/e2e/cases/cli/watch-files-array/rsbuild.config.ts b/e2e/cases/cli/watch-files-array/rsbuild.config.ts index ea783776ca..eaaa0a926b 100644 --- a/e2e/cases/cli/watch-files-array/rsbuild.config.ts +++ b/e2e/cases/cli/watch-files-array/rsbuild.config.ts @@ -1,5 +1,5 @@ import path from 'node:path'; -import { type RsbuildPlugin, defineConfig } from '@rsbuild/core'; +import { defineConfig, type RsbuildPlugin } from '@rsbuild/core'; import fse from 'fs-extra'; import content from './test-temp-config'; diff --git a/e2e/cases/cli/watch-files/rsbuild.config.ts b/e2e/cases/cli/watch-files/rsbuild.config.ts index db44358234..b0fdced393 100644 --- a/e2e/cases/cli/watch-files/rsbuild.config.ts +++ b/e2e/cases/cli/watch-files/rsbuild.config.ts @@ -1,5 +1,5 @@ import path from 'node:path'; -import { type RsbuildPlugin, defineConfig } from '@rsbuild/core'; +import { defineConfig, type RsbuildPlugin } from '@rsbuild/core'; import fse from 'fs-extra'; import content from './test-temp-config'; diff --git a/e2e/cases/css/css-assets/index.test.ts b/e2e/cases/css/css-assets/index.test.ts index 5a4ff3a198..98262a416f 100644 --- a/e2e/cases/css/css-assets/index.test.ts +++ b/e2e/cases/css/css-assets/index.test.ts @@ -1,6 +1,5 @@ import path from 'node:path'; -import { build } from '@e2e/helper'; -import { readDirContents } from '@e2e/helper'; +import { build, readDirContents } from '@e2e/helper'; import { expect, test } from '@playwright/test'; test('should build CSS assets correctly', async () => { diff --git a/e2e/cases/html/template-with-script/index.test.ts b/e2e/cases/html/template-with-script/index.test.ts index 1396f56a19..41205927dd 100644 --- a/e2e/cases/html/template-with-script/index.test.ts +++ b/e2e/cases/html/template-with-script/index.test.ts @@ -10,5 +10,6 @@ test('should compile template with es template correctly', async () => { const indexHtml = files[Object.keys(files).find((file) => file.endsWith('index.html'))!]; + // biome-ignore lint/suspicious/noTemplateCurlyInString: should ignore string expect(indexHtml).toContain("const baseUrl = match ? `${match[0]}/` : '/'"); }); diff --git a/e2e/cases/module-federation-v2/host/src/bootstrap.js b/e2e/cases/module-federation-v2/host/src/bootstrap.js index 48342b5972..e96402f213 100644 --- a/e2e/cases/module-federation-v2/host/src/bootstrap.js +++ b/e2e/cases/module-federation-v2/host/src/bootstrap.js @@ -1,4 +1,3 @@ -import React from 'react'; import { createRoot } from 'react-dom/client'; import App from './App'; diff --git a/e2e/cases/module-federation-v2/remote/src/bootstrap.js b/e2e/cases/module-federation-v2/remote/src/bootstrap.js index 48342b5972..e96402f213 100644 --- a/e2e/cases/module-federation-v2/remote/src/bootstrap.js +++ b/e2e/cases/module-federation-v2/remote/src/bootstrap.js @@ -1,4 +1,3 @@ -import React from 'react'; import { createRoot } from 'react-dom/client'; import App from './App'; diff --git a/e2e/cases/module-federation/host/src/bootstrap.js b/e2e/cases/module-federation/host/src/bootstrap.js index 48342b5972..e96402f213 100644 --- a/e2e/cases/module-federation/host/src/bootstrap.js +++ b/e2e/cases/module-federation/host/src/bootstrap.js @@ -1,4 +1,3 @@ -import React from 'react'; import { createRoot } from 'react-dom/client'; import App from './App'; diff --git a/e2e/cases/module-federation/remote/src/bootstrap.js b/e2e/cases/module-federation/remote/src/bootstrap.js index 48342b5972..e96402f213 100644 --- a/e2e/cases/module-federation/remote/src/bootstrap.js +++ b/e2e/cases/module-federation/remote/src/bootstrap.js @@ -1,4 +1,3 @@ -import React from 'react'; import { createRoot } from 'react-dom/client'; import App from './App'; diff --git a/e2e/cases/module/glob-import/src/App.jsx b/e2e/cases/module/glob-import/src/App.jsx index 1e69cb6ee3..e71035adba 100644 --- a/e2e/cases/module/glob-import/src/App.jsx +++ b/e2e/cases/module/glob-import/src/App.jsx @@ -1,5 +1,3 @@ -import { useState } from 'react'; - const context = import.meta.webpackContext('./components', { regExp: /\.jsx$/, recursive: false, @@ -8,8 +6,6 @@ const context = import.meta.webpackContext('./components', { const fileNames = context.keys(); const App = () => { - const [count, setCount] = useState(0); - const components = fileNames.map((fileName) => { const module = context(fileName); const Component = module.default; diff --git a/e2e/cases/node-polyfill-tip/with-protocol/index.test.ts b/e2e/cases/node-polyfill-tip/with-protocol/index.test.ts index ea32e3309f..606aa1e73d 100644 --- a/e2e/cases/node-polyfill-tip/with-protocol/index.test.ts +++ b/e2e/cases/node-polyfill-tip/with-protocol/index.test.ts @@ -6,7 +6,7 @@ test('should print tips if resolve Node.js builtin module failed', async () => { try { await build({ cwd: __dirname }); - } catch (err) {} + } catch {} restore(); expect( diff --git a/e2e/cases/node-polyfill-tip/without-protocol/index.test.ts b/e2e/cases/node-polyfill-tip/without-protocol/index.test.ts index ea32e3309f..606aa1e73d 100644 --- a/e2e/cases/node-polyfill-tip/without-protocol/index.test.ts +++ b/e2e/cases/node-polyfill-tip/without-protocol/index.test.ts @@ -6,7 +6,7 @@ test('should print tips if resolve Node.js builtin module failed', async () => { try { await build({ cwd: __dirname }); - } catch (err) {} + } catch {} restore(); expect( diff --git a/e2e/cases/plugin-api/plugin-after-build-hook/index.test.ts b/e2e/cases/plugin-api/plugin-after-build-hook/index.test.ts index abe91e2adb..d34c090a61 100644 --- a/e2e/cases/plugin-api/plugin-after-build-hook/index.test.ts +++ b/e2e/cases/plugin-api/plugin-after-build-hook/index.test.ts @@ -2,7 +2,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { rspackOnlyTest } from '@e2e/helper'; import { expect } from '@playwright/test'; -import { type RsbuildPlugin, createRsbuild } from '@rsbuild/core'; +import { createRsbuild, type RsbuildPlugin } from '@rsbuild/core'; import fse, { remove } from 'fs-extra'; const distFile = path.join(__dirname, 'node_modules/hooksTempFile'); diff --git a/e2e/cases/plugin-api/plugin-expose/index.test.ts b/e2e/cases/plugin-api/plugin-expose/index.test.ts index 84883aaa47..49ab2b377b 100644 --- a/e2e/cases/plugin-api/plugin-expose/index.test.ts +++ b/e2e/cases/plugin-api/plugin-expose/index.test.ts @@ -1,6 +1,6 @@ import { rspackOnlyTest } from '@e2e/helper'; import { expect } from '@playwright/test'; -import { type RsbuildPlugin, createRsbuild } from '@rsbuild/core'; +import { createRsbuild, type RsbuildPlugin } from '@rsbuild/core'; type ParentAPI = { initial: number; diff --git a/e2e/cases/plugin-api/plugin-hooks-environment/index.test.ts b/e2e/cases/plugin-api/plugin-hooks-environment/index.test.ts index 05e049fe3e..39c2881528 100644 --- a/e2e/cases/plugin-api/plugin-hooks-environment/index.test.ts +++ b/e2e/cases/plugin-api/plugin-hooks-environment/index.test.ts @@ -1,6 +1,6 @@ import { getRandomPort, gotoPage, rspackOnlyTest } from '@e2e/helper'; import { expect } from '@playwright/test'; -import { type RsbuildPlugin, createRsbuild } from '@rsbuild/core'; +import { createRsbuild, type RsbuildPlugin } from '@rsbuild/core'; const createPlugin = () => { const names: string[] = []; diff --git a/e2e/cases/plugin-api/plugin-hooks-watch/index.test.ts b/e2e/cases/plugin-api/plugin-hooks-watch/index.test.ts index 8d6fdc06bb..399f2d63f5 100644 --- a/e2e/cases/plugin-api/plugin-hooks-watch/index.test.ts +++ b/e2e/cases/plugin-api/plugin-hooks-watch/index.test.ts @@ -2,7 +2,7 @@ import fs from 'node:fs'; import { join } from 'node:path'; import { expectFile, rspackOnlyTest } from '@e2e/helper'; import { expect } from '@playwright/test'; -import { type RsbuildPlugin, createRsbuild } from '@rsbuild/core'; +import { createRsbuild, type RsbuildPlugin } from '@rsbuild/core'; import fse, { remove } from 'fs-extra'; const createPlugin = () => { diff --git a/e2e/cases/plugin-api/plugin-hooks/index.test.ts b/e2e/cases/plugin-api/plugin-hooks/index.test.ts index 0aaf347e43..d7f78897d0 100644 --- a/e2e/cases/plugin-api/plugin-hooks/index.test.ts +++ b/e2e/cases/plugin-api/plugin-hooks/index.test.ts @@ -1,6 +1,6 @@ import { getRandomPort, gotoPage, rspackOnlyTest } from '@e2e/helper'; import { expect } from '@playwright/test'; -import { type RsbuildPlugin, createRsbuild } from '@rsbuild/core'; +import { createRsbuild, type RsbuildPlugin } from '@rsbuild/core'; const createPlugin = () => { const names: string[] = []; diff --git a/e2e/cases/plugin-react/enable-profiler/src/App.jsx b/e2e/cases/plugin-react/enable-profiler/src/App.jsx index 070970286a..639af6a6e2 100644 --- a/e2e/cases/plugin-react/enable-profiler/src/App.jsx +++ b/e2e/cases/plugin-react/enable-profiler/src/App.jsx @@ -1,5 +1,3 @@ -import React from 'react'; - const App = () =>
Hello Rsbuild!
; export default App; diff --git a/e2e/cases/plugin-react/legacy-jsx/src/App.jsx b/e2e/cases/plugin-react/legacy-jsx/src/App.jsx index 070970286a..d940dde6b6 100644 --- a/e2e/cases/plugin-react/legacy-jsx/src/App.jsx +++ b/e2e/cases/plugin-react/legacy-jsx/src/App.jsx @@ -1,3 +1,4 @@ +// biome-ignore lint/correctness/noUnusedImports: required in legacy jsx import React from 'react'; const App = () =>
Hello Rsbuild!
; diff --git a/e2e/cases/plugin-solid/ref/src/App.jsx b/e2e/cases/plugin-solid/ref/src/App.jsx index 94078e2dff..3704f37a02 100644 --- a/e2e/cases/plugin-solid/ref/src/App.jsx +++ b/e2e/cases/plugin-solid/ref/src/App.jsx @@ -1,7 +1,7 @@ import { createSignal } from 'solid-js'; const App = () => { - const [el, setEl] = createSignal(); + const [_el, setEl] = createSignal(); return (
abc diff --git a/e2e/cases/plugin-svgr/exclude-importer/src/index.jsx b/e2e/cases/plugin-svgr/exclude-importer/src/index.jsx index 5d1fd7163e..05d43f81e8 100644 --- a/e2e/cases/plugin-svgr/exclude-importer/src/index.jsx +++ b/e2e/cases/plugin-svgr/exclude-importer/src/index.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { createRoot } from 'react-dom/client'; import Bar from './Bar'; import Foo from './Foo'; diff --git a/e2e/cases/plugin-svgr/exclude/src/index.jsx b/e2e/cases/plugin-svgr/exclude/src/index.jsx index 5d1fd7163e..05d43f81e8 100644 --- a/e2e/cases/plugin-svgr/exclude/src/index.jsx +++ b/e2e/cases/plugin-svgr/exclude/src/index.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { createRoot } from 'react-dom/client'; import Bar from './Bar'; import Foo from './Foo'; diff --git a/e2e/cases/rsdoctor/index.test.ts b/e2e/cases/rsdoctor/index.test.ts index 1cfb7173b9..9afa62922f 100644 --- a/e2e/cases/rsdoctor/index.test.ts +++ b/e2e/cases/rsdoctor/index.test.ts @@ -1,6 +1,6 @@ import { proxyConsole, rspackOnlyTest } from '@e2e/helper'; import { expect } from '@playwright/test'; -import { type Rspack, createRsbuild } from '@rsbuild/core'; +import { createRsbuild, type Rspack } from '@rsbuild/core'; import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'; import { matchPlugin } from '@scripts/test-helper'; diff --git a/e2e/cases/server/overlay-type-errors/src/index.ts b/e2e/cases/server/overlay-type-errors/src/index.ts index 9a0048bf68..2694a4f93d 100644 --- a/e2e/cases/server/overlay-type-errors/src/index.ts +++ b/e2e/cases/server/overlay-type-errors/src/index.ts @@ -1,3 +1,5 @@ // This is a type error let num = 1; num = '2'; + +console.log(num); diff --git a/e2e/cases/server/ssr-type-module/rsbuild.config.ts b/e2e/cases/server/ssr-type-module/rsbuild.config.ts index 0d38641aab..dbfeccca5c 100644 --- a/e2e/cases/server/ssr-type-module/rsbuild.config.ts +++ b/e2e/cases/server/ssr-type-module/rsbuild.config.ts @@ -1,8 +1,8 @@ import { - type RequestHandler, - type SetupMiddlewaresServer, defineConfig, logger, + type RequestHandler, + type SetupMiddlewaresServer, } from '@rsbuild/core'; import { pluginReact } from '@rsbuild/plugin-react'; diff --git a/e2e/cases/server/ssr/rsbuild.config.ts b/e2e/cases/server/ssr/rsbuild.config.ts index 80ca9b1b40..5ade71f506 100644 --- a/e2e/cases/server/ssr/rsbuild.config.ts +++ b/e2e/cases/server/ssr/rsbuild.config.ts @@ -1,8 +1,8 @@ import { - type RequestHandler, - type SetupMiddlewaresServer, defineConfig, logger, + type RequestHandler, + type SetupMiddlewaresServer, } from '@rsbuild/core'; import { pluginReact } from '@rsbuild/plugin-react'; diff --git a/e2e/cases/sri/algotithm/index.test.ts b/e2e/cases/sri/algotithm/index.test.ts index cfe0968f5c..09fd37f7b1 100644 --- a/e2e/cases/sri/algotithm/index.test.ts +++ b/e2e/cases/sri/algotithm/index.test.ts @@ -14,11 +14,11 @@ rspackOnlyTest( files[Object.keys(files).find((file) => file.endsWith('index.html'))!]; expect(html).toMatch( - /