From 32593945021696a0085a877402f17610179c0afc Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Mon, 5 Aug 2024 17:55:06 +1200 Subject: [PATCH] feat: more tweaks --- package.json | 6 +- pnpm-lock.yaml | 127 ++++++++++++++++++---------- rollup.config.ts | 2 +- scripts/typegen.ts | 2 + src/configs/comments.ts | 4 +- src/configs/formatters.ts | 12 +-- src/configs/functional.ts | 14 +-- src/configs/ignores.ts | 52 ++++++++++-- src/configs/imports.ts | 14 +-- src/configs/in-editor.ts | 2 +- src/configs/javascript.ts | 8 +- src/configs/jsdoc.ts | 4 +- src/configs/jsonc.ts | 12 +-- src/configs/markdown.ts | 14 +-- src/configs/node.ts | 4 +- src/configs/overrides.ts | 2 +- src/configs/promise.ts | 4 +- src/configs/regexp.ts | 4 +- src/configs/sonar.ts | 4 +- src/configs/sort.ts | 2 +- src/configs/stylistic.ts | 14 +-- src/configs/test.ts | 8 +- src/configs/toml.ts | 12 +-- src/configs/typescript.ts | 22 ++--- src/configs/unicorn.ts | 4 +- src/configs/unocss.ts | 4 +- src/configs/vue.ts | 18 ++-- src/configs/yaml.ts | 12 +-- src/factory.ts | 17 ++-- src/types.ts | 32 +++++-- src/utils.ts | 4 +- tsconfig.json | 4 +- typings/eslint-plugin-vue-i18n.d.ts | 7 +- 33 files changed, 270 insertions(+), 181 deletions(-) diff --git a/package.json b/package.json index 56030295..0741efc4 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "@commitlint/cli": "19.3.0", "@commitlint/config-conventional": "19.2.2", "@cspell/dict-cryptocurrencies": "5.0.0", + "@eslint/compat": "1.1.1", "@intlify/eslint-plugin-vue-i18n": "3.0.0", "@semantic-release/changelog": "6.0.3", "@semantic-release/commit-analyzer": "13.0.0", @@ -67,6 +68,7 @@ "@semantic-release/release-notes-generator": "14.0.1", "@stylistic/eslint-plugin": "2.6.1", "@stylistic/eslint-plugin-migrate": "2.6.1", + "@types/eslint": "9.6.0", "@types/node": "22.1.0", "@typescript-eslint/eslint-plugin": "8.0.0", "@typescript-eslint/parser": "8.0.0", @@ -86,7 +88,7 @@ "eslint-plugin-jsdoc": "48.11.0", "eslint-plugin-jsonc": "2.16.0", "eslint-plugin-markdown": "5.1.0", - "eslint-plugin-n": "17.10.1", + "eslint-plugin-n": "17.10.2", "eslint-plugin-no-only-tests": "3.1.0", "eslint-plugin-optimize-regex": "1.2.1", "eslint-plugin-prettier": "5.2.1", @@ -104,7 +106,7 @@ "jiti": "1.21.6", "jsonc-eslint-parser": "2.4.0", "knip": "5.27.0", - "lint-staged": "15.2.7", + "lint-staged": "15.2.8", "markdownlint": "0.34.0", "markdownlint-cli": "0.41.0", "prettier": "3.3.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c401e23b..ffdc834b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,6 +36,9 @@ importers: '@cspell/dict-cryptocurrencies': specifier: 5.0.0 version: 5.0.0 + '@eslint/compat': + specifier: 1.1.1 + version: 1.1.1 '@intlify/eslint-plugin-vue-i18n': specifier: 3.0.0 version: 3.0.0(eslint@9.8.0) @@ -63,6 +66,9 @@ importers: '@stylistic/eslint-plugin-migrate': specifier: 2.6.1 version: 2.6.1(eslint@9.8.0)(typescript@5.4.5) + '@types/eslint': + specifier: 9.6.0 + version: 9.6.0 '@types/node': specifier: 22.1.0 version: 22.1.0 @@ -121,8 +127,8 @@ importers: specifier: 5.1.0 version: 5.1.0(eslint@9.8.0) eslint-plugin-n: - specifier: 17.10.1 - version: 17.10.1(eslint@9.8.0) + specifier: 17.10.2 + version: 17.10.2(eslint@9.8.0) eslint-plugin-no-only-tests: specifier: 3.1.0 version: 3.1.0 @@ -175,8 +181,8 @@ importers: specifier: 5.27.0 version: 5.27.0(@types/node@22.1.0)(typescript@5.4.5) lint-staged: - specifier: 15.2.7 - version: 15.2.7 + specifier: 15.2.8 + version: 15.2.8 markdownlint: specifier: 0.34.0 version: 0.34.0 @@ -701,6 +707,10 @@ packages: '@eslint-stylistic/metadata@2.6.1': resolution: {integrity: sha512-cjM6wojoJbLCyZWyil8IwLnj+eAke7CIzenxJrKnHDe+NGUAbP9q3xQ5F5idgkFJfNhCwJ1WjwUpxJH7mptLWg==} + '@eslint/compat@1.1.1': + resolution: {integrity: sha512-lpHyRyplhGPL5mGEh6M9O5nnKk0Gz4bFI+Zu6tKlPpDUN7XshWvH9C/px4UVm87IAANE0W81CEsNGbS1KlzXpA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@eslint/config-array@0.17.1': resolution: {integrity: sha512-BlYOpej8AQ8Ev9xVqroV7a02JK3SkBAaN9GfMMH9W6Ch8FlQlkjGw4Ir7+FgYwfirivAf4t+GtzuAxqfukmISA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -1237,6 +1247,10 @@ packages: resolution: {integrity: sha512-4nJ3yixlEthEJ9Rk4vPcdBRkZvQZlYyu8j4/Mqz5sgIkddmEnH2Yj2ZrnP9S3tQOvSNRUIgVNF/1yPpRAGNRig==} engines: {node: '>=14.16'} + ansi-escapes@7.0.0: + resolution: {integrity: sha512-GdYO7a61mR0fOlAsvC9/rIHf7L96sBc6dEWzeOu+KAea5bZyQRPIpojrVoI4AXGJS/ycu/fBTdLrUkA4ODrvjw==} + engines: {node: '>=18'} + ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} @@ -1436,9 +1450,9 @@ packages: resolution: {integrity: sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==} engines: {node: '>=8'} - cli-cursor@4.0.0: - resolution: {integrity: sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + cli-cursor@5.0.0: + resolution: {integrity: sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==} + engines: {node: '>=18'} cli-highlight@2.1.11: resolution: {integrity: sha512-9KDcoEVwyUXrjcJNvHD0NFc/hiwe/WPVYIleQh2O1N2Zro5gWJZ/K+3DGn8w8P/F6FxOgzyC5bxDyHIgCSPhGg==} @@ -1789,6 +1803,10 @@ packages: resolution: {integrity: sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + environment@1.1.0: + resolution: {integrity: sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==} + engines: {node: '>=18'} + error-ex@1.3.2: resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} @@ -1963,8 +1981,8 @@ packages: peerDependencies: eslint: '>=8' - eslint-plugin-n@17.10.1: - resolution: {integrity: sha512-hm/q37W6efDptJXdwirsm6A257iY6ZNtpoSG0wEzFzjJ3AhL7OhEIhdSR2e4OdYfHO5EDeqlCfFrjf9q208IPw==} + eslint-plugin-n@17.10.2: + resolution: {integrity: sha512-e+s4eAf5NtJaxPhTNu3qMO0Iz40WANS93w9LQgYcvuljgvDmWi/a3rh+OrNyMHeng6aOWGJO0rCg5lH4zi8yTw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: '>=8.23.0' @@ -2826,8 +2844,8 @@ packages: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} - lilconfig@3.1.1: - resolution: {integrity: sha512-O18pf7nyvHTckunPWCV1XUNXU1piu01y2b7ATJ0ppkUkk8ocqVWBrYjJBCwHDjD/ZWcfyrA0P4gKhzWGi5EINQ==} + lilconfig@3.1.2: + resolution: {integrity: sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==} engines: {node: '>=14'} lines-and-columns@1.2.4: @@ -2836,13 +2854,13 @@ packages: linkify-it@5.0.0: resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==} - lint-staged@15.2.7: - resolution: {integrity: sha512-+FdVbbCZ+yoh7E/RosSdqKJyUM2OEjTciH0TFNkawKgvFp1zbGlEC39RADg+xKBG1R4mhoH2j85myBQZ5wR+lw==} + lint-staged@15.2.8: + resolution: {integrity: sha512-PUWFf2zQzsd9EFU+kM1d7UP+AZDbKFKuj+9JNVTBkhUFhbg4MAt6WfyMMwBfM4lYqd4D2Jwac5iuTu9rVj4zCQ==} engines: {node: '>=18.12.0'} hasBin: true - listr2@8.2.1: - resolution: {integrity: sha512-irTfvpib/rNiD637xeevjO2l3Z5loZmuaRi0L0YE5LfijwVY96oyVn0DFD3o/teAok7nfobMG1THvvcHh/BP6g==} + listr2@8.2.4: + resolution: {integrity: sha512-opevsywziHd3zHCVQGAj8zu+Z3yHNkkoYhWIGnq54RrCVwLz0MozotJEDnKsIBLvkfLGN6BLOyAeRrYI0pKA4g==} engines: {node: '>=18.0.0'} load-json-file@4.0.0: @@ -2925,8 +2943,8 @@ packages: resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} engines: {node: '>=10'} - log-update@6.0.0: - resolution: {integrity: sha512-niTvB4gqvtof056rRIrTZvjNYE4rCUzO6X/X+kYjd7WFxXeJ0NwEFnRxX6ehkvv3jTwrXnNdtAak5XYZuIyPFw==} + log-update@6.1.0: + resolution: {integrity: sha512-9ie8ItPR6tjY5uYJh8K/Zrv/RMZ5VOlOWvtZdEHYSTFKZfIBPQa9tOAEeAWhd+AnIneLJ22w5fjOYtoutpWq5w==} engines: {node: '>=18'} longest@2.0.1: @@ -3019,6 +3037,10 @@ packages: resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} engines: {node: '>=12'} + mimic-function@5.0.1: + resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==} + engines: {node: '>=18'} + min-indent@1.0.1: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} @@ -3221,6 +3243,10 @@ packages: resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} engines: {node: '>=12'} + onetime@7.0.0: + resolution: {integrity: sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==} + engines: {node: '>=18'} + optionator@0.9.4: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} @@ -3571,16 +3597,16 @@ packages: resolution: {integrity: sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==} engines: {node: '>=8'} - restore-cursor@4.0.0: - resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + restore-cursor@5.1.0: + resolution: {integrity: sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==} + engines: {node: '>=18'} reusify@1.0.4: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - rfdc@1.3.1: - resolution: {integrity: sha512-r5a3l5HzYlIC68TpmYKlxWjmOP6wiPJ1vWv2HeLhNsRZMrCkxeqxiHlQ21oXmQ4F3SiryXBHhAD7JZqvOJjFmg==} + rfdc@1.4.1: + resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} rimraf@6.0.1: resolution: {integrity: sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==} @@ -4189,11 +4215,6 @@ packages: resolution: {integrity: sha512-4wZWvE398hCP7O8n3nXKu/vdq1HcH01ixYlCREaJL5NUMwQ0g3MaGFUBNSlmBtKmhbtVG/Cm6lyYmSVTEVil8A==} engines: {node: ^14.17.0 || >=16.0.0} - yaml@2.4.5: - resolution: {integrity: sha512-aBx2bnqDzVOyNKfsysjA2ms5ZlnjSAW2eG3/L5G/CSujfjLJTJsEw1bGw8kCf04KodQWk1pxlGnZ56CRxiawmg==} - engines: {node: '>= 14'} - hasBin: true - yaml@2.5.0: resolution: {integrity: sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==} engines: {node: '>= 14'} @@ -4680,6 +4701,8 @@ snapshots: '@eslint-stylistic/metadata@2.6.1': {} + '@eslint/compat@1.1.1': {} + '@eslint/config-array@0.17.1': dependencies: '@eslint/object-schema': 2.1.4 @@ -5349,6 +5372,10 @@ snapshots: ansi-escapes@6.2.1: {} + ansi-escapes@7.0.0: + dependencies: + environment: 1.1.0 + ansi-regex@5.0.1: {} ansi-regex@6.0.1: {} @@ -5556,9 +5583,9 @@ snapshots: dependencies: restore-cursor: 3.1.0 - cli-cursor@4.0.0: + cli-cursor@5.0.0: dependencies: - restore-cursor: 4.0.0 + restore-cursor: 5.1.0 cli-highlight@2.1.11: dependencies: @@ -5968,6 +5995,8 @@ snapshots: env-paths@3.0.0: {} + environment@1.1.0: {} + error-ex@1.3.2: dependencies: is-arrayish: 0.2.1 @@ -6261,7 +6290,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-n@17.10.1(eslint@9.8.0): + eslint-plugin-n@17.10.2(eslint@9.8.0): dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@9.8.0) enhanced-resolve: 5.17.0 @@ -7222,7 +7251,7 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 - lilconfig@3.1.1: {} + lilconfig@3.1.2: {} lines-and-columns@1.2.4: {} @@ -7230,28 +7259,28 @@ snapshots: dependencies: uc.micro: 2.1.0 - lint-staged@15.2.7: + lint-staged@15.2.8: dependencies: chalk: 5.3.0 commander: 12.1.0 debug: 4.3.6 execa: 8.0.1 - lilconfig: 3.1.1 - listr2: 8.2.1 + lilconfig: 3.1.2 + listr2: 8.2.4 micromatch: 4.0.7 pidtree: 0.6.0 string-argv: 0.3.2 - yaml: 2.4.5 + yaml: 2.5.0 transitivePeerDependencies: - supports-color - listr2@8.2.1: + listr2@8.2.4: dependencies: cli-truncate: 4.0.0 colorette: 2.0.20 eventemitter3: 5.0.1 - log-update: 6.0.0 - rfdc: 1.3.1 + log-update: 6.1.0 + rfdc: 1.4.1 wrap-ansi: 9.0.0 load-json-file@4.0.0: @@ -7322,10 +7351,10 @@ snapshots: chalk: 4.1.2 is-unicode-supported: 0.1.0 - log-update@6.0.0: + log-update@6.1.0: dependencies: - ansi-escapes: 6.2.1 - cli-cursor: 4.0.0 + ansi-escapes: 7.0.0 + cli-cursor: 5.0.0 slice-ansi: 7.1.0 strip-ansi: 7.1.0 wrap-ansi: 9.0.0 @@ -7424,6 +7453,8 @@ snapshots: mimic-fn@4.0.0: {} + mimic-function@5.0.1: {} + min-indent@1.0.1: {} minimatch@10.0.1: @@ -7558,6 +7589,10 @@ snapshots: dependencies: mimic-fn: 4.0.0 + onetime@7.0.0: + dependencies: + mimic-function: 5.0.1 + optionator@0.9.4: dependencies: deep-is: 0.1.4 @@ -7894,14 +7929,14 @@ snapshots: onetime: 5.1.2 signal-exit: 3.0.7 - restore-cursor@4.0.0: + restore-cursor@5.1.0: dependencies: - onetime: 5.1.2 - signal-exit: 3.0.7 + onetime: 7.0.0 + signal-exit: 4.1.0 reusify@1.0.4: {} - rfdc@1.3.1: {} + rfdc@1.4.1: {} rimraf@6.0.1: dependencies: @@ -8553,8 +8588,6 @@ snapshots: lodash: 4.17.21 yaml: 2.5.0 - yaml@2.4.5: {} - yaml@2.5.0: {} yargs-parser@20.2.9: {} diff --git a/rollup.config.ts b/rollup.config.ts index 86e93d59..d0f1770e 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -1,5 +1,5 @@ import { rollupPlugin as rollupPluginDeassert } from "deassert"; -import { type RollupOptions } from "rollup"; +import type { RollupOptions } from "rollup"; import rollupPluginTs from "rollup-plugin-ts"; import pkg from "./package.json" with { type: "json" }; diff --git a/scripts/typegen.ts b/scripts/typegen.ts index 0973629f..e72613cf 100644 --- a/scripts/typegen.ts +++ b/scripts/typegen.ts @@ -44,7 +44,9 @@ const configs = (await combine( mode: "none", }), ignores({ + projectRoot: process.cwd(), ignores: [], + ignoreFiles: [], }), imports({ stylistic: false, diff --git a/src/configs/comments.ts b/src/configs/comments.ts index d8e403e7..28d557c2 100644 --- a/src/configs/comments.ts +++ b/src/configs/comments.ts @@ -1,6 +1,6 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; -import { type FlatConfigItem } from "../types"; +import type { FlatConfigItem } from "../types"; import { loadPackages } from "../utils"; export async function comments(): Promise { diff --git a/src/configs/formatters.ts b/src/configs/formatters.ts index 5aacf2bd..30e23c84 100644 --- a/src/configs/formatters.ts +++ b/src/configs/formatters.ts @@ -1,6 +1,6 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; import { isPackageExists } from "local-pkg"; -import { type Options as PrettierOptions } from "prettier"; +import type { Options as PrettierOptions } from "prettier"; import { GLOB_CSS, @@ -19,10 +19,10 @@ import { GLOB_TSX, GLOB_YAML, } from "../globs"; -import { - type FlatConfigItem, - type OptionsFormatters, - type StylisticConfig, +import type { + FlatConfigItem, + OptionsFormatters, + StylisticConfig, } from "../types"; import { loadPackages, parserPlain } from "../utils"; diff --git a/src/configs/functional.ts b/src/configs/functional.ts index ceacbfb8..bf4230f8 100644 --- a/src/configs/functional.ts +++ b/src/configs/functional.ts @@ -1,10 +1,10 @@ -import { - type FlatConfigItem, - type OptionsFunctional, - type OptionsMode, - type OptionsOverrides, - type OptionsTypeScriptParserOptions, - type RequiredOptionsStylistic, +import type { + FlatConfigItem, + OptionsFunctional, + OptionsMode, + OptionsOverrides, + OptionsTypeScriptParserOptions, + RequiredOptionsStylistic, } from "../types"; import { loadPackages } from "../utils"; diff --git a/src/configs/ignores.ts b/src/configs/ignores.ts index ddde260a..14dc80e9 100644 --- a/src/configs/ignores.ts +++ b/src/configs/ignores.ts @@ -1,18 +1,54 @@ +import assert from "node:assert/strict"; +import fs from "node:fs/promises"; +import path from "node:path"; + import { GLOB_EXCLUDE } from "../globs"; -import { type FlatConfigItem, type OptionsIgnores } from "../types"; +import type { + FlatConfigItem, + OptionsIgnoreFiles, + OptionsIgnores, + OptionsProjectRoot, +} from "../types"; +import { loadPackages } from "../utils"; + +export async function ignores( + options: Readonly< + { ignores: OptionsIgnores } & OptionsProjectRoot & OptionsIgnoreFiles + >, +): Promise { + const { ignoreFiles, ignores: ignoresOptions, projectRoot } = options; -export function ignores( - options: Readonly<{ ignores: OptionsIgnores }>, -): FlatConfigItem[] { - const ignoresOptions = options.ignores; + const includeIgnoreFile = + ignoreFiles.length === 0 + ? undefined + : await loadPackages(["@eslint/compat"]).then( + ([p]) => (p as typeof import("@eslint/compat")).includeIgnoreFile, + ); const [extend, files] = Array.isArray(ignoresOptions) ? [true, ignoresOptions] : [ignoresOptions.extend, ignoresOptions.files]; + const ignoreConfig = { + ignores: extend ? [...GLOB_EXCLUDE, ...files] : [...files], + }; + + const ignoreFileConfigs = await Promise.all( + ignoreFiles.map((file) => { + assert(includeIgnoreFile !== undefined); + const filePath = path.resolve(projectRoot, file); + return fs + .access(filePath) + .then(() => includeIgnoreFile(filePath)) + .catch(() => { + console.warn(`Ignore file "${filePath}" not found.`); + return null; + }); + }), + ); + return [ - { - ignores: extend ? [...GLOB_EXCLUDE, ...files] : [...files], - }, + ignoreConfig, + ...ignoreFileConfigs.filter((v: T | null): v is T => v !== null), ]; } diff --git a/src/configs/imports.ts b/src/configs/imports.ts index 5ceb30f9..d0b6a4b5 100644 --- a/src/configs/imports.ts +++ b/src/configs/imports.ts @@ -1,10 +1,10 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; import { GLOB_DTS, GLOB_MJS, GLOB_MTS, GLOB_TS, GLOB_TSX } from "../globs"; -import { - type FlatConfigItem, - type OptionsTypeScriptParserOptions, - type RequiredOptionsStylistic, +import type { + FlatConfigItem, + OptionsTypeScriptParserOptions, + RequiredOptionsStylistic, } from "../types"; import { loadPackages } from "../utils"; @@ -49,7 +49,7 @@ export async function imports( }, }, rules: { - "import/consistent-type-specifier-style": ["error", "prefer-inline"], + // "import/consistent-type-specifier-style": ["error", "prefer-inline"], -- using ts/consistent-type-imports instead "import/default": "error", // "import/dynamic-import-chunkname": "off", "import/export": "error", @@ -175,7 +175,7 @@ export async function imports( "import/default": "off", "import/namespace": "off", - // "ts/no-import-type-side-effects": "off", + "ts/no-import-type-side-effects": "error", "ts/consistent-type-imports": [ stylisticEnforcement, { diff --git a/src/configs/in-editor.ts b/src/configs/in-editor.ts index af439aa3..0f13b825 100644 --- a/src/configs/in-editor.ts +++ b/src/configs/in-editor.ts @@ -1,4 +1,4 @@ -import { type FlatConfigItem } from "../types"; +import type { FlatConfigItem } from "../types"; export function inEditor(): FlatConfigItem[] { return [ diff --git a/src/configs/javascript.ts b/src/configs/javascript.ts index eff1c6cc..e28c30f1 100644 --- a/src/configs/javascript.ts +++ b/src/configs/javascript.ts @@ -1,9 +1,9 @@ import globals from "globals"; -import { - type FlatConfigItem, - type OptionsFunctional, - type OptionsOverrides, +import type { + FlatConfigItem, + OptionsFunctional, + OptionsOverrides, } from "../types"; const useNumberIsFinite = "Please use Number.isFinite instead"; diff --git a/src/configs/jsdoc.ts b/src/configs/jsdoc.ts index 767116b6..40a22cac 100644 --- a/src/configs/jsdoc.ts +++ b/src/configs/jsdoc.ts @@ -1,6 +1,6 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; -import { type FlatConfigItem, type RequiredOptionsStylistic } from "../types"; +import type { FlatConfigItem, RequiredOptionsStylistic } from "../types"; import { loadPackages } from "../utils"; export async function jsdoc( diff --git a/src/configs/jsonc.ts b/src/configs/jsonc.ts index 02598189..feae602c 100644 --- a/src/configs/jsonc.ts +++ b/src/configs/jsonc.ts @@ -1,10 +1,10 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; -import { - type FlatConfigItem, - type OptionsFiles, - type OptionsOverrides, - type RequiredOptionsStylistic, +import type { + FlatConfigItem, + OptionsFiles, + OptionsOverrides, + RequiredOptionsStylistic, } from "../types"; import { loadPackages } from "../utils"; diff --git a/src/configs/markdown.ts b/src/configs/markdown.ts index 7b891100..83f4bc40 100644 --- a/src/configs/markdown.ts +++ b/src/configs/markdown.ts @@ -1,4 +1,4 @@ -import { type ESLint, type Linter } from "eslint"; +import type { ESLint, Linter } from "eslint"; import { mergeProcessors, processorPassThrough } from "eslint-merge-processors"; import { @@ -6,12 +6,12 @@ import { GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, } from "../globs"; -import { - type FlatConfigItem, - type OptionsComponentExts, - type OptionsFiles, - type OptionsOverrides, - type OptionsTypeRequiredRules, +import type { + FlatConfigItem, + OptionsComponentExts, + OptionsFiles, + OptionsOverrides, + OptionsTypeRequiredRules, } from "../types"; import { interopDefault, loadPackages, parserPlain } from "../utils"; diff --git a/src/configs/node.ts b/src/configs/node.ts index 5275e439..0ce3b9f4 100644 --- a/src/configs/node.ts +++ b/src/configs/node.ts @@ -1,7 +1,7 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; import { GLOB_DTS, GLOB_MJS, GLOB_TS, GLOB_TSX } from "../globs"; -import { type FlatConfigItem } from "../types"; +import type { FlatConfigItem } from "../types"; import { loadPackages } from "../utils"; export async function node(): Promise { diff --git a/src/configs/overrides.ts b/src/configs/overrides.ts index 17505bd8..9eda5f6d 100644 --- a/src/configs/overrides.ts +++ b/src/configs/overrides.ts @@ -1,5 +1,5 @@ import { GLOB_DTS, GLOB_SRC, GLOB_SRC_EXT, GLOB_TYPINGS } from "../globs"; -import { type FlatConfigItem } from "../types"; +import type { FlatConfigItem } from "../types"; import { interopDefault } from "../utils"; export async function overrides(): Promise { diff --git a/src/configs/promise.ts b/src/configs/promise.ts index 794fd7ef..db34d1bd 100644 --- a/src/configs/promise.ts +++ b/src/configs/promise.ts @@ -1,6 +1,6 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; -import { type FlatConfigItem } from "../types"; +import type { FlatConfigItem } from "../types"; import { loadPackages } from "../utils"; export async function promise(): Promise { diff --git a/src/configs/regexp.ts b/src/configs/regexp.ts index 19326791..da3d5a33 100644 --- a/src/configs/regexp.ts +++ b/src/configs/regexp.ts @@ -1,6 +1,6 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; -import { type FlatConfigItem } from "../types"; +import type { FlatConfigItem } from "../types"; import { loadPackages } from "../utils"; export async function regexp(): Promise { diff --git a/src/configs/sonar.ts b/src/configs/sonar.ts index 386fe288..95012558 100644 --- a/src/configs/sonar.ts +++ b/src/configs/sonar.ts @@ -1,6 +1,6 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; -import { type FlatConfigItem, type OptionsFunctional } from "../types"; +import type { FlatConfigItem, OptionsFunctional } from "../types"; import { loadPackages } from "../utils"; export async function sonar( diff --git a/src/configs/sort.ts b/src/configs/sort.ts index 7ac1448b..4bd391ef 100644 --- a/src/configs/sort.ts +++ b/src/configs/sort.ts @@ -1,4 +1,4 @@ -import { type FlatConfigItem } from "../types"; +import type { FlatConfigItem } from "../types"; /** * Sort tsconfig.json diff --git a/src/configs/stylistic.ts b/src/configs/stylistic.ts index 4bac9992..f6070d71 100644 --- a/src/configs/stylistic.ts +++ b/src/configs/stylistic.ts @@ -1,11 +1,11 @@ -import { type StylisticCustomizeOptions } from "@stylistic/eslint-plugin"; -import { type ESLint } from "eslint"; +import type { StylisticCustomizeOptions } from "@stylistic/eslint-plugin"; +import type { ESLint } from "eslint"; -import { - type FlatConfigItem, - type OptionsHasTypeScript, - type OptionsOverrides, - type StylisticConfig, +import type { + FlatConfigItem, + OptionsHasTypeScript, + OptionsOverrides, + StylisticConfig, } from "../types"; import { loadPackages } from "../utils"; diff --git a/src/configs/test.ts b/src/configs/test.ts index 5af52530..183dd7b7 100644 --- a/src/configs/test.ts +++ b/src/configs/test.ts @@ -1,10 +1,6 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; -import { - type FlatConfigItem, - type OptionsFiles, - type OptionsOverrides, -} from "../types"; +import type { FlatConfigItem, OptionsFiles, OptionsOverrides } from "../types"; import { interopDefault, loadPackages } from "../utils"; export async function test( diff --git a/src/configs/toml.ts b/src/configs/toml.ts index 2de78088..8924d731 100644 --- a/src/configs/toml.ts +++ b/src/configs/toml.ts @@ -1,10 +1,10 @@ -import { type ESLint, type Linter } from "eslint"; +import type { ESLint, Linter } from "eslint"; -import { - type FlatConfigItem, - type OptionsFiles, - type OptionsOverrides, - type RequiredOptionsStylistic, +import type { + FlatConfigItem, + OptionsFiles, + OptionsOverrides, + RequiredOptionsStylistic, } from "../types"; import { loadPackages } from "../utils"; diff --git a/src/configs/typescript.ts b/src/configs/typescript.ts index 7b09d7c2..af2116d2 100644 --- a/src/configs/typescript.ts +++ b/src/configs/typescript.ts @@ -1,6 +1,6 @@ import assert from "node:assert/strict"; -import { type ESLint, type Linter } from "eslint"; +import type { ESLint, Linter } from "eslint"; import { GLOB_DTS, @@ -10,16 +10,16 @@ import { GLOB_TS, GLOB_TSX, } from "../globs"; -import { - type FlatConfigItem, - type OptionsComponentExts, - type OptionsFiles, - type OptionsFunctional, - type OptionsMode, - type OptionsOverrides, - type OptionsProjectRoot, - type OptionsTypeScriptParserOptions, - type OptionsTypeScriptUnsafeSeverity, +import type { + FlatConfigItem, + OptionsComponentExts, + OptionsFiles, + OptionsFunctional, + OptionsMode, + OptionsOverrides, + OptionsProjectRoot, + OptionsTypeScriptParserOptions, + OptionsTypeScriptUnsafeSeverity, } from "../types"; import { loadPackages } from "../utils"; diff --git a/src/configs/unicorn.ts b/src/configs/unicorn.ts index a565b5eb..ee0f598b 100644 --- a/src/configs/unicorn.ts +++ b/src/configs/unicorn.ts @@ -1,6 +1,6 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; -import { type FlatConfigItem } from "../types"; +import type { FlatConfigItem } from "../types"; import { loadPackages } from "../utils"; export async function unicorn(): Promise { diff --git a/src/configs/unocss.ts b/src/configs/unocss.ts index 15a0a8ac..da78eeaa 100644 --- a/src/configs/unocss.ts +++ b/src/configs/unocss.ts @@ -1,6 +1,6 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; -import { type FlatConfigItem, type OptionsUnoCSS } from "../types"; +import type { FlatConfigItem, OptionsUnoCSS } from "../types"; import { loadPackages } from "../utils"; export async function unocss( diff --git a/src/configs/vue.ts b/src/configs/vue.ts index bca6428b..1ebc727b 100644 --- a/src/configs/vue.ts +++ b/src/configs/vue.ts @@ -1,14 +1,14 @@ -import { type ESLint, type Linter } from "eslint"; +import type { ESLint, Linter } from "eslint"; import { mergeProcessors } from "eslint-merge-processors"; -import { - type FlatConfigItem, - type OptionsFiles, - type OptionsHasTypeScript, - type OptionsOverrides, - type OptionsTypeScriptParserOptions, - type OptionsVue, - type RequiredOptionsStylistic, +import type { + FlatConfigItem, + OptionsFiles, + OptionsHasTypeScript, + OptionsOverrides, + OptionsTypeScriptParserOptions, + OptionsVue, + RequiredOptionsStylistic, } from "../types"; import { interopDefault, loadPackages } from "../utils"; diff --git a/src/configs/yaml.ts b/src/configs/yaml.ts index 01cb5665..21eff61d 100644 --- a/src/configs/yaml.ts +++ b/src/configs/yaml.ts @@ -1,10 +1,10 @@ -import { type ESLint } from "eslint"; +import type { ESLint } from "eslint"; -import { - type FlatConfigItem, - type OptionsFiles, - type OptionsOverrides, - type RequiredOptionsStylistic, +import type { + FlatConfigItem, + OptionsFiles, + OptionsOverrides, + RequiredOptionsStylistic, } from "../types"; import { loadPackages } from "../utils"; diff --git a/src/factory.ts b/src/factory.ts index 71dc2d9c..2c9ecc7f 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -47,13 +47,13 @@ import { GLOB_VUE, GLOB_YAML, } from "./globs"; -import { - type Awaitable, - type FlatConfigItem, - type OptionsConfig, - type OptionsTypeScriptParserOptions, - type OptionsTypeScriptShorthands, - type OptionsTypescript, +import type { + Awaitable, + FlatConfigItem, + OptionsConfig, + OptionsTypeScriptParserOptions, + OptionsTypeScriptShorthands, + OptionsTypescript, } from "./types"; const VuePackages = ["vue", "nuxt", "vitepress", "@slidev/cli"]; @@ -91,6 +91,7 @@ export function rsEslint( Boolean(process.env["VIM"]) || Boolean(process.env["NVIM"])), ignores: ignoresOptions, + ignoresFiles: ignoresFilesOptions = [".gitignore"], typescript: typeScriptOptions = isPackageExists("typescript"), unocss: unoCSSOptions = isPackageExists("unocss"), vue: vueOptions = VuePackages.some((i) => isPackageExists(i)), @@ -179,7 +180,9 @@ export function rsEslint( // Base configs m_configs.push( ignores({ + projectRoot, ignores: ignoresOptions ?? [], + ignoreFiles: ignoresFilesOptions, }), javascript({ ...functionalConfigOptions, diff --git a/src/types.ts b/src/types.ts index 38d31244..a8668965 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,13 +1,13 @@ -import { type StylisticCustomizeOptions } from "@stylistic/eslint-plugin"; -import { type ParserOptions } from "@typescript-eslint/parser"; -import { type TSESLint } from "@typescript-eslint/utils"; -import { type ESLint, type Linter } from "eslint"; -import { type Options as VueBlocksOptions } from "eslint-processor-vue-blocks"; -import { type Options as PrettierOptions } from "prettier"; +import type { StylisticCustomizeOptions } from "@stylistic/eslint-plugin"; +import type { ParserOptions } from "@typescript-eslint/parser"; +import type { TSESLint } from "@typescript-eslint/utils"; +import type { ESLint, Linter } from "eslint"; +import type { Options as VueBlocksOptions } from "eslint-processor-vue-blocks"; +import type { Options as PrettierOptions } from "prettier"; -import { type SettingsVueI18nLocaleDir } from "../typings/eslint-plugin-vue-i18n"; +import type { SettingsVueI18nLocaleDir } from "../typings/eslint-plugin-vue-i18n"; -import { type RuleOptions as Rules } from "./typegen"; +import type { RuleOptions as Rules } from "./typegen"; declare module "eslint" { // eslint-disable-next-line ts/no-namespace @@ -183,6 +183,15 @@ export type OptionsProjectRoot = { projectRoot: string; }; +export type OptionsIgnoreFiles = { + /** + * Files that contain ignore patterns. + * + * @default [".gitignore"] + */ + ignoreFiles: string[]; +}; + export type OptionsIgnores = | NonNullable | { @@ -290,6 +299,13 @@ export type OptionsConfig = { autoRenamePlugins?: boolean; ignores?: OptionsIgnores; + + /** + * Files that contain ignore patterns. + * + * @default [".gitignore"] + */ + ignoresFiles?: OptionsIgnoreFiles["ignoreFiles"]; } & OptionsComponentExts; export { type RuleOptions as Rules } from "./typegen"; diff --git a/src/utils.ts b/src/utils.ts index 71f4d6b6..51ff4917 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,9 +1,9 @@ import assert from "node:assert/strict"; -import { type Awaitable } from "eslint-flat-config-utils"; +import type { Awaitable } from "eslint-flat-config-utils"; import { isPackageExists } from "local-pkg"; -import { type FlatConfigItem } from "./types"; +import type { FlatConfigItem } from "./types"; /** * Combine array and non-array configs into a single array. diff --git a/tsconfig.json b/tsconfig.json index 592eb911..3f278c90 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,9 @@ "extends": "./tsconfig.build.json", "compilerOptions": { "allowJs": true, + "noEmit": true, "rootDir": "." + // "isolatedDeclarations": false }, - "include": [".", ".*"] + "include": [".", ".*", "**/*", "**/.*"] } diff --git a/typings/eslint-plugin-vue-i18n.d.ts b/typings/eslint-plugin-vue-i18n.d.ts index 0f33b8b6..387beffa 100644 --- a/typings/eslint-plugin-vue-i18n.d.ts +++ b/typings/eslint-plugin-vue-i18n.d.ts @@ -1,5 +1,4 @@ - -// From https://github.com/intlify/eslint-plugin-vue-i18n/blob/v3.0.0-next.11/lib/types/settings.ts +// From https://github.com/intlify/eslint-plugin-vue-i18n/blob/v3.0.0/lib/types/settings.ts /** * How to determine the locale for localization messages. @@ -28,7 +27,7 @@ export type SettingsVueI18nLocaleDirGlob = string; /** * Specifies a glob and messages format type. */ -export type SettingsVueI18nLocaleDirObject = { +export interface SettingsVueI18nLocaleDirObject { /** * A glob for specifying files that store localization messages of project. */ @@ -47,4 +46,4 @@ export type SettingsVueI18nLocaleDirObject = { * If you omit it, it will be captured from the resource path with the same regular expression pattern as `vue-cli-plugin-i18n`. */ localePattern?: string | RegExp; -}; +}