From fe4db278c8330892da217c475e7c122ee9fdb9e1 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 28 Apr 2026 19:04:58 +0800 Subject: [PATCH] chore: migrate linting to rslint and prettier --- .gitignore | 1 + .prettierignore | 3 + .prettierrc | 3 + .vscode/extensions.json | 3 + .vscode/settings.json | 4 + README.md | 28 ++--- biome.json | 29 ------ package.json | 31 +++--- pnpm-lock.yaml | 223 ++++++++++++++++++++-------------------- rslint.config.ts | 10 ++ src/matchers.ts | 12 ++- src/normalize.ts | 5 +- src/utils.ts | 9 +- 13 files changed, 185 insertions(+), 176 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json delete mode 100644 biome.json create mode 100644 rslint.config.ts diff --git a/.gitignore b/.gitignore index 0ef14fe..ccb527e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ dist/ # IDE .vscode/* !.vscode/extensions.json +!.vscode/settings.json .idea 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 new file mode 100644 index 0000000..f172f18 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["rstack.rslint", "esbenp.prettier-vscode"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..770e0e6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "search.useIgnoreFiles": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" +} diff --git a/README.md b/README.md index f03b1f7..f45bdd9 100644 --- a/README.md +++ b/README.md @@ -142,20 +142,20 @@ Transform the final string after all replacements. Toggle individual features (all enabled by default): -| Feature | Default | Description | -|---|---|---| -| `replaceWorkspace` | `true` | `/foo/packages/core/src` → `/src` | -| `replaceRoot` | `true` | `/foo/node_modules/.pnpm` → `/node_modules/.pnpm` | -| `replaceWorkspaceWithFileProtocol` | `true` | `file:///foo/packages/core/src` → `/src` | -| `replaceRootWithFileProtocol` | `true` | `file:///foo/node_modules/.pnpm` → `/node_modules/.pnpm` | -| `replacePnpmInner` | `true` | Collapse pnpm's long `.pnpm/...` and global virtual store `pnpm/store/.../links/...` paths to `` | -| `replaceTmpDir` | `true` | `os.tmpdir()` paths → `` | -| `replaceHomeDir` | `true` | `os.homedir()` paths → `` | -| `transformWin32Path` | `true` | Convert `D:\\foo\\bar` to `/d/foo/bar` | -| `transformCLR` | `true` | Normalize ANSI color escape codes | -| `escapeDoubleQuotes` | `true` | Escape `"` to `\"` | -| `escapeEOL` | `true` | Normalize `\r\n` to `\n` | -| `addDoubleQuotes` | `true` | Wrap output in double quotes | +| Feature | Default | Description | +| ---------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------ | +| `replaceWorkspace` | `true` | `/foo/packages/core/src` → `/src` | +| `replaceRoot` | `true` | `/foo/node_modules/.pnpm` → `/node_modules/.pnpm` | +| `replaceWorkspaceWithFileProtocol` | `true` | `file:///foo/packages/core/src` → `/src` | +| `replaceRootWithFileProtocol` | `true` | `file:///foo/node_modules/.pnpm` → `/node_modules/.pnpm` | +| `replacePnpmInner` | `true` | Collapse pnpm's long `.pnpm/...` and global virtual store `pnpm/store/.../links/...` paths to `` | +| `replaceTmpDir` | `true` | `os.tmpdir()` paths → `` | +| `replaceHomeDir` | `true` | `os.homedir()` paths → `` | +| `transformWin32Path` | `true` | Convert `D:\\foo\\bar` to `/d/foo/bar` | +| `transformCLR` | `true` | Normalize ANSI color escape codes | +| `escapeDoubleQuotes` | `true` | Escape `"` to `\"` | +| `escapeEOL` | `true` | Normalize `\r\n` to `\n` | +| `addDoubleQuotes` | `true` | Wrap output in double quotes | More details can be found in [./src/types.ts](https://github.com/rspack-contrib/path-serializer/blob/main/src/types.ts). diff --git a/biome.json b/biome.json deleted file mode 100644 index dbfb388..0000000 --- a/biome.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "$schema": "https://biomejs.dev/schemas/1.8.0/schema.json", - "organizeImports": { - "enabled": true - }, - "vcs": { - "enabled": true, - "clientKind": "git", - "useIgnoreFile": true - }, - "formatter": { - "indentStyle": "space" - }, - "javascript": { - "formatter": { - "quoteStyle": "single" - } - }, - "linter": { - "enabled": true, - "rules": { - "recommended": true, - "suspicious": { - "noExplicitAny": "off" - } - }, - "ignore": ["./src/upath.mjs"] - } -} diff --git a/package.json b/package.json index c6114dd..8a62a46 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,14 @@ "version": "0.6.0", "type": "module", "description": "path-serializer", - "keywords": ["snapshot", "rstest", "vitest", "jest", "ci", "test"], + "keywords": [ + "snapshot", + "rstest", + "vitest", + "jest", + "ci", + "test" + ], "repository": { "type": "git", "url": "git+https://github.com/rstackjs/path-serializer.git" @@ -21,25 +28,30 @@ "main": "./dist/cjs/index.cjs", "module": "./dist/esm/index.js", "types": "./dist/esm/index.d.ts", - "files": ["dist", "README.md", "LICENSE"], + "files": [ + "dist", + "README.md", + "LICENSE" + ], "scripts": { "build": "rslib build", "dev": "rslib build --watch", - "lint": "biome check --write", - "prepare": "pnpm run build && simple-git-hooks", + "lint": "rslint && prettier -c .", + "lint:write": "rslint --fix && prettier -w .", + "prepare": "simple-git-hooks && pnpm run build", "test:watch": "rstest --watch", "test": "rstest", "prepublish": "pnpm run build", "bump": "npx bumpp" }, "simple-git-hooks": { - "pre-commit": "npx nano-staged" + "pre-commit": "pnpm run lint:write" }, "devDependencies": { "rsbuild-plugin-publint": "^0.3.4", - "@biomejs/biome": "^1.9.4", "@microsoft/api-extractor": "^7.48.0", "@rslib/core": "0.18.6", + "@rslint/core": "^0.5.0", "@rstest/adapter-rslib": "0.2.1", "@rstest/core": "0.9.2", "@types/lodash-es": "^4.17.12", @@ -47,7 +59,7 @@ "execa": "9.5.1", "fs-extra": "11.2.0", "lodash-es": "^4.17.21", - "nano-staged": "^0.8.0", + "prettier": "^3.8.3", "semver": "7.6.3", "simple-git-hooks": "^2.11.1", "slash": "5.1.0", @@ -58,10 +70,5 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" - }, - "nano-staged": { - "*.{js,jsx,ts,tsx,mjs,cjs,json}": [ - "biome check --write --no-errors-on-unmatched" - ] } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4251405..416291b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,15 +8,15 @@ importers: .: devDependencies: - '@biomejs/biome': - specifier: ^1.9.4 - version: 1.9.4 '@microsoft/api-extractor': specifier: ^7.48.0 version: 7.48.0(@types/node@22.10.1) '@rslib/core': specifier: 0.18.6 version: 0.18.6(@microsoft/api-extractor@7.48.0(@types/node@22.10.1))(typescript@5.7.2) + '@rslint/core': + specifier: ^0.5.0 + version: 0.5.1(jiti@2.6.1) '@rstest/adapter-rslib': specifier: 0.2.1 version: 0.2.1(@rslib/core@0.18.6(@microsoft/api-extractor@7.48.0(@types/node@22.10.1))(typescript@5.7.2))(@rstest/core@0.9.2(core-js@3.47.0))(typescript@5.7.2) @@ -38,9 +38,9 @@ importers: lodash-es: specifier: ^4.17.21 version: 4.17.21 - nano-staged: - specifier: ^0.8.0 - version: 0.8.0 + prettier: + specifier: ^3.8.3 + version: 3.8.3 rsbuild-plugin-publint: specifier: ^0.3.4 version: 0.3.4(@rsbuild/core@1.7.3) @@ -124,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.9.0': resolution: {integrity: sha512-0DQ98G9ZQZOxfUcQn1waV2yS8aWdZ6kJMbYCJB3oUBecjWYO1fqJ+a1DRfPF3O5JEkwqwP1A9QEN/9mYm2Yd0w==} @@ -256,6 +199,45 @@ packages: typescript: optional: true + '@rslint/core@0.5.1': + resolution: {integrity: sha512-UGcalhkpNvm4zN7E2DiQsuwM10LMi3CazOiANVevf5hn+NB7WKEMWYKn3bFySptg7Ll042IKMUlIXaFQjWs9lQ==} + hasBin: true + peerDependencies: + jiti: ^2.0.0 + peerDependenciesMeta: + jiti: + optional: true + + '@rslint/darwin-arm64@0.5.1': + resolution: {integrity: sha512-grbPKhrRv0BTKvdByIIlS5avc4ttF9vylaStJh/TTYS96cTkjCcTv7RAUv/ZI3VSaSZdRBcW4f6wW9pPWpt41w==} + cpu: [arm64] + os: [darwin] + + '@rslint/darwin-x64@0.5.1': + resolution: {integrity: sha512-v7P5AYWzm4Xrly5nl5yXSAyHn6j9pwZyFFUTD9UCOodZMEVmBxW3WxdL9iq8PfnG5n8GXHqTqBSYwWfG1WWD0g==} + cpu: [x64] + os: [darwin] + + '@rslint/linux-arm64@0.5.1': + resolution: {integrity: sha512-czDNVvgea0LpTlqaRvZHulJn8RmmDso2DufIWedxIA9yfK+nEK4H0tANNVQL4NBTHiv/6cqQw8NveP3KD5I93g==} + cpu: [arm64] + os: [linux] + + '@rslint/linux-x64@0.5.1': + resolution: {integrity: sha512-D0isbtok26OSjSQkWDDfTWPLQDqrufbTbiihMFxkDlIRKDGcU9HvnfTlEmgnwzkxt6Jm7CBZZiXdFtyhPgnWEg==} + cpu: [x64] + os: [linux] + + '@rslint/win32-arm64@0.5.1': + resolution: {integrity: sha512-XnU369fuTR9EqFhRMmbg+rHO3T/gwC+VV2AC1HAvZ62/pgNjFQmlK6IEsU293sgXHOUnRIQ6IsC9J0imyrCMXQ==} + cpu: [arm64] + os: [win32] + + '@rslint/win32-x64@0.5.1': + resolution: {integrity: sha512-7++ELodvfVPFDSYEMVWb7OA+BD2JeONXtwXP/vmbrcawBTff7E/6VREB8dGPYCNh/ypBuSQ2WYXUtYAxQxwSiQ==} + cpu: [x64] + os: [win32] + '@rspack/binding-darwin-arm64@1.7.9': resolution: {integrity: sha512-64dgstte0If5czi9bA/cpOe0ryY6wC9AIQRtyJ3DlOF6Tt+y9cKkmUoGu3V+WYaYIZRT7HNk8V7kL8amVjFTYw==} cpu: [arm64] @@ -520,6 +502,15 @@ packages: fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + figures@6.1.0: resolution: {integrity: sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg==} engines: {node: '>=18'} @@ -610,11 +601,6 @@ packages: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} engines: {node: '>=4'} - nano-staged@0.8.0: - resolution: {integrity: sha512-QSEqPGTCJbkHU2yLvfY6huqYPjdBrOaTMKatO1F8nCSrkQGXeKwtCiCnsdxnuMhbg3DTVywKaeWLGCE5oJpq0g==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - hasBin: true - npm-run-path@6.0.0: resolution: {integrity: sha512-9qny7Z9DsQU8Ou39ERsPU4OZQlSTP47ShQzuKZ6PRXpYLtIFgl/DEBYEXKlvcEa+9tHVcK8CF81Y2V72qaZhWA==} engines: {node: '>=18'} @@ -637,12 +623,18 @@ packages: path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} - picocolors@1.0.1: - resolution: {integrity: sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==} - picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + picomatch@4.0.4: + resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==} + engines: {node: '>=12'} + + prettier@3.8.3: + resolution: {integrity: sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==} + engines: {node: '>=14'} + hasBin: true + pretty-ms@9.1.0: resolution: {integrity: sha512-o1piW0n3tgKIKCwk2vpM/vOV13zjJzvP37Ioze54YlTHE06m4tjEbzg9WsKkvTuyYln2DHjo5pY4qrZGI0otpw==} engines: {node: '>=18'} @@ -749,6 +741,10 @@ packages: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} + tinyglobby@0.2.15: + resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} + engines: {node: '>=12.0.0'} + tinypool@2.1.0: resolution: {integrity: sha512-Pugqs6M0m7Lv1I7FtxN4aoyToKg1C4tu+/381vH35y8oENM/Ai7f7C4StcoK4/+BSw9ebcS8jRiVrORFKCALLw==} engines: {node: ^20.0.0 || >=22.0.0} @@ -841,41 +837,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.9.0': dependencies: '@emnapi/wasi-threads': 1.2.0 @@ -988,6 +949,37 @@ snapshots: transitivePeerDependencies: - '@typescript/native-preview' + '@rslint/core@0.5.1(jiti@2.6.1)': + dependencies: + picomatch: 4.0.4 + tinyglobby: 0.2.15 + optionalDependencies: + '@rslint/darwin-arm64': 0.5.1 + '@rslint/darwin-x64': 0.5.1 + '@rslint/linux-arm64': 0.5.1 + '@rslint/linux-x64': 0.5.1 + '@rslint/win32-arm64': 0.5.1 + '@rslint/win32-x64': 0.5.1 + jiti: 2.6.1 + + '@rslint/darwin-arm64@0.5.1': + optional: true + + '@rslint/darwin-x64@0.5.1': + optional: true + + '@rslint/linux-arm64@0.5.1': + optional: true + + '@rslint/linux-x64@0.5.1': + optional: true + + '@rslint/win32-arm64@0.5.1': + optional: true + + '@rslint/win32-x64@0.5.1': + optional: true + '@rspack/binding-darwin-arm64@1.7.9': optional: true @@ -1238,6 +1230,10 @@ snapshots: fast-deep-equal@3.1.3: {} + fdir@6.5.0(picomatch@4.0.4): + optionalDependencies: + picomatch: 4.0.4 + figures@6.1.0: dependencies: is-unicode-supported: 2.1.0 @@ -1315,10 +1311,6 @@ snapshots: mri@1.2.0: {} - nano-staged@0.8.0: - dependencies: - picocolors: 1.0.1 - npm-run-path@6.0.0: dependencies: path-key: 4.0.0 @@ -1334,10 +1326,12 @@ snapshots: path-parse@1.0.7: {} - picocolors@1.0.1: {} - picocolors@1.1.1: {} + picomatch@4.0.4: {} + + prettier@3.8.3: {} + pretty-ms@9.1.0: dependencies: parse-ms: 4.0.0 @@ -1412,6 +1406,11 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} + tinyglobby@0.2.15: + dependencies: + fdir: 6.5.0(picomatch@4.0.4) + picomatch: 4.0.4 + tinypool@2.1.0: {} tslib@2.8.1: {} diff --git a/rslint.config.ts b/rslint.config.ts new file mode 100644 index 0000000..879395e --- /dev/null +++ b/rslint.config.ts @@ -0,0 +1,10 @@ +import { defineConfig, ts } from '@rslint/core'; + +export default defineConfig([ + ts.configs.recommended, + { + rules: { + '@typescript-eslint/no-explicit-any': 'off', + }, + }, +]); diff --git a/src/matchers.ts b/src/matchers.ts index 38022d6..ff79977 100644 --- a/src/matchers.ts +++ b/src/matchers.ts @@ -5,16 +5,22 @@ import { getRealTemporaryDirectory } from './utils'; export const createTmpDirMatchers = (): PathMatcher[] => { const ret: PathMatcher[] = []; const realTmpDir = getRealTemporaryDirectory(); - realTmpDir && ret.push({ match: realTmpDir, mark: 'temp' }); + if (realTmpDir) { + ret.push({ match: realTmpDir, mark: 'temp' }); + } const tmpDir = os.tmpdir(); - tmpDir && ret.push({ match: tmpDir, mark: 'temp' }); + if (tmpDir) { + ret.push({ match: tmpDir, mark: 'temp' }); + } return ret; }; export const createHomeDirMatchers = (): PathMatcher[] => { const ret: PathMatcher[] = []; const homedir = os.homedir(); - homedir && ret.push({ match: homedir, mark: 'home' }); + if (homedir) { + ret.push({ match: homedir, mark: 'home' }); + } return ret; }; diff --git a/src/normalize.ts b/src/normalize.ts index 63739d6..c32e66b 100644 --- a/src/normalize.ts +++ b/src/normalize.ts @@ -4,7 +4,10 @@ import upath from 'upath'; export const normalizePathToPosix = (p: string | undefined): string => { return upath .normalizeSafe(path.normalize(p || '')) - .replace(/^([a-zA-Z]+):/, (_: any, m: string) => `/${m.toLowerCase()}`); + .replace( + /^([a-zA-Z]+):/, + (_match: string, m: string) => `/${m.toLowerCase()}`, + ); }; // find the path in code and replace it with normalizePathToPosix diff --git a/src/utils.ts b/src/utils.ts index 66fac22..a312bec 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,12 +3,11 @@ import os from 'node:os'; import { escapeRegExp } from 'lodash-es'; export function getRealTemporaryDirectory(): string | null { - let ret: string | null = null; try { - ret = os.tmpdir(); - ret = fs.realpathSync(ret); - } catch {} - return ret; + return fs.realpathSync(os.tmpdir()); + } catch { + return null; + } } /**