From 5aead9a94388f459a305976e05439d35d1c5cb46 Mon Sep 17 00:00:00 2001 From: Geoff Date: Fri, 26 Jul 2024 23:17:16 -0400 Subject: [PATCH 1/2] Switch from Prettier & ESLint to BiomeJS --- .eslintrc | 88 ---------------------------------------- .github/workflows/ci.yml | 2 +- .prettierignore | 2 - .prettierrc | 5 --- biome.json | 46 +++++++++++++++++++++ package.json | 17 ++++---- 6 files changed, 54 insertions(+), 106 deletions(-) delete mode 100644 .eslintrc delete mode 100644 .prettierignore delete mode 100644 .prettierrc create mode 100644 biome.json diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 6635d412..00000000 --- a/.eslintrc +++ /dev/null @@ -1,88 +0,0 @@ -{ - "extends": ["prettier"], - "plugins": ["@typescript-eslint", "prettier/recommended"], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "sourceType": "module", - "ecmaVersion": 2020, - "ecmaFeatures": { - "jsx": true - } - }, - "env": { - "browser": true, - "es6": true, - "mocha": true, - "node": true - }, - "rules": { - "@typescript-eslint/no-unused-vars": [ - "error", - { "vars": "all", "args": "none" } - ], - "constructor-super": "error", - "dot-notation": ["error", { "allowKeywords": true }], - "eqeqeq": ["error", "smart"], - "linebreak-style": "error", - "new-parens": "error", - "no-array-constructor": "error", - "no-class-assign": "error", - "no-console": "error", - "no-const-assign": "error", - "no-debugger": "error", - "no-dupe-args": "error", - "no-dupe-class-members": "error", - "no-dupe-keys": "error", - "no-duplicate-case": "error", - "no-empty": "error", - "no-empty-character-class": "error", - "no-empty-pattern": "error", - "no-ex-assign": "error", - "no-extend-native": "error", - "no-extra-boolean-cast": "error", - "no-func-assign": "error", - "no-invalid-regexp": "error", - "no-lonely-if": "error", - "no-native-reassign": "error", - "no-negated-in-lhs": "error", - "no-new-object": "error", - "no-new-symbol": "error", - "no-path-concat": "error", - "no-redeclare": "error", - "no-regex-spaces": "error", - "no-sequences": "error", - "no-shadow": "error", - "no-shadow-restricted-names": "error", - "no-tabs": "error", - "no-this-before-super": "error", - "no-throw-literal": "error", - "no-unneeded-ternary": "error", - "no-unreachable": "error", - "no-unsafe-finally": "error", - "no-unsafe-negation": "error", - "no-unused-expressions": "error", - "no-unused-vars": "off", - "no-useless-call": "error", - "no-useless-computed-key": "error", - "no-useless-constructor": "error", - "no-useless-rename": "error", - "no-var": "error", - "no-void": "error", - "no-with": "error", - "object-shorthand": ["error", "always"], - "prefer-arrow-callback": "error", - "prefer-const": [ - "error", - { "destructuring": "all", "ignoreReadBeforeAssign": true } - ], - "prefer-rest-params": "error", - "prefer-spread": "error", - "prefer-template": "error", - "radix": "error", - "spaced-comment": ["error", "always", { "exceptions": ["-"] }], - "use-isnan": "error", - "valid-typeof": "error", - "yield-star-spacing": ["error", "after"], - "yoda": ["error", "never"] - } -} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 473cb0c9..8831ac59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,6 @@ jobs: - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - - run: npm install && npm test && npm run lint + - run: npm install && npm test && npm run check env: CI: true diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 1eae0cf6..00000000 --- a/.prettierignore +++ /dev/null @@ -1,2 +0,0 @@ -dist/ -node_modules/ diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 0b495108..00000000 --- a/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "singleQuote": true, - "semi": false, - "trailingComma": "es5" -} diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..fb4f3582 --- /dev/null +++ b/biome.json @@ -0,0 +1,46 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", + "files": { + "include": ["src/**/*.ts", "test/**/*.ts"] + }, + "organizeImports": { + "enabled": false + }, + "formatter": { + "enabled": true, + "indentStyle": "space" + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "complexity": { + "noUselessTypeConstraint": "off", + "noBannedTypes": "off", + "useArrowFunction": "off" + }, + "suspicious": { + "noAssignInExpressions": "off", + "noExplicitAny": "off", + "noGlobalIsNan": "off", + "noImplicitAnyLet": "off" + }, + "style": { + "noParameterAssign": "off", + "useNumberNamespace": "off", + "noNonNullAssertion": "off", + "noUselessElse": "off", + "useImportType": "off", + "useConst": "off", + "useNodejsImportProtocol": "off" + } + } + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "semicolons": "asNeeded", + "trailingCommas": "es5" + } + } +} diff --git a/package.json b/package.json index 5b6afed1..f0dc47fe 100644 --- a/package.json +++ b/package.json @@ -19,18 +19,15 @@ "node": ">=14.0.0" }, "devDependencies": { + "@biomejs/biome": "1.8.3", "@rollup/plugin-typescript": "^11.1.6", "@types/expect": "^24.3.0", "@types/lodash": "^4.14.144", "@types/node": "^18.7.14", "@typescript-eslint/eslint-plugin": "^7.1.1", "@typescript-eslint/parser": "^7.1.1", - "eslint": "^8.57.0", - "eslint-config-prettier": "^9.1.0", - "eslint-plugin-prettier": "^5.1.3", "lodash": "^4.17.15", "np": "^10.0.0", - "prettier": "^3.2.5", "rollup": "^4.12.1", "typescript": "^4.8.3", "vitest": "^1.6.0" @@ -38,12 +35,12 @@ "scripts": { "build": "rm -rf ./{dist} && rollup --config ./rollup.config.js", "clean": "rm -rf ./{dist,node_modules}", - "fix": "npm run fix:eslint && npm run fix:prettier", - "fix:eslint": "npm run lint:eslint --fix", - "fix:prettier": "prettier '**/*.{js,json,ts}' --write", - "lint": "npm run lint:eslint && npm run lint:prettier", - "lint:eslint": "eslint '{src,test}/*.{js,ts}'", - "lint:prettier": "prettier '**/*.{js,json,ts}' --check", + "fix": "npx @biomejs/biome check --write .", + "fix:lint": "npx @biomejs/biome lint --write .", + "fix:format": "npx @biomejs/biome format --write .", + "check": "npx @biomejs/biome check .", + "check:lint": "npx @biomejs/biome lint .", + "check:format": "npx @biomejs/biome format .", "release": "npm run build && npm run lint && np", "test": "npm run build && npm run test:types && npm run test:vitest", "test:types": "tsc --noEmit && tsc --project ./test/tsconfig.json --noEmit", From 8ae65f2aab3dd5c613d8f474ccd32cb39d6a96cb Mon Sep 17 00:00:00 2001 From: Geoff Date: Fri, 26 Jul 2024 23:17:28 -0400 Subject: [PATCH 2/2] `npm run fix` --- src/utils.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 5c05d1e1..412a1ba4 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -200,7 +200,9 @@ export function* run( */ export type UnionToIntersection = ( - U extends any ? (arg: U) => any : never + U extends any + ? (arg: U) => any + : never ) extends (arg: infer I) => void ? I : never @@ -230,10 +232,11 @@ export type IsMatch = T extends G ? (G extends T ? T : never) : never * Check if a type is an exact match. */ -export type IsExactMatch = - (() => G extends T ? 1 : 2) extends () => G extends U ? 1 : 2 - ? T - : never +export type IsExactMatch = (() => G extends T ? 1 : 2) extends < + G, +>() => G extends U ? 1 : 2 + ? T + : never /** * Check if a type is a record type. @@ -265,7 +268,11 @@ export type IsTuple = T extends [any] */ export type IsUnion = ( - T extends any ? (U extends T ? false : true) : false + T extends any + ? U extends T + ? false + : true + : false ) extends false ? never : T