Skip to content

Commit

Permalink
chore(infra): migrate to biome for import order sorting (#6741)
Browse files Browse the repository at this point in the history
* chore(infra): sort-imports migrate to biome

* chore(infra): npm run lint:js-sort-imports-order and npm run api-extractor:local

* chore: fix prettier config

* chore: rebase master

* chore: update

* chore: update

* chore: update

* chore: update
  • Loading branch information
SoonIter committed Jun 7, 2024
1 parent c0c0fd3 commit c040bfc
Show file tree
Hide file tree
Showing 99 changed files with 865 additions and 1,079 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ jobs:
if: steps.changes.outputs.src == 'true'
run: pnpm run lint:js

- name: Eslint
- name: Biome Sort Imports Order
if: steps.changes.outputs.src == 'true'
run: pnpm run eslint:js
run: pnpm run lint-ci:js-sort-imports-order

- name: Prettier
if: steps.changes.outputs.src == 'true'
Expand Down
35 changes: 35 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.0/schema.json",
"formatter": {
"enabled": false
},
"organizeImports": {
"enabled": true,
"ignore": [
"packages/rspack/src/config/schema.check.js",
"packages/**/etc/**/*",
"packages/**/compiled/**/*",
"plugin-test/**/*",
"benchcases/**/*",
"crates/**/*",
"webpack-test/**/*",
"webpack-cli-test/**/*",
"webpack-examples/**/*",
"packages/playground/**/*",
"packages/rspack-dev-server/client",
"packages/rspack-plugin-react-refresh/client",
"packages/rspack-test-tools/template/**/*",
"packages/rspack-test-tools/tests/**/*",
"packages/rspack-plugin-mini-css-extract/test/cases/**/*"
]
},
"linter": {
"enabled": false
},
"vcs": {
"enabled": true,
"defaultBranch": "main",
"clientKind": "git",
"useIgnoreFile": true
}
}
36 changes: 0 additions & 36 deletions eslint.config.mjs

This file was deleted.

6 changes: 3 additions & 3 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default {
"*.rs": "rustfmt --edition 2021",
"*.{ts,js}": "pnpm run format:js",
"*.{ts,tsx,js}": "pnpm run format:js",
"*.toml": "npx @taplo/cli format",
"*.{ts,js,cts,cjs,mts,mjs}": () => [
"*.{ts,tsx,js,cts,cjs,mts,mjs}": () => [
"pnpm run lint:js",
"pnpm eslint --report-unused-disable-directives-severity off --cache --fix",
"pnpm run lint:js-sort-imports-order",
"pnpm run api-extractor:ci"
]
};
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
"test:js": "pnpm -r run test",
"format:rs": "pnpm --filter @rspack/core... build",
"format:js": "pnpm run format-ci:js --write",
"format-ci:js": "node ./node_modules/prettier/bin/prettier.cjs \"packages/**/src/**/*.{ts,js}\" \"crates/rspack_plugin_runtime/**/*.{ts,js}\" \"x.mjs\" --check",
"format-ci:js": "node ./node_modules/prettier/bin/prettier.cjs \"packages/**/src/**/*.{ts,tsx,js}\" \"crates/rspack_plugin_runtime/**/*.{ts,js}\" \"x.mjs\" --check",
"format-ci:toml": "npx @taplo/cli format --check '.cargo/*.toml' './crates/**/Cargo.toml' './Cargo.toml'",
"format:toml": "npx @taplo/cli format '.cargo/*.toml' './crates/**/Cargo.toml' './Cargo.toml'",
"lint:js": "oxlint --deny-warnings -c .eslintrc.json",
"eslint:js": "eslint --report-unused-disable-directives-severity off --cache",
"lint:js-sort-imports-order": "pnpm run lint-ci:js-sort-imports-order --write",
"lint-ci:js-sort-imports-order": "biome check",
"lint:rs": "node ./scripts/check_rust_dependency.cjs",
"build:binding:debug": "pnpm --filter @rspack/binding run build:debug",
"build:binding:release": "pnpm --filter @rspack/binding run build:release",
Expand All @@ -51,19 +52,16 @@
"pnpm": "8.14.3"
},
"devDependencies": {
"@biomejs/biome": "1.8.0",
"@microsoft/api-extractor": "^7.43.1",
"@rspack/cli": "workspace:*",
"@taplo/cli": "^0.7.0",
"@types/is-ci": "^3.0.4",
"@types/jest": "29.5.12",
"@types/node": "20.12.7",
"@types/rimraf": "3.0.2",
"@typescript-eslint/parser": "^7.9.0",
"commander": "12.0.0",
"cross-env": "^7.0.3",
"eslint": "^9.2.0",
"eslint-plugin-oxlint": "^0.2.9",
"eslint-plugin-simple-import-sort": "^12.1.0",
"filenamify": "^4.3.0",
"husky": "^9.0.0",
"is-ci": "3.0.1",
Expand Down
18 changes: 9 additions & 9 deletions packages/create-rspack/template-react-ts/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.tsx";
import "./index.css";

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
);
2 changes: 1 addition & 1 deletion packages/rspack-cli/src/commands/build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MultiStats, Stats } from "@rspack/core";
import * as fs from "fs";
import { MultiStats, Stats } from "@rspack/core";

import type { RspackCLI } from "../rspack-cli";
import { RspackCommand } from "../types";
Expand Down
6 changes: 3 additions & 3 deletions packages/rspack-cli/src/commands/preview.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import path from "path";
import {
DevServer,
MultiRspackOptions,
rspack,
RspackOptions
RspackOptions,
rspack
} from "@rspack/core";
import path from "path";

import type { RspackCLI } from "../rspack-cli";
import { RspackCommand, RspackPreviewCLIOptions } from "../types";
Expand Down
8 changes: 4 additions & 4 deletions packages/rspack-cli/src/rspack-cli.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import path from "path";
import util from "util";
import type { RspackPluginFunction, RspackPluginInstance } from "@rspack/core";
import {
Compiler,
MultiCompiler,
MultiRspackOptions,
MultiStats,
rspack,
RspackOptions,
Stats
Stats,
rspack
} from "@rspack/core";
import * as rspackCore from "@rspack/core";
import path from "path";
import semver from "semver";
import util from "util";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";

Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-cli/src/utils/loadConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MultiRspackOptions, RspackOptions } from "@rspack/core";
import fs from "fs";
import interpret from "interpret";
import path from "path";
import { MultiRspackOptions, RspackOptions } from "@rspack/core";
import interpret from "interpret";
import rechoir from "rechoir";

import { RspackCLIOptions } from "../types";
Expand Down
10 changes: 5 additions & 5 deletions packages/rspack-cli/src/utils/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ The full syntax, remember update this when you change something in this file.
*/

import fs from "fs";
import path from "path";
import { URLSearchParams } from "url";
import {
type Compiler,
RspackOptions,
experimental_cleanupGlobalTrace as cleanupGlobalTrace,
experimental_registerGlobalTrace as registerGlobalTrace,
RspackOptions
experimental_registerGlobalTrace as registerGlobalTrace
} from "@rspack/core";
import fs from "fs";
import inspector from "inspector";
import path from "path";
import { URLSearchParams } from "url";

type JSCPUProfileOptionsOutput = string;
type JSCPUProfileOptions = {
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-cli/tests/build/config/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { run } from "../../utils/test-utils";
import { readFile } from "fs/promises";
import { resolve } from "path";
import { readFile } from "fs/promises";
import { run } from "../../utils/test-utils";

describe("rspack cli", () => {
describe("should config not found", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-cli/tests/build/issue-6214/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFile, run } from "../../utils/test-utils";
import { resolve } from "path";
import { readFile, run } from "../../utils/test-utils";

it("should not have `process.env.NODE_ENV` when optimization.nodeEnv has been set", async () => {
await run(__dirname, ["--mode", "production"]);
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-cli/tests/build/issue-6359/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFile, run, runWatch } from "../../utils/test-utils";
import { resolve } from "path";
import { readFile, run, runWatch } from "../../utils/test-utils";

it("should not have `process.env.WEBPACK_SERVE` set on build mode", async () => {
await run(__dirname, []);
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-cli/tests/build/json/json.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { existsSync } from "fs";
import { resolve } from "path";
import { run, readFile } from "../../utils/test-utils";
import { readFile, run } from "../../utils/test-utils";

const successMessage = "stats are successfully stored as json to stats.json";

Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-cli/tests/build/profile/profile.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from "fs";
import { run } from "../../utils/test-utils";
import { resolve } from "path";
import { run } from "../../utils/test-utils";

const defaultTracePath = "./trace.json";
const defaultJSCPUPath = "./jscpuprofile.json";
Expand Down
6 changes: 3 additions & 3 deletions packages/rspack-dev-server/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Compiler } from "@rspack/core";
import crypto from "crypto";
import type { RequestHandler, Response } from "express";
import type { IncomingMessage } from "http";
import mime from "mime-types";
import { extname } from "path";
import { parse } from "url";
import type { Compiler } from "@rspack/core";
import type { RequestHandler, Response } from "express";
import mime from "mime-types";
import wdm from "webpack-dev-middleware";

function etag(buf: any) {
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-dev-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
*/
import path from "node:path";

import { Compiler, MultiCompiler } from "@rspack/core";
import type { FSWatcher } from "chokidar";
import fs from "fs";
import type { Server } from "http";
import type { Socket } from "net";
import { Compiler, MultiCompiler } from "@rspack/core";
import type { FSWatcher } from "chokidar";
import rdm from "webpack-dev-middleware";
import WebpackDevServer from "webpack-dev-server";

Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-dev-server/tests/normalizeOptions.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { RspackOptions, rspack } from "@rspack/core";
import { RspackDevServer, Configuration } from "@rspack/dev-server";
import { Configuration, RspackDevServer } from "@rspack/dev-server";
import ReactRefreshPlugin from "@rspack/plugin-react-refresh";
import customConfig from "./fixtures/provide-plugin-custom/webpack.config";
// @ts-expect-error
import serializer from "jest-serializer-path";
import customConfig from "./fixtures/provide-plugin-custom/webpack.config";

expect.addSnapshotSerializer(serializer);

Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-plugin-react-refresh/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Compiler } from "@rspack/core";
import path from "path";
import type { Compiler } from "@rspack/core";

import { normalizeOptions, type PluginOptions } from "./options";
import { type PluginOptions, normalizeOptions } from "./options";

export type { PluginOptions };

Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/case/diff.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from "fs-extra";
import path from "path";
import fs from "fs-extra";
import rimraf from "rimraf";

import createLazyTestEnv from "../helper/legacy/createLazyTestEnv";
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/compare/comparator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import deepmerge from "deepmerge";
import path from "path";
import deepmerge from "deepmerge";

import { ITestReporter, TCompareModules } from "../type";
import { compareFile } from "./compare";
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/compare/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TFileCompareResult,
TModuleCompareResult
} from "../type";
import { formatCode, IFormatCodeOptions } from "./format-code";
import { IFormatCodeOptions, formatCode } from "./format-code";
import { replaceRuntimeModuleName } from "./replace-runtime-module-name";

export interface ICompareOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/processor/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import path from "path";

import { readConfigFile } from "..";
import {
compareFile,
IFormatCodeOptions,
compareFile,
replaceRuntimeModuleName
} from "../compare";
import { RspackDiffConfigPlugin, WebpackDiffConfigPlugin } from "../plugin";
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/processor/error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StatsError, StatsWarnings } from "@rspack/core";
import fs from "fs";
import path from "path";
import { StatsError, StatsWarnings } from "@rspack/core";
import prettyFormat from "pretty-format";
import merge from "webpack-merge";

Expand Down
6 changes: 3 additions & 3 deletions packages/rspack-test-tools/src/processor/hook.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import path from "path";
import { Compilation, Compiler } from "@rspack/core";
import { getSerializers } from "jest-snapshot";
import path from "path";
import { format as prettyFormat, PrettyFormatOptions } from "pretty-format";
import { PrettyFormatOptions, format as prettyFormat } from "pretty-format";
import { Source } from "webpack-sources";

import { TestContext, TTestContextOptions } from "../test/context";
import { TTestContextOptions, TestContext } from "../test/context";
import {
ECompilerType,
ITestContext,
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/processor/hot-step.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import { Chunk } from "@rspack/core";
import fs from "fs-extra";
import path from "path";

import { escapeEOL, escapeSep } from "../helper";
import { THotStepRuntimeData } from "../runner";
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/processor/hot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import { rspack } from "@rspack/core";
import fs from "fs-extra";
import path from "path";

import {
ECompilerType,
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/processor/snapshot.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Compiler as RspackCompiler } from "@rspack/core";
import path from "path";
import { type Compiler as RspackCompiler } from "@rspack/core";
import {
type Compilation as WebpackCompilation,
type Compiler as WebpackCompiler
Expand Down
Loading

2 comments on commit c040bfc

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-06-07 c0c0fd3) Current Change
10000_development-mode + exec 2.24 s ± 15 ms 2.22 s ± 22 ms -0.58 %
10000_development-mode_hmr + exec 739 ms ± 5.1 ms 731 ms ± 8.2 ms -1.10 %
10000_production-mode + exec 2.58 s ± 28 ms 2.58 s ± 18 ms +0.26 %
arco-pro_development-mode + exec 1.94 s ± 84 ms 1.93 s ± 67 ms -0.79 %
arco-pro_development-mode_hmr + exec 441 ms ± 2 ms 441 ms ± 2.6 ms -0.17 %
arco-pro_production-mode + exec 3.51 s ± 72 ms 3.55 s ± 74 ms +1.05 %
threejs_development-mode_10x + exec 1.4 s ± 8.4 ms 1.4 s ± 22 ms -0.29 %
threejs_development-mode_10x_hmr + exec 808 ms ± 7.4 ms 808 ms ± 9.6 ms +0.08 %
threejs_production-mode_10x + exec 4.71 s ± 35 ms 4.71 s ± 23 ms +0.09 %

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ✅ success
_selftest ✅ success
nx ✅ success
rspress ✅ success
rsbuild ❌ failure
compat ✅ success
examples ✅ success

Please sign in to comment.