From 182c8eb562064a8dd04e9cdc06c3ee838ffd8c4c Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 28 Apr 2026 21:36:55 +0800 Subject: [PATCH] chore: migrate to rslint and prettier --- .github/renovate.json5 | 26 ++--- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 6 +- .prettierignore | 3 + .prettierrc | 3 + .vscode/extensions.json | 2 +- .vscode/settings.json | 16 +-- README.md | 34 +++--- biome.json | 31 ------ package.json | 13 ++- pnpm-lock.yaml | 182 ++++++++++++++++----------------- rslint.config.ts | 3 + src/TailwindCSSRspackPlugin.ts | 5 +- 13 files changed, 139 insertions(+), 187 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc delete mode 100644 biome.json create mode 100644 rslint.config.ts diff --git a/.github/renovate.json5 b/.github/renovate.json5 index f2a89a7..5912956 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -1,18 +1,12 @@ { - $schema: 'https://docs.renovatebot.com/renovate-schema.json', - extends: [ - 'config:recommended', - 'schedule:monthly', - 'group:allNonMajor', - ], - baseBranchPatterns: ['main', 'v4'], - rangeStrategy: 'bump', - packageRules: [ - { - matchDepTypes: [ - 'peerDependencies', - ], - enabled: false, - }, - ], + $schema: 'https://docs.renovatebot.com/renovate-schema.json', + extends: ['config:recommended', 'schedule:monthly', 'group:allNonMajor'], + baseBranchPatterns: ['main', 'v4'], + rangeStrategy: 'bump', + packageRules: [ + { + matchDepTypes: ['peerDependencies'], + enabled: false, + }, + ], } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dbc4f91..c4c791e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: # Run `npm run bump` to bump the version and create a git tag. push: tags: - - "v*" + - 'v*' workflow_dispatch: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ec5f1d5..a8f4015 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,8 +19,8 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] tailwindcss: - - "^3" - - "3.1.0" # The fist version that support `options.config`. + - '^3' + - '3.1.0' # The fist version that support `options.config`. # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -41,7 +41,7 @@ jobs: - name: Install tailwindcss@${{ matrix.tailwindcss }} if: ${{ matrix.tailwindcss }} != "latest" # Tailwind CSS <= v3.4.0 does not have correct TypeScript definition, which will make `rslib build` fail. - continue-on-error: true + continue-on-error: true run: pnpm add -D -w tailwindcss@${{ matrix.tailwindcss }} - name: Run Test diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..79e4884 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +# Ignore artifacts: +dist +pnpm-lock.yaml diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..544138b --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "singleQuote": true +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 699ed73..f172f18 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["biomejs.biome"] + "recommendations": ["rstack.rslint", "esbenp.prettier-vscode"] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 58f2f56..770e0e6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,18 +1,4 @@ { "search.useIgnoreFiles": true, - "[json]": { - "editor.defaultFormatter": "biomejs.biome" - }, - "[typescript]": { - "editor.defaultFormatter": "biomejs.biome" - }, - "[javascript]": { - "editor.defaultFormatter": "biomejs.biome" - }, - "[javascriptreact]": { - "editor.defaultFormatter": "biomejs.biome" - }, - "[css]": { - "editor.defaultFormatter": "biomejs.biome" - } + "editor.defaultFormatter": "esbenp.prettier-vscode" } diff --git a/README.md b/README.md index db2fc02..665c66c 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Add plugin to your `rsbuild.config.ts`: ```ts // rsbuild.config.ts -import { pluginTailwindCSS } from "rsbuild-plugin-tailwindcss"; +import { pluginTailwindCSS } from 'rsbuild-plugin-tailwindcss'; export default { plugins: [pluginTailwindCSS()], @@ -47,15 +47,15 @@ Create a `tailwind.config.js` file at the root of the project: export default { theme: { colors: { - blue: "#1fb6ff", - purple: "#7e5bef", - pink: "#ff49db", - orange: "#ff7849", - green: "#13ce66", - yellow: "#ffc82c", - "gray-dark": "#273444", - gray: "#8492a6", - "gray-light": "#d3dce6", + blue: '#1fb6ff', + purple: '#7e5bef', + pink: '#ff49db', + orange: '#ff7849', + green: '#13ce66', + yellow: '#ffc82c', + 'gray-dark': '#273444', + gray: '#8492a6', + 'gray-light': '#d3dce6', }, }, }; @@ -74,7 +74,7 @@ Create a `postcss.config.js` file at the root of the project: ```js export default { plugins: { - cssnano: process.env["NODE_ENV"] === "production" ? {} : false, + cssnano: process.env['NODE_ENV'] === 'production' ? {} : false, }, }; ``` @@ -98,12 +98,12 @@ The path to custom Tailwind CSS configuration. Could be a relative path from the ```js // rsbuild.config.ts -import { pluginTailwindCSS } from "rsbuild-plugin-tailwindcss"; +import { pluginTailwindCSS } from 'rsbuild-plugin-tailwindcss'; export default { plugins: [ pluginTailwindCSS({ - config: "./config/tailwind.config.js", + config: './config/tailwind.config.js', }), ], }; @@ -125,13 +125,13 @@ Include all `.js`, `.jsx`, `.ts`, `.tsx` files but exclude files in `./src/store ```js // rsbuild.config.ts -import { pluginTailwindCSS } from "@byted-lynx/plugin-tailwindcss"; +import { pluginTailwindCSS } from '@byted-lynx/plugin-tailwindcss'; export default { plugins: [ pluginTailwindCSS({ include: /\.[jt]sx?/, - exclude: ["./src/store/**", /[\\/]node_modules[\\/]/], + exclude: ['./src/store/**', /[\\/]node_modules[\\/]/], }), ], }; @@ -143,7 +143,7 @@ Note that `picomatch` patterns are very similar to [`minimatch`](https://github. Specifies the absolute path to the tailwindcss package. -By default, tailwindcss is resolved using Node.js module resolution algorithm starting from the root path. +By default, tailwindcss is resolved using Node.js module resolution algorithm starting from the root path. This option allows explicit specification of the tailwindcss package location for scenarios where automatic resolution fails or the resolved path is not correct, such as in monorepo. @@ -152,7 +152,7 @@ This option allows explicit specification of the tailwindcss package location fo ```js // rsbuild.config.ts -import { pluginTailwindCSS } from 'rsbuild-plugin-tailwindcss' +import { pluginTailwindCSS } from 'rsbuild-plugin-tailwindcss'; export default { plugins: [ diff --git a/biome.json b/biome.json deleted file mode 100644 index 348ebd5..0000000 --- a/biome.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", - "organizeImports": { - "enabled": true - }, - "vcs": { - "enabled": true, - "defaultBranch": "main", - "clientKind": "git", - "useIgnoreFile": true - }, - "formatter": { - "indentStyle": "space" - }, - "javascript": { - "formatter": { - "quoteStyle": "single" - } - }, - "css": { - "formatter": { - "enabled": true - } - }, - "linter": { - "enabled": true, - "rules": { - "recommended": true - } - } -} diff --git a/package.json b/package.json index 83b5fba..37c780d 100644 --- a/package.json +++ b/package.json @@ -14,28 +14,31 @@ "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", - "files": ["dist"], + "files": [ + "dist" + ], "scripts": { "build": "rslib build", "bump": "npx bumpp", "dev": "rslib build --watch", - "lint": "biome check .", - "lint:write": "biome check . --write", + "lint": "rslint && prettier -c .", + "lint:write": "rslint --fix && prettier -w .", "prepare": "simple-git-hooks && npm run build", "test": "playwright test --workers 1" }, "simple-git-hooks": { - "pre-commit": "npm run lint:write" + "pre-commit": "pnpm run lint:write" }, "devDependencies": { - "@biomejs/biome": "^1.9.4", "@playwright/test": "^1.59.1", "@rollup/pluginutils": "^5.3.0", "@rsbuild/core": "2.0.0", "@rslib/core": "^0.21.3", + "@rslint/core": "^0.5.0", "@types/node": "^22.19.17", "@types/semver": "^7.7.1", "postcss": "^8.5.10", + "prettier": "^3.8.3", "semver": "^7.7.4", "simple-git-hooks": "^2.13.1", "tailwindcss": "^3.4.19", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ce69b71..239f779 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,9 +10,6 @@ importers: .: devDependencies: - '@biomejs/biome': - specifier: ^1.9.4 - version: 1.9.4 '@playwright/test': specifier: ^1.59.1 version: 1.59.1 @@ -25,6 +22,9 @@ importers: '@rslib/core': specifier: ^0.21.3 version: 0.21.3(core-js@3.47.0)(typescript@5.9.3) + '@rslint/core': + specifier: ^0.5.0 + version: 0.5.0 '@types/node': specifier: ^22.19.17 version: 22.19.17 @@ -34,6 +34,9 @@ importers: postcss: specifier: ^8.5.10 version: 8.5.10 + prettier: + specifier: ^3.8.3 + version: 3.8.3 semver: specifier: ^7.7.4 version: 7.7.4 @@ -121,63 +124,6 @@ packages: resolution: {integrity: sha512-Hb4o6h1Pf6yRUAX07DR4JVY7dmQw+RVQMW5/m55GoiAT/VRoKCWBtIUPPOnqDVhbx1Cjfil9b6EDrgJsUAujEQ==} engines: {node: '>= 10'} - '@biomejs/biome@1.9.4': - resolution: {integrity: sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==} - engines: {node: '>=14.21.3'} - hasBin: true - - '@biomejs/cli-darwin-arm64@1.9.4': - resolution: {integrity: sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [darwin] - - '@biomejs/cli-darwin-x64@1.9.4': - resolution: {integrity: sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [darwin] - - '@biomejs/cli-linux-arm64-musl@1.9.4': - resolution: {integrity: sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [linux] - libc: [musl] - - '@biomejs/cli-linux-arm64@1.9.4': - resolution: {integrity: sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [linux] - libc: [glibc] - - '@biomejs/cli-linux-x64-musl@1.9.4': - resolution: {integrity: sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [linux] - libc: [musl] - - '@biomejs/cli-linux-x64@1.9.4': - resolution: {integrity: sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [linux] - libc: [glibc] - - '@biomejs/cli-win32-arm64@1.9.4': - resolution: {integrity: sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [win32] - - '@biomejs/cli-win32-x64@1.9.4': - resolution: {integrity: sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [win32] - '@emnapi/core@1.10.0': resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==} @@ -268,6 +214,45 @@ packages: typescript: optional: true + '@rslint/core@0.5.0': + resolution: {integrity: sha512-RkP/xqWx+Nvj7awvALIpbGnc5ECv8/AjPXqQDixhms4bu4dW5UbNNZ9XbrvJ4JoToUC/Ac5CrwW+nOj7JItSFQ==} + hasBin: true + peerDependencies: + jiti: ^2.0.0 + peerDependenciesMeta: + jiti: + optional: true + + '@rslint/darwin-arm64@0.5.0': + resolution: {integrity: sha512-AgsyJBnmXBuTnXAB5YUr6fhgfxvCl+iNRFlCjNN4WiClKEQyRLkU8KAmqVoZWOMyNszDUl9k/KT5P5KrBEJCJQ==} + cpu: [arm64] + os: [darwin] + + '@rslint/darwin-x64@0.5.0': + resolution: {integrity: sha512-4vxDu0DFzJVsGGxmmGmtSqKOPPfVcJvqxZP7XXDf9isFPg3L9jF+2DW3QL3KL7LO3Q+3zVG9eL+MQslMUf9NSw==} + cpu: [x64] + os: [darwin] + + '@rslint/linux-arm64@0.5.0': + resolution: {integrity: sha512-sNdDT7Omf6GttaJOql1915t/6txHlo0mEulLNhuDK4KVD9EnSltQ1uIDeqhNVvsKSnqIuTp3qCWmo1qYv5xKTA==} + cpu: [arm64] + os: [linux] + + '@rslint/linux-x64@0.5.0': + resolution: {integrity: sha512-Er/feorEUqOjee1ueE02fHIaPB1haxoGdh3uNqNrm3CUyrBp+Amjb8HL3MRzIYQuYoZWBAw9fU67YG8FxcWUsA==} + cpu: [x64] + os: [linux] + + '@rslint/win32-arm64@0.5.0': + resolution: {integrity: sha512-Y895KBuDVfoprZqr1BKX4YwP4kA2cqUuQr1B50+W8yjSRznyotNa09pRqUi+FrgJ5z6x07JjmW3Ggv8t5z9wwg==} + cpu: [arm64] + os: [win32] + + '@rslint/win32-x64@0.5.0': + resolution: {integrity: sha512-pTvCNr99DQg+22XQ5QkHySOLD4ap3wJ6yuwoW2r/4dW4MbmyDF9FfQGfhH1ZsQA3h20H8/3ANGdKuCbZnjkSrg==} + cpu: [x64] + os: [win32] + '@rspack/binding-darwin-arm64@2.0.0': resolution: {integrity: sha512-ICBHDKYyndFqljLhjxvKfWWZu39RJSH2jkSmbceXl0kmptLSE0cLWpvk+eGSzLqtxKN0jVchwCw+5P5mWCzwAw==} cpu: [arm64] @@ -590,6 +575,10 @@ packages: resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==} engines: {node: '>=12'} + picomatch@4.0.4: + resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==} + engines: {node: '>=12'} + pify@2.3.0: resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==} engines: {node: '>=0.10.0'} @@ -649,6 +638,11 @@ packages: resolution: {integrity: sha512-pMMHxBOZKFU6HgAZ4eyGnwXF/EvPGGqUr0MnZ5+99485wwW41kW91A4LOGxSHhgugZmSChL5AlElNdwlNgcnLQ==} engines: {node: ^10 || ^12 || >=14} + prettier@3.8.3: + resolution: {integrity: sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==} + engines: {node: '>=14'} + hasBin: true + queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} @@ -830,41 +824,6 @@ snapshots: '@ast-grep/napi-win32-ia32-msvc': 0.37.0 '@ast-grep/napi-win32-x64-msvc': 0.37.0 - '@biomejs/biome@1.9.4': - optionalDependencies: - '@biomejs/cli-darwin-arm64': 1.9.4 - '@biomejs/cli-darwin-x64': 1.9.4 - '@biomejs/cli-linux-arm64': 1.9.4 - '@biomejs/cli-linux-arm64-musl': 1.9.4 - '@biomejs/cli-linux-x64': 1.9.4 - '@biomejs/cli-linux-x64-musl': 1.9.4 - '@biomejs/cli-win32-arm64': 1.9.4 - '@biomejs/cli-win32-x64': 1.9.4 - - '@biomejs/cli-darwin-arm64@1.9.4': - optional: true - - '@biomejs/cli-darwin-x64@1.9.4': - optional: true - - '@biomejs/cli-linux-arm64-musl@1.9.4': - optional: true - - '@biomejs/cli-linux-arm64@1.9.4': - optional: true - - '@biomejs/cli-linux-x64-musl@1.9.4': - optional: true - - '@biomejs/cli-linux-x64@1.9.4': - optional: true - - '@biomejs/cli-win32-arm64@1.9.4': - optional: true - - '@biomejs/cli-win32-x64@1.9.4': - optional: true - '@emnapi/core@1.10.0': dependencies: '@emnapi/wasi-threads': 1.2.1 @@ -959,6 +918,35 @@ snapshots: - '@typescript/native-preview' - core-js + '@rslint/core@0.5.0': + dependencies: + picomatch: 4.0.4 + optionalDependencies: + '@rslint/darwin-arm64': 0.5.0 + '@rslint/darwin-x64': 0.5.0 + '@rslint/linux-arm64': 0.5.0 + '@rslint/linux-x64': 0.5.0 + '@rslint/win32-arm64': 0.5.0 + '@rslint/win32-x64': 0.5.0 + + '@rslint/darwin-arm64@0.5.0': + optional: true + + '@rslint/darwin-x64@0.5.0': + optional: true + + '@rslint/linux-arm64@0.5.0': + optional: true + + '@rslint/linux-x64@0.5.0': + optional: true + + '@rslint/win32-arm64@0.5.0': + optional: true + + '@rslint/win32-x64@0.5.0': + optional: true + '@rspack/binding-darwin-arm64@2.0.0': optional: true @@ -1233,6 +1221,8 @@ snapshots: picomatch@4.0.2: {} + picomatch@4.0.4: {} + pify@2.3.0: {} pirates@4.0.6: {} @@ -1282,6 +1272,8 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 + prettier@3.8.3: {} + queue-microtask@1.2.3: {} read-cache@1.0.0: diff --git a/rslint.config.ts b/rslint.config.ts new file mode 100644 index 0000000..5055b09 --- /dev/null +++ b/rslint.config.ts @@ -0,0 +1,3 @@ +import { defineConfig, ts } from '@rslint/core'; + +export default defineConfig([ts.configs.recommended]); diff --git a/src/TailwindCSSRspackPlugin.ts b/src/TailwindCSSRspackPlugin.ts index 6bd7512..6bcc2e0 100644 --- a/src/TailwindCSSRspackPlugin.ts +++ b/src/TailwindCSSRspackPlugin.ts @@ -394,9 +394,8 @@ class TailwindRspackPluginImpl { ): Promise<['tailwind.config.mjs' | 'tailwind.config.cjs', string]> { const version = await this.#resolveTailwindCSSVersion(tailwindcssPath); - const { default: satisfies } = await import( - 'semver/functions/satisfies.js' - ); + const { default: satisfies } = + await import('semver/functions/satisfies.js'); const content = JSON.stringify(entryModules); if (satisfies(version, '^3.3.0')) {