From 95963ac345d27cd06a4eeb5ebc16e1848cb2fd81 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 27 Mar 2024 13:02:34 +0100 Subject: [PATCH 1/7] chore: update typegen --- package.json | 2 +- pnpm-lock.yaml | 14 +++++--------- scripts/typegen.ts | 39 +++++---------------------------------- src/types.ts | 6 +++--- 4 files changed, 14 insertions(+), 47 deletions(-) diff --git a/package.json b/package.json index f8ee8154fc..246aa6e4d0 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,7 @@ "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.6", "eslint-plugin-svelte": "2.36.0-next.13", - "eslint-typegen": "^0.0.2", + "eslint-typegen": "^0.1.0", "esno": "^4.7.0", "execa": "^8.0.1", "fast-glob": "^3.3.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fef317e02a..8d811f0951 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -169,8 +169,8 @@ importers: specifier: 2.36.0-next.13 version: 2.36.0-next.13(eslint@9.0.0-rc.0)(svelte@4.2.12) eslint-typegen: - specifier: ^0.0.2 - version: 0.0.2 + specifier: ^0.1.0 + version: 0.1.0 esno: specifier: ^4.7.0 version: 4.7.0 @@ -2767,12 +2767,12 @@ packages: esrecurse: 4.3.0 estraverse: 5.3.0 - /eslint-typegen@0.0.2: - resolution: {integrity: sha512-/kmNPeWpWASqik/lsg+5FaX25Imz8xvevo0ChR6itAeJMQmQCrnrUoYcbmaiK0MFqlIhMYREReX4nUpVHceXmA==} + /eslint-typegen@0.1.0: + resolution: {integrity: sha512-ho0gUzQXXQHkuXlpKGrzROFsRdNM2H9KLhwmlrltBFZYRhm7jke8RYzAVhSLL2ulrEar1cqJNNkTiTRRkjyRqA==} dependencies: '@types/eslint': 8.56.6 - json-schema: 0.4.0 json-schema-to-typescript: 13.1.2 + ohash: 1.1.3 dev: true /eslint-visitor-keys@3.4.3: @@ -3673,10 +3673,6 @@ packages: /json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} - /json-schema@0.4.0: - resolution: {integrity: sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==} - dev: true - /json-stable-stringify-without-jsonify@1.0.1: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} diff --git a/scripts/typegen.ts b/scripts/typegen.ts index 875c505f9c..5fd3fc430c 100644 --- a/scripts/typegen.ts +++ b/scripts/typegen.ts @@ -1,32 +1,6 @@ import fs from 'node:fs/promises' -import { pluginsToRulesOptions } from 'eslint-typegen' -import type { ESLint } from 'eslint' -import { - astro, - combine, - comments, - formatters, - imports, - javascript, - jsdoc, - jsonc, - markdown, - node, - perfectionist, - react, - sortPackageJson, - stylistic, - svelte, - test, - toml, - typescript, - unicorn, - unocss, - vue, - yaml, -} from '../src' - -const plugins: Record = {} +import { flatConfigsToRulesDTS } from 'eslint-typegen/core' +import { astro, combine, comments, formatters, imports, javascript, jsdoc, jsonc, markdown, node, perfectionist, react, sortPackageJson, stylistic, svelte, test, toml, typescript, unicorn, unocss, vue, yaml } from '../src' const configs = await combine( astro(), @@ -52,11 +26,8 @@ const configs = await combine( yaml(), ) -for (const config of configs) - Object.assign(plugins, config.plugins) - -console.log(Object.keys(plugins)) - -const dts = await pluginsToRulesOptions(plugins) +const dts = await flatConfigsToRulesDTS(configs, { + includeAugmentation: false, +}) await fs.writeFile('src/typegen.d.ts', dts) diff --git a/src/types.ts b/src/types.ts index beef29167a..ac6b227188 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,11 +4,11 @@ import type { Options as VueBlocksOptions } from 'eslint-processor-vue-blocks' import type { Linter } from 'eslint' import type { StylisticCustomizeOptions } from '@stylistic/eslint-plugin' import type { VendoredPrettierOptions } from './vender/prettier-types' -import type { RulesOptions } from './typegen' +import type { RuleOptions } from './typegen' export type Awaitable = T | Promise -export type Rules = RulesOptions +export type Rules = RuleOptions export type FlatConfigItem = Omit & { /** @@ -29,7 +29,7 @@ export type FlatConfigItem = Omit & { */ rules?: { [key: string]: Linter.RuleEntry - } & RulesOptions + } & Rules } export interface OptionsFiles { From 445aae211af737dc4f79b213313c3603c50ee970 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 27 Mar 2024 14:01:20 +0100 Subject: [PATCH 2/7] feat: improve types --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 246aa6e4d0..80e15de92e 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,7 @@ "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.6", "eslint-plugin-svelte": "2.36.0-next.13", - "eslint-typegen": "^0.1.0", + "eslint-typegen": "^0.1.3", "esno": "^4.7.0", "execa": "^8.0.1", "fast-glob": "^3.3.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8d811f0951..bab1b29074 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -169,8 +169,8 @@ importers: specifier: 2.36.0-next.13 version: 2.36.0-next.13(eslint@9.0.0-rc.0)(svelte@4.2.12) eslint-typegen: - specifier: ^0.1.0 - version: 0.1.0 + specifier: ^0.1.3 + version: 0.1.3 esno: specifier: ^4.7.0 version: 4.7.0 @@ -2767,8 +2767,8 @@ packages: esrecurse: 4.3.0 estraverse: 5.3.0 - /eslint-typegen@0.1.0: - resolution: {integrity: sha512-ho0gUzQXXQHkuXlpKGrzROFsRdNM2H9KLhwmlrltBFZYRhm7jke8RYzAVhSLL2ulrEar1cqJNNkTiTRRkjyRqA==} + /eslint-typegen@0.1.3: + resolution: {integrity: sha512-ry+4sLT/HyhjcBQMcCwir1/luU08EcPKir5cH6W4AFq9YmaIlHJPA61gISAmTSV6/yXnNDJwcBtpSCGVMG74bw==} dependencies: '@types/eslint': 8.56.6 json-schema-to-typescript: 13.1.2 From 3074a85097e7b5db620669e1203713484f3c8ae4 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 27 Mar 2024 14:01:24 +0100 Subject: [PATCH 3/7] chore: release v2.11.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 80e15de92e..95772f3819 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@antfu/eslint-config", "type": "module", - "version": "2.11.0", + "version": "2.11.1", "packageManager": "pnpm@8.15.5", "description": "Anthony's ESLint config", "author": "Anthony Fu (https://github.com/antfu/)", From 4d42710c2bf0033d5f5224ecaa4903b10ebe7387 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Thu, 28 Mar 2024 00:49:26 +0100 Subject: [PATCH 4/7] chore: improve types --- package.json | 2 +- pnpm-lock.yaml | 217 ++++++------------------------------------------- 2 files changed, 25 insertions(+), 194 deletions(-) diff --git a/package.json b/package.json index 95772f3819..34f5a9165b 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,7 @@ "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.6", "eslint-plugin-svelte": "2.36.0-next.13", - "eslint-typegen": "^0.1.3", + "eslint-typegen": "^0.1.4", "esno": "^4.7.0", "execa": "^8.0.1", "fast-glob": "^3.3.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bab1b29074..4b987207ea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -169,8 +169,8 @@ importers: specifier: 2.36.0-next.13 version: 2.36.0-next.13(eslint@9.0.0-rc.0)(svelte@4.2.12) eslint-typegen: - specifier: ^0.1.3 - version: 0.1.3 + specifier: ^0.1.4 + version: 0.1.4 esno: specifier: ^4.7.0 version: 4.7.0 @@ -266,6 +266,15 @@ packages: resolution: {integrity: sha512-pvFiLP2BeOKA/ZOS6jxx4XhKzdVLHDhGlFEaZ2flWWYf2xOqVniqpk38I04DFRyz+L0ASggl7SkItTc+ZLju4w==} dev: true + /@apidevtools/json-schema-ref-parser@11.5.4: + resolution: {integrity: sha512-o2fsypTGU0WxRxbax8zQoHiIB4dyrkwYfcm8TxZ+bx9pCzcWZbQtiMqpgBvWA/nJ2TrGjK5adCLfTH8wUeU/Wg==} + engines: {node: '>= 16'} + dependencies: + '@jsdevtools/ono': 7.1.3 + '@types/json-schema': 7.0.15 + js-yaml: 4.1.0 + dev: true + /@astrojs/compiler@1.8.2: resolution: {integrity: sha512-o/ObKgtMzl8SlpIdzaxFnt7SATKPxu4oIP/1NL+HDJRzxfJcAkOTAb/ZKMRyULbz4q+1t2/DAebs2Z1QairkZw==} dev: true @@ -314,16 +323,6 @@ packages: '@babel/helper-validator-identifier': 7.22.20 to-fast-properties: 2.0.0 - /@bcherny/json-schema-ref-parser@10.0.5-fork: - resolution: {integrity: sha512-E/jKbPoca1tfUPj3iSbitDZTGnq6FUFjkH6L8U2oDwSuwK1WhnnVtCG7oFOTg/DDnyoXbQYUiUiGOibHqaGVnw==} - engines: {node: '>= 16'} - dependencies: - '@jsdevtools/ono': 7.1.3 - '@types/json-schema': 7.0.14 - call-me-maybe: 1.0.2 - js-yaml: 4.1.0 - dev: true - /@clack/core@0.3.4: resolution: {integrity: sha512-H4hxZDXgHtWTwV3RAVenqcC4VbJZNegbBjlPvzOzCouXtS2y3sDvlO3IsbrPNWuLWPPlYVYPghQdSF64683Ldw==} dependencies: @@ -903,36 +902,25 @@ packages: '@types/node': 20.11.30 dev: true - /@types/glob@7.2.0: - resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} - dependencies: - '@types/minimatch': 5.1.2 - '@types/node': 20.11.30 - dev: true - /@types/json-schema@7.0.14: resolution: {integrity: sha512-U3PUjAudAdJBeC2pgN8uTIKgxrb4nlDF3SF0++EldXQvQBGkpFZMSnwQiIoDU77tv45VgNkl/L4ouD+rEomujw==} + /@types/json-schema@7.0.15: + resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + dev: true + /@types/jsonfile@6.1.3: resolution: {integrity: sha512-/yqTk2SZ1wIezK0hiRZD7RuSf4B3whFxFamB1kGStv+8zlWScTMcHanzfc0XKWs5vA1TkHeckBlOyM8jxU8nHA==} dependencies: '@types/node': 20.11.30 dev: true - /@types/lodash@4.17.0: - resolution: {integrity: sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA==} - dev: true - /@types/mdast@3.0.14: resolution: {integrity: sha512-gVZ04PGgw1qLZKsnWnyFv4ORnaJ+DXLdHTVSFbU8yX6xZ34Bjg4Q32yPkmveUP1yItXReKfB0Aknlh/3zxTKAw==} dependencies: '@types/unist': 2.0.9 dev: false - /@types/minimatch@5.1.2: - resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==} - dev: true - /@types/node@20.11.30: resolution: {integrity: sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==} dependencies: @@ -942,10 +930,6 @@ packages: resolution: {integrity: sha512-ehPtgRgaULsFG8x0NeYJvmyH1hmlfsNLujHe9dQEia/7MAJYdzMSi19JtchUHjmBA6XC/75dK55mzZH+RyieSg==} dev: false - /@types/prettier@2.7.3: - resolution: {integrity: sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==} - dev: true - /@types/prompts@2.4.9: resolution: {integrity: sha512-qTxFi6Buiu8+50/+3DGIWLHM6QuWsEKugJnnP6iv2Mc4ncxE4A/OJkjuVOA+5X0X1S/nq5VJRa8Lu+nwcvbrKA==} dependencies: @@ -1806,17 +1790,6 @@ packages: escape-string-regexp: 1.0.5 dev: false - /cli-color@2.0.4: - resolution: {integrity: sha512-zlnpg0jNcibNrO7GG9IeHH7maWFeCz+Ja1wx/7tZNU5ASSSSZ+/qZciM0/LHCYxSdqv5h2sdbQ/PXYdOuetXvA==} - engines: {node: '>=0.10'} - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - es6-iterator: 2.0.3 - memoizee: 0.4.15 - timers-ext: 0.1.7 - dev: true - /cli-cursor@4.0.0: resolution: {integrity: sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -1932,14 +1905,6 @@ packages: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} dev: true - /d@1.0.2: - resolution: {integrity: sha512-MOqHvMWF9/9MX6nza0KgvFH4HpMU0EF5uUDXqX/BtxtU8NfB0QzRtJ8Oe/6SuS4kbhyzVJwjd97EA4PKrzJ8bw==} - engines: {node: '>=0.12'} - dependencies: - es5-ext: 0.10.64 - type: 2.7.2 - dev: true - /debug@3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} peerDependencies: @@ -2185,42 +2150,6 @@ packages: is-symbol: 1.0.4 dev: true - /es5-ext@0.10.64: - resolution: {integrity: sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==} - engines: {node: '>=0.10'} - requiresBuild: true - dependencies: - es6-iterator: 2.0.3 - es6-symbol: 3.1.4 - esniff: 2.0.1 - next-tick: 1.1.0 - dev: true - - /es6-iterator@2.0.3: - resolution: {integrity: sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==} - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - es6-symbol: 3.1.4 - dev: true - - /es6-symbol@3.1.4: - resolution: {integrity: sha512-U9bFFjX8tFiATgtkJ1zg25+KviIXpgRvRHS8sau3GfhVzThRQrOeksPeT0BWW2MNZs1OEWJ1DPXOQMn0KKRkvg==} - engines: {node: '>=0.12'} - dependencies: - d: 1.0.2 - ext: 1.7.0 - dev: true - - /es6-weak-map@2.0.3: - resolution: {integrity: sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==} - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - es6-iterator: 2.0.3 - es6-symbol: 3.1.4 - dev: true - /esbuild@0.19.12: resolution: {integrity: sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==} engines: {node: '>=12'} @@ -2767,11 +2696,11 @@ packages: esrecurse: 4.3.0 estraverse: 5.3.0 - /eslint-typegen@0.1.3: - resolution: {integrity: sha512-ry+4sLT/HyhjcBQMcCwir1/luU08EcPKir5cH6W4AFq9YmaIlHJPA61gISAmTSV6/yXnNDJwcBtpSCGVMG74bw==} + /eslint-typegen@0.1.4: + resolution: {integrity: sha512-Sb/xFinq1B5ZmcM+OispI9BQbuS1gb058WSeads/40y0/iYjxLLng77Q6MZPzEcpYuP8vV2t5qsC1Ca2Plc19Q==} dependencies: '@types/eslint': 8.56.6 - json-schema-to-typescript: 13.1.2 + json-schema-to-typescript-lite: 14.0.0 ohash: 1.1.3 dev: true @@ -2825,16 +2754,6 @@ packages: transitivePeerDependencies: - supports-color - /esniff@2.0.1: - resolution: {integrity: sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==} - engines: {node: '>=0.10'} - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - event-emitter: 0.3.5 - type: 2.7.2 - dev: true - /esno@4.7.0: resolution: {integrity: sha512-81owrjxIxOwqcABt20U09Wn8lpBo9K6ttqbGvQcB3VYNLJyaV1fvKkDtpZd3Rj5BX3WXiGiJCjUevKQGNICzJg==} hasBin: true @@ -2891,13 +2810,6 @@ packages: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} - /event-emitter@0.3.5: - resolution: {integrity: sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==} - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - dev: true - /eventemitter3@5.0.1: resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==} dev: true @@ -2931,12 +2843,6 @@ packages: signal-exit: 4.1.0 strip-final-newline: 3.0.0 - /ext@1.7.0: - resolution: {integrity: sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==} - dependencies: - type: 2.7.2 - dev: true - /fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} @@ -3102,11 +3008,6 @@ packages: resolution: {integrity: sha512-Gxc29eLs1fbn6LQ4jSU4vXjlwyZhF5HsGuMAa7gqBP4Rw4yxxltyDUuF5MBclFzDTXO+ACchGQoeela4DSfzdQ==} dev: true - /get-stdin@8.0.0: - resolution: {integrity: sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==} - engines: {node: '>=10'} - dev: true - /get-stream@6.0.1: resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} engines: {node: '>=10'} @@ -3156,16 +3057,6 @@ packages: dependencies: is-glob: 4.0.3 - /glob-promise@4.2.2(glob@7.1.6): - resolution: {integrity: sha512-xcUzJ8NWN5bktoTIX7eOclO1Npxd/dyVqUJxlLIDasT4C7KZyqlPIwkdJ0Ypiy3p2ZKahTjK4M9uC3sNSfNMzw==} - engines: {node: '>=12'} - peerDependencies: - glob: ^7.1.6 - dependencies: - '@types/glob': 7.2.0 - glob: 7.1.6 - dev: true - /glob@10.3.10: resolution: {integrity: sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==} engines: {node: '>=16 || 14 >=14.17'} @@ -3495,10 +3386,6 @@ packages: resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} engines: {node: '>=8'} - /is-promise@2.2.2: - resolution: {integrity: sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==} - dev: true - /is-reference@3.0.2: resolution: {integrity: sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==} dependencies: @@ -3649,25 +3536,12 @@ packages: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} dev: false - /json-schema-to-typescript@13.1.2: - resolution: {integrity: sha512-17G+mjx4nunvOpkPvcz7fdwUwYCEwyH8vR3Ym3rFiQ8uzAL3go+c1306Kk7iGRk8HuXBXqy+JJJmpYl0cvOllw==} - engines: {node: '>=12.0.0'} - hasBin: true + /json-schema-to-typescript-lite@14.0.0: + resolution: {integrity: sha512-On0b6UdEgdotLzWk37yNId2wK77P7UfxuCWDEgduoz1VLR4rPbDcQGW6zlHVgL62Bq7gERq0JMmUyAjJigxYHg==} + engines: {node: '>=20.0.0'} dependencies: - '@bcherny/json-schema-ref-parser': 10.0.5-fork - '@types/json-schema': 7.0.14 - '@types/lodash': 4.17.0 - '@types/prettier': 2.7.3 - cli-color: 2.0.4 - get-stdin: 8.0.0 - glob: 7.1.6 - glob-promise: 4.2.2(glob@7.1.6) - is-glob: 4.0.3 - lodash: 4.17.21 - minimist: 1.2.8 - mkdirp: 1.0.4 - mz: 2.7.0 - prettier: 2.8.8 + '@apidevtools/json-schema-ref-parser': 11.5.4 + '@types/json-schema': 7.0.15 dev: true /json-schema-traverse@0.4.1: @@ -3816,6 +3690,7 @@ packages: /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} + dev: false /log-update@6.0.0: resolution: {integrity: sha512-niTvB4gqvtof056rRIrTZvjNYE4rCUzO6X/X+kYjd7WFxXeJ0NwEFnRxX6ehkvv3jTwrXnNdtAak5XYZuIyPFw==} @@ -3851,12 +3726,6 @@ packages: dependencies: yallist: 4.0.0 - /lru-queue@0.1.0: - resolution: {integrity: sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==} - dependencies: - es5-ext: 0.10.64 - dev: true - /magic-string@0.30.8: resolution: {integrity: sha512-ISQTe55T2ao7XtlAStud6qwYPZjE4GK1S/BeVPus4jrq6JuOnQ00YKQC581RWhR122W7msZV263KzVeLoqidyQ==} engines: {node: '>=12'} @@ -3882,19 +3751,6 @@ packages: /mdn-data@2.0.30: resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==} - /memoizee@0.4.15: - resolution: {integrity: sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==} - dependencies: - d: 1.0.2 - es5-ext: 0.10.64 - es6-weak-map: 2.0.3 - event-emitter: 0.3.5 - is-promise: 2.2.2 - lru-queue: 0.1.0 - next-tick: 1.1.0 - timers-ext: 0.1.7 - dev: true - /merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} @@ -3943,10 +3799,6 @@ packages: dependencies: brace-expansion: 2.0.1 - /minimist@1.2.8: - resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} - dev: true - /minipass@3.3.6: resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} engines: {node: '>=8'} @@ -4013,10 +3865,6 @@ packages: /natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} - /next-tick@1.1.0: - resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==} - dev: true - /node-fetch-native@1.6.1: resolution: {integrity: sha512-bW9T/uJDPAJB2YNYEpWzE54U5O3MQidXsOyTfnbKYtTtFexRvGzb1waphBN4ZwP6EcIvYYEOwW0b72BpAqydTw==} dev: true @@ -4451,12 +4299,6 @@ packages: prettier: 3.2.5 dev: true - /prettier@2.8.8: - resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} - engines: {node: '>=10.13.0'} - hasBin: true - dev: true - /prettier@3.2.5: resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} engines: {node: '>=14'} @@ -5076,13 +4918,6 @@ packages: any-promise: 1.3.0 dev: true - /timers-ext@0.1.7: - resolution: {integrity: sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==} - dependencies: - es5-ext: 0.10.64 - next-tick: 1.1.0 - dev: true - /tinybench@2.5.1: resolution: {integrity: sha512-65NKvSuAVDP/n4CqH+a9w2kTlLReS9vhsAP06MWx+/89nMinJyB2icyl58RIcqCmIggpojIGeuJGhjU1aGMBSg==} @@ -5231,10 +5066,6 @@ packages: engines: {node: '>=14.16'} dev: true - /type@2.7.2: - resolution: {integrity: sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==} - dev: true - /typed-array-buffer@1.0.2: resolution: {integrity: sha512-gEymJYKZtKXzzBzM4jqa9w6Q1Jjm7x2d+sh19AdsD4wqnMPDYyvwpsIc2Q/835kHuo3BEQ7CjelGhfTsoBb2MQ==} engines: {node: '>= 0.4'} From 3f0993af750cf891f568165caff8936cfb5663f6 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Thu, 28 Mar 2024 00:49:32 +0100 Subject: [PATCH 5/7] chore: release v2.11.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 34f5a9165b..95e6e49d8c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@antfu/eslint-config", "type": "module", - "version": "2.11.1", + "version": "2.11.2", "packageManager": "pnpm@8.15.5", "description": "Anthony's ESLint config", "author": "Anthony Fu (https://github.com/antfu/)", From ac1b7268857c23d47fe12c23f3a3855257c09f9f Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Thu, 28 Mar 2024 01:01:43 +0100 Subject: [PATCH 6/7] feat: more relax types for merging --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- src/configs/astro.ts | 4 ++-- src/configs/comments.ts | 4 ++-- src/configs/formatters.ts | 6 +++--- src/configs/ignores.ts | 4 ++-- src/configs/imports.ts | 4 ++-- src/configs/javascript.ts | 4 ++-- src/configs/jsdoc.ts | 4 ++-- src/configs/jsonc.ts | 4 ++-- src/configs/markdown.ts | 4 ++-- src/configs/node.ts | 4 ++-- src/configs/perfectionist.ts | 4 ++-- src/configs/react.ts | 4 ++-- src/configs/sort.ts | 6 +++--- src/configs/stylistic.ts | 4 ++-- src/configs/svelte.ts | 4 ++-- src/configs/test.ts | 4 ++-- src/configs/toml.ts | 4 ++-- src/configs/typescript.ts | 8 ++++---- src/configs/unicorn.ts | 4 ++-- src/configs/unocss.ts | 4 ++-- src/configs/vue.ts | 4 ++-- src/configs/yaml.ts | 4 ++-- src/factory.ts | 25 +++++++++++++------------ src/types.ts | 30 ++++++++++++++---------------- src/utils.ts | 6 +++--- test/fixtures.test.ts | 4 ++-- test/types.ts | 6 +++--- 29 files changed, 88 insertions(+), 89 deletions(-) diff --git a/package.json b/package.json index 95e6e49d8c..0faa91d189 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "@typescript-eslint/eslint-plugin": "^7.4.0", "@typescript-eslint/parser": "^7.4.0", "eslint-config-flat-gitignore": "^0.1.3", - "eslint-flat-config-utils": "^0.1.0", + "eslint-flat-config-utils": "^0.1.1", "eslint-merge-processors": "^0.1.0", "eslint-plugin-antfu": "^2.1.2", "eslint-plugin-eslint-comments": "^3.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4b987207ea..5030dce8d8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,8 +27,8 @@ importers: specifier: ^0.1.3 version: 0.1.3 eslint-flat-config-utils: - specifier: ^0.1.0 - version: 0.1.0 + specifier: ^0.1.1 + version: 0.1.1 eslint-merge-processors: specifier: ^0.1.0 version: 0.1.0(eslint@9.0.0-rc.0) @@ -2218,8 +2218,8 @@ packages: parse-gitignore: 2.0.0 dev: false - /eslint-flat-config-utils@0.1.0: - resolution: {integrity: sha512-GVjeM6BITHRpax/lLV8IEdsyIFHH0/4ggN3WJ3IcMTxKRmbo1pA8chPE/WP4sjvkEo8W6WaeIopUMhlzHYeP4g==} + /eslint-flat-config-utils@0.1.1: + resolution: {integrity: sha512-lQc7hFsNu54In+XbJdMmI06zJ5d8+3oDD+Y6badqZ434g9Xm6w+7DGv+mlzQgpf/eMX5iK2kUroTsFdy/WC8Sg==} dependencies: '@types/eslint': 8.56.6 dev: false diff --git a/src/configs/astro.ts b/src/configs/astro.ts index e6a1d471ac..30328f5f07 100644 --- a/src/configs/astro.ts +++ b/src/configs/astro.ts @@ -1,10 +1,10 @@ -import type { FlatConfigItem, OptionsFiles, OptionsOverrides, OptionsStylistic } from '../types' +import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' import { GLOB_ASTRO } from '../globs' import { interopDefault } from '../utils' export async function astro( options: OptionsOverrides & OptionsStylistic & OptionsFiles = {}, -): Promise { +): Promise { const { files = [GLOB_ASTRO], overrides = {}, diff --git a/src/configs/comments.ts b/src/configs/comments.ts index a56283698e..b126c698dd 100644 --- a/src/configs/comments.ts +++ b/src/configs/comments.ts @@ -1,7 +1,7 @@ -import type { FlatConfigItem } from '../types' +import type { TypedFlatConfigItem } from '../types' import { pluginComments } from '../plugins' -export async function comments(): Promise { +export async function comments(): Promise { return [ { name: 'antfu:eslint-comments', diff --git a/src/configs/formatters.ts b/src/configs/formatters.ts index d340a598be..c7ddc52abe 100644 --- a/src/configs/formatters.ts +++ b/src/configs/formatters.ts @@ -2,13 +2,13 @@ import { isPackageExists } from 'local-pkg' import { GLOB_ASTRO, GLOB_CSS, GLOB_GRAPHQL, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS } from '../globs' import type { VendoredPrettierOptions } from '../vender/prettier-types' import { ensurePackages, interopDefault, parserPlain } from '../utils' -import type { FlatConfigItem, OptionsFormatters, StylisticConfig } from '../types' +import type { OptionsFormatters, StylisticConfig, TypedFlatConfigItem } from '../types' import { StylisticConfigDefaults } from './stylistic' export async function formatters( options: OptionsFormatters | true = {}, stylistic: StylisticConfig = {}, -): Promise { +): Promise { if (options === true) { options = { astro: isPackageExists('astro'), @@ -61,7 +61,7 @@ export async function formatters( const pluginFormat = await interopDefault(import('eslint-plugin-format')) - const configs: FlatConfigItem[] = [ + const configs: TypedFlatConfigItem[] = [ { name: 'antfu:formatters:setup', plugins: { diff --git a/src/configs/ignores.ts b/src/configs/ignores.ts index ec83734a47..41326a3893 100644 --- a/src/configs/ignores.ts +++ b/src/configs/ignores.ts @@ -1,7 +1,7 @@ -import type { FlatConfigItem } from '../types' +import type { TypedFlatConfigItem } from '../types' import { GLOB_EXCLUDE } from '../globs' -export async function ignores(): Promise { +export async function ignores(): Promise { return [ { ignores: GLOB_EXCLUDE, diff --git a/src/configs/imports.ts b/src/configs/imports.ts index 19849a6388..34b2d071a7 100644 --- a/src/configs/imports.ts +++ b/src/configs/imports.ts @@ -1,8 +1,8 @@ -import type { FlatConfigItem, OptionsStylistic } from '../types' +import type { OptionsStylistic, TypedFlatConfigItem } from '../types' import { pluginAntfu, pluginImport } from '../plugins' import { GLOB_SRC_EXT } from '../globs' -export async function imports(options: OptionsStylistic = {}): Promise { +export async function imports(options: OptionsStylistic = {}): Promise { const { stylistic = true, } = options diff --git a/src/configs/javascript.ts b/src/configs/javascript.ts index c750919b28..d892e3c054 100644 --- a/src/configs/javascript.ts +++ b/src/configs/javascript.ts @@ -1,11 +1,11 @@ import globals from 'globals' -import type { FlatConfigItem, OptionsIsInEditor, OptionsOverrides } from '../types' +import type { OptionsIsInEditor, OptionsOverrides, TypedFlatConfigItem } from '../types' import { pluginAntfu, pluginUnusedImports } from '../plugins' import { GLOB_SRC, GLOB_SRC_EXT } from '../globs' export async function javascript( options: OptionsIsInEditor & OptionsOverrides = {}, -): Promise { +): Promise { const { isInEditor = false, overrides = {}, diff --git a/src/configs/jsdoc.ts b/src/configs/jsdoc.ts index c1b1686a0e..3a0b4181c9 100644 --- a/src/configs/jsdoc.ts +++ b/src/configs/jsdoc.ts @@ -1,7 +1,7 @@ import { interopDefault } from '../utils' -import type { FlatConfigItem, OptionsStylistic } from '../types' +import type { OptionsStylistic, TypedFlatConfigItem } from '../types' -export async function jsdoc(options: OptionsStylistic = {}): Promise { +export async function jsdoc(options: OptionsStylistic = {}): Promise { const { stylistic = true, } = options diff --git a/src/configs/jsonc.ts b/src/configs/jsonc.ts index b456dbe126..a68ee48a86 100644 --- a/src/configs/jsonc.ts +++ b/src/configs/jsonc.ts @@ -1,10 +1,10 @@ -import type { FlatConfigItem, OptionsFiles, OptionsOverrides, OptionsStylistic } from '../types' +import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' import { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from '../globs' import { interopDefault } from '../utils' export async function jsonc( options: OptionsFiles & OptionsStylistic & OptionsOverrides = {}, -): Promise { +): Promise { const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC], overrides = {}, diff --git a/src/configs/markdown.ts b/src/configs/markdown.ts index 51ab9367cb..73d75514bd 100644 --- a/src/configs/markdown.ts +++ b/src/configs/markdown.ts @@ -1,11 +1,11 @@ import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors' -import type { FlatConfigItem, OptionsComponentExts, OptionsFiles, OptionsOverrides } from '../types' +import type { OptionsComponentExts, OptionsFiles, OptionsOverrides, TypedFlatConfigItem } from '../types' import { GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN } from '../globs' import { interopDefault, parserPlain } from '../utils' export async function markdown( options: OptionsFiles & OptionsComponentExts & OptionsOverrides = {}, -): Promise { +): Promise { const { componentExts = [], files = [GLOB_MARKDOWN], diff --git a/src/configs/node.ts b/src/configs/node.ts index 17438242c3..dcbfde364f 100644 --- a/src/configs/node.ts +++ b/src/configs/node.ts @@ -1,7 +1,7 @@ -import type { FlatConfigItem } from '../types' +import type { TypedFlatConfigItem } from '../types' import { pluginNode } from '../plugins' -export async function node(): Promise { +export async function node(): Promise { return [ { name: 'antfu:node', diff --git a/src/configs/perfectionist.ts b/src/configs/perfectionist.ts index 9722d45fad..e42b4ff9f4 100644 --- a/src/configs/perfectionist.ts +++ b/src/configs/perfectionist.ts @@ -1,4 +1,4 @@ -import type { FlatConfigItem } from '../types' +import type { TypedFlatConfigItem } from '../types' import { pluginPerfectionist } from '../plugins' /** @@ -6,7 +6,7 @@ import { pluginPerfectionist } from '../plugins' * * @see https://github.com/azat-io/eslint-plugin-perfectionist */ -export async function perfectionist(): Promise { +export async function perfectionist(): Promise { return [ { name: 'antfu:perfectionist', diff --git a/src/configs/react.ts b/src/configs/react.ts index 820e6ece3a..4957a4263f 100644 --- a/src/configs/react.ts +++ b/src/configs/react.ts @@ -1,6 +1,6 @@ import { isPackageExists } from 'local-pkg' import { ensurePackages, interopDefault } from '../utils' -import type { FlatConfigItem, OptionsFiles, OptionsHasTypeScript, OptionsOverrides } from '../types' +import type { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, TypedFlatConfigItem } from '../types' import { GLOB_JSX, GLOB_TSX } from '../globs' // react refresh @@ -10,7 +10,7 @@ const ReactRefreshAllowConstantExportPackages = [ export async function react( options: OptionsHasTypeScript & OptionsOverrides & OptionsFiles = {}, -): Promise { +): Promise { const { files = [GLOB_JSX, GLOB_TSX], overrides = {}, diff --git a/src/configs/sort.ts b/src/configs/sort.ts index c5c7853781..4321b61ec2 100644 --- a/src/configs/sort.ts +++ b/src/configs/sort.ts @@ -1,11 +1,11 @@ -import type { FlatConfigItem } from '../types' +import type { TypedFlatConfigItem } from '../types' /** * Sort package.json * * Requires `jsonc` config */ -export async function sortPackageJson(): Promise { +export async function sortPackageJson(): Promise { return [ { files: ['**/package.json'], @@ -112,7 +112,7 @@ export async function sortPackageJson(): Promise { * Requires `jsonc` config */ -export function sortTsconfig(): FlatConfigItem[] { +export function sortTsconfig(): TypedFlatConfigItem[] { return [ { files: ['**/tsconfig.json', '**/tsconfig.*.json'], diff --git a/src/configs/stylistic.ts b/src/configs/stylistic.ts index a0f891bd38..064aef24db 100644 --- a/src/configs/stylistic.ts +++ b/src/configs/stylistic.ts @@ -1,5 +1,5 @@ import { interopDefault } from '../utils' -import type { FlatConfigItem, OptionsOverrides, StylisticConfig } from '../types' +import type { OptionsOverrides, StylisticConfig, TypedFlatConfigItem } from '../types' import { pluginAntfu } from '../plugins' export const StylisticConfigDefaults: StylisticConfig = { @@ -11,7 +11,7 @@ export const StylisticConfigDefaults: StylisticConfig = { export async function stylistic( options: StylisticConfig & OptionsOverrides = {}, -): Promise { +): Promise { const { indent, jsx, diff --git a/src/configs/svelte.ts b/src/configs/svelte.ts index 2c151d2c71..a591e9e20e 100644 --- a/src/configs/svelte.ts +++ b/src/configs/svelte.ts @@ -1,10 +1,10 @@ import { ensurePackages, interopDefault } from '../utils' -import type { FlatConfigItem, OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic } from '../types' +import type { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' import { GLOB_SVELTE } from '../globs' export async function svelte( options: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles = {}, -): Promise { +): Promise { const { files = [GLOB_SVELTE], overrides = {}, diff --git a/src/configs/test.ts b/src/configs/test.ts index 9756c1826f..ac5fa5a1ca 100644 --- a/src/configs/test.ts +++ b/src/configs/test.ts @@ -1,10 +1,10 @@ import { interopDefault } from '../utils' -import type { FlatConfigItem, OptionsFiles, OptionsIsInEditor, OptionsOverrides } from '../types' +import type { OptionsFiles, OptionsIsInEditor, OptionsOverrides, TypedFlatConfigItem } from '../types' import { GLOB_TESTS } from '../globs' export async function test( options: OptionsFiles & OptionsIsInEditor & OptionsOverrides = {}, -): Promise { +): Promise { const { files = GLOB_TESTS, isInEditor = false, diff --git a/src/configs/toml.ts b/src/configs/toml.ts index 9144ba3d44..9622b9bb7d 100644 --- a/src/configs/toml.ts +++ b/src/configs/toml.ts @@ -1,10 +1,10 @@ -import type { FlatConfigItem, OptionsFiles, OptionsOverrides, OptionsStylistic } from '../types' +import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' import { GLOB_TOML } from '../globs' import { interopDefault } from '../utils' export async function toml( options: OptionsOverrides & OptionsStylistic & OptionsFiles = {}, -): Promise { +): Promise { const { files = [GLOB_TOML], overrides = {}, diff --git a/src/configs/typescript.ts b/src/configs/typescript.ts index 448eefca7c..06bd45abc6 100644 --- a/src/configs/typescript.ts +++ b/src/configs/typescript.ts @@ -1,12 +1,12 @@ import process from 'node:process' import { GLOB_SRC, GLOB_TS, GLOB_TSX } from '../globs' -import type { FlatConfigItem, OptionsComponentExts, OptionsFiles, OptionsOverrides, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes } from '../types' +import type { OptionsComponentExts, OptionsFiles, OptionsOverrides, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, TypedFlatConfigItem } from '../types' import { pluginAntfu } from '../plugins' import { interopDefault, renameRules, toArray } from '../utils' export async function typescript( options: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions = {}, -): Promise { +): Promise { const { componentExts = [], overrides = {}, @@ -24,7 +24,7 @@ export async function typescript( : undefined const isTypeAware = !!tsconfigPath - const typeAwareRules: FlatConfigItem['rules'] = { + const typeAwareRules: TypedFlatConfigItem['rules'] = { 'dot-notation': 'off', 'no-implied-eval': 'off', 'no-throw-literal': 'off', @@ -54,7 +54,7 @@ export async function typescript( interopDefault(import('@typescript-eslint/parser')), ] as const) - function makeParser(typeAware: boolean, files: string[], ignores?: string[]): FlatConfigItem { + function makeParser(typeAware: boolean, files: string[], ignores?: string[]): TypedFlatConfigItem { return { files, ...ignores ? { ignores } : {}, diff --git a/src/configs/unicorn.ts b/src/configs/unicorn.ts index 3481ad2458..5bb9989235 100644 --- a/src/configs/unicorn.ts +++ b/src/configs/unicorn.ts @@ -1,7 +1,7 @@ -import type { FlatConfigItem } from '../types' +import type { TypedFlatConfigItem } from '../types' import { pluginUnicorn } from '../plugins' -export async function unicorn(): Promise { +export async function unicorn(): Promise { return [ { name: 'antfu:unicorn', diff --git a/src/configs/unocss.ts b/src/configs/unocss.ts index 516b6d7a0b..973f031936 100644 --- a/src/configs/unocss.ts +++ b/src/configs/unocss.ts @@ -1,9 +1,9 @@ import { ensurePackages, interopDefault } from '../utils' -import type { FlatConfigItem, OptionsUnoCSS } from '../types' +import type { OptionsUnoCSS, TypedFlatConfigItem } from '../types' export async function unocss( options: OptionsUnoCSS = {}, -): Promise { +): Promise { const { attributify = true, strict = false, diff --git a/src/configs/vue.ts b/src/configs/vue.ts index ff94172c5d..27a6c6b547 100644 --- a/src/configs/vue.ts +++ b/src/configs/vue.ts @@ -1,11 +1,11 @@ import { mergeProcessors } from 'eslint-merge-processors' import { interopDefault } from '../utils' -import type { FlatConfigItem, OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic, OptionsVue } from '../types' +import type { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic, OptionsVue, TypedFlatConfigItem } from '../types' import { GLOB_VUE } from '../globs' export async function vue( options: OptionsVue & OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles = {}, -): Promise { +): Promise { const { files = [GLOB_VUE], overrides = {}, diff --git a/src/configs/yaml.ts b/src/configs/yaml.ts index 46e5d4af9f..c350f9fb92 100644 --- a/src/configs/yaml.ts +++ b/src/configs/yaml.ts @@ -1,10 +1,10 @@ -import type { FlatConfigItem, OptionsFiles, OptionsOverrides, OptionsStylistic } from '../types' +import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' import { GLOB_YAML } from '../globs' import { interopDefault } from '../utils' export async function yaml( options: OptionsOverrides & OptionsStylistic & OptionsFiles = {}, -): Promise { +): Promise { const { files = [GLOB_YAML], overrides = {}, diff --git a/src/factory.ts b/src/factory.ts index adac710c80..210b9dc6ab 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -2,7 +2,8 @@ import process from 'node:process' import fs from 'node:fs' import { isPackageExists } from 'local-pkg' import { FlatConfigPipeline } from 'eslint-flat-config-utils' -import type { Awaitable, FlatConfigItem, OptionsConfig } from './types' +import type { Linter } from 'eslint' +import type { Awaitable, OptionsConfig, TypedFlatConfigItem } from './types' import { astro, comments, @@ -30,7 +31,7 @@ import { import { interopDefault } from './utils' import { formatters } from './configs/formatters' -const flatConfigProps: (keyof FlatConfigItem)[] = [ +const flatConfigProps: (keyof TypedFlatConfigItem)[] = [ 'name', 'files', 'ignores', @@ -61,17 +62,17 @@ export const defaultPluginRenaming = { /** * Construct an array of ESLint flat config items. * - * @param {OptionsConfig & FlatConfigItem} options + * @param {OptionsConfig & TypedFlatConfigItem} options * The options for generating the ESLint configurations. - * @param {Awaitable[]} userConfigs + * @param {Awaitable[]} userConfigs * The user configurations to be merged with the generated configurations. - * @returns {Promise} + * @returns {Promise} * The merged ESLint configurations. */ export function antfu( - options: OptionsConfig & FlatConfigItem = {}, - ...userConfigs: Awaitable[] -): FlatConfigPipeline { + options: OptionsConfig & TypedFlatConfigItem = {}, + ...userConfigs: Awaitable | Linter.FlatConfig[]>[] +): FlatConfigPipeline { const { astro: enableAstro = false, autoRenamePlugins = true, @@ -94,7 +95,7 @@ export function antfu( if (stylisticOptions && !('jsx' in stylisticOptions)) stylisticOptions.jsx = options.jsx ?? true - const configs: Awaitable[] = [] + const configs: Awaitable[] = [] if (enableGitignore) { if (typeof enableGitignore !== 'boolean') { @@ -239,16 +240,16 @@ export function antfu( if (key in options) acc[key] = options[key] as any return acc - }, {} as FlatConfigItem) + }, {} as TypedFlatConfigItem) if (Object.keys(fusedConfig).length) configs.push([fusedConfig]) - let pipeline = new FlatConfigPipeline() + let pipeline = new FlatConfigPipeline() pipeline = pipeline .append( ...configs, - ...userConfigs, + ...userConfigs as any, ) if (autoRenamePlugins) { diff --git a/src/types.ts b/src/types.ts index ac6b227188..b789f9e070 100644 --- a/src/types.ts +++ b/src/types.ts @@ -10,7 +10,7 @@ export type Awaitable = T | Promise export type Rules = RuleOptions -export type FlatConfigItem = Omit & { +export type TypedFlatConfigItem = Omit & { /** * Custom name of each config item */ @@ -27,9 +27,7 @@ export type FlatConfigItem = Omit & { /** * An object containing a name-value mapping of rules to use. */ - rules?: { - [key: string]: Linter.RuleEntry - } & Rules + rules?: Linter.RulesRecord & Rules } export interface OptionsFiles { @@ -163,7 +161,7 @@ export interface StylisticConfig extends Pick[]): Promise { +export async function combine(...configs: Awaitable[]): Promise { const resolved = await Promise.all(configs) return resolved.flat() } @@ -76,7 +76,7 @@ export function renameRules(rules: Record, map: Record): FlatConfigItem[] { +export function renamePluginInConfigs(configs: TypedFlatConfigItem[], map: Record): TypedFlatConfigItem[] { return configs.map((i) => { const clone = { ...i } if (clone.rules) diff --git a/test/fixtures.test.ts b/test/fixtures.test.ts index 02d8e7296b..682fad0977 100644 --- a/test/fixtures.test.ts +++ b/test/fixtures.test.ts @@ -3,7 +3,7 @@ import { afterAll, beforeAll, it } from 'vitest' import fs from 'fs-extra' import { execa } from 'execa' import fg from 'fast-glob' -import type { FlatConfigItem, OptionsConfig } from '../src/types' +import type { OptionsConfig, TypedFlatConfigItem } from '../src/types' beforeAll(async () => { await fs.rm('_fixtures', { recursive: true, force: true }) @@ -79,7 +79,7 @@ runWithConfig( }, ) -function runWithConfig(name: string, configs: OptionsConfig, ...items: FlatConfigItem[]) { +function runWithConfig(name: string, configs: OptionsConfig, ...items: TypedFlatConfigItem[]) { it.concurrent(name, async ({ expect }) => { const from = resolve('fixtures/input') const output = resolve('fixtures/output', name) diff --git a/test/types.ts b/test/types.ts index 9701a61baf..e204608ebd 100644 --- a/test/types.ts +++ b/test/types.ts @@ -1,6 +1,6 @@ import type { Linter } from 'eslint' -import type { FlatConfigItem } from '../src'; +import type { TypedFlatConfigItem } from '../src'; // Make sure they are compatible -((): Linter.FlatConfig => ({} as FlatConfigItem))(); -((): FlatConfigItem => ({} as Linter.FlatConfig))() +((): Linter.FlatConfig => ({} as TypedFlatConfigItem))(); +((): TypedFlatConfigItem => ({} as Linter.FlatConfig))() From 78ba89fa042873534608b5b03111901081941803 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Thu, 28 Mar 2024 01:01:53 +0100 Subject: [PATCH 7/7] chore: release v2.11.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0faa91d189..ef03075c31 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@antfu/eslint-config", "type": "module", - "version": "2.11.2", + "version": "2.11.3", "packageManager": "pnpm@8.15.5", "description": "Anthony's ESLint config", "author": "Anthony Fu (https://github.com/antfu/)",