From 057c16abe0c5eb0c97e3c5dcc2522bd4ed00a4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 2 Jul 2024 20:02:22 +0900 Subject: [PATCH] chore: use flat config (#111) --- .eslintignore | 3 --- .eslintrc.cjs | 32 ---------------------- eslint.config.js | 35 ++++++++++++++++++++++++ package.json | 6 +++-- pnpm-lock.yaml | 70 +++++++++++++++++++++++++++++++++++++++++------- 5 files changed, 100 insertions(+), 46 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.cjs create mode 100644 eslint.config.js diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index d6bbde8..0000000 --- a/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -dist -node_modules -test/fixtures/* diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index feb85a0..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,32 +0,0 @@ -module.exports = { - root: true, - parserOptions: { - sourceType: 'module' - }, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:@typescript-eslint/stylistic', - 'plugin:vitest/legacy-recommended', - 'prettier' - ], - rules: { - '@typescript-eslint/member-delimiter-style': 'off', - '@typescript-eslint/consistent-type-imports': 'error', - '@typescript-eslint/consistent-type-definitions': ['error', 'type'] - }, - overrides: [ - { - // root files - files: ['*.{js,cjs}'], - excludedFiles: ['*/**/*.{js,cjs}'], - env: { - node: true - }, - rules: { - '@typescript-eslint/no-var-requires': 'off' - } - } - ], - reportUnusedDisableDirectives: true -} diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..9e960c4 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,35 @@ +// @ts-check + +import eslint from '@eslint/js' +import tseslint from 'typescript-eslint' +import vitest from 'eslint-plugin-vitest' +import eslintConfigPrettier from 'eslint-config-prettier' + +export default tseslint.config( + { + languageOptions: { + sourceType: 'module' + }, + linterOptions: { + reportUnusedDisableDirectives: 'error' + } + }, + eslint.configs.recommended, + ...tseslint.configs.recommended, + ...tseslint.configs.stylistic, + { + rules: { + '@typescript-eslint/member-delimiter-style': 'off', + '@typescript-eslint/consistent-type-imports': 'error', + '@typescript-eslint/consistent-type-definitions': ['error', 'type'] + } + }, + { + files: ['test/**'], + ...vitest.configs.recommended + }, + eslintConfigPrettier, + { + ignores: ['dist/**', 'test/fixtures/**'] + } +) diff --git a/package.json b/package.json index 99e06c3..a7a5f8b 100644 --- a/package.json +++ b/package.json @@ -43,12 +43,13 @@ "devDependencies": { "@changesets/changelog-github": "^0.5.0", "@changesets/cli": "^2.27.1", + "@eslint/js": "^9.1.1", "@polka/url": "^1.0.0-next.25", + "@types/eslint-config-prettier": "^6.11.3", + "@types/eslint__js": "^8.42.3", "@types/fs-extra": "^11.0.4", "@types/node": "^20.12.7", "@types/throttle-debounce": "^5.0.2", - "@typescript-eslint/eslint-plugin": "^7.8.0", - "@typescript-eslint/parser": "^7.8.0", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-vitest": "^0.5.4", @@ -58,6 +59,7 @@ "throttle-debounce": "^5.0.0", "tsup": "^8.0.2", "typescript": "^5.4.5", + "typescript-eslint": "^7.8.0", "vite": "^5.2.10", "vitest": "^1.5.3", "vitest-github-actions-reporter": "^0.11.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7a7569f..c9f40d4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,9 +27,18 @@ importers: '@changesets/cli': specifier: ^2.27.1 version: 2.27.1 + '@eslint/js': + specifier: ^9.1.1 + version: 9.1.1 '@polka/url': specifier: ^1.0.0-next.25 version: 1.0.0-next.25 + '@types/eslint-config-prettier': + specifier: ^6.11.3 + version: 6.11.3 + '@types/eslint__js': + specifier: ^8.42.3 + version: 8.42.3 '@types/fs-extra': specifier: ^11.0.4 version: 11.0.4 @@ -39,12 +48,6 @@ importers: '@types/throttle-debounce': specifier: ^5.0.2 version: 5.0.2 - '@typescript-eslint/eslint-plugin': - specifier: ^7.8.0 - version: 7.8.0(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5) - '@typescript-eslint/parser': - specifier: ^7.8.0 - version: 7.8.0(eslint@8.57.0)(typescript@5.4.5) eslint: specifier: ^8.57.0 version: 8.57.0 @@ -53,7 +56,7 @@ importers: version: 9.1.0(eslint@8.57.0) eslint-plugin-vitest: specifier: ^0.5.4 - version: 0.5.4(@typescript-eslint/eslint-plugin@7.8.0(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5)(vitest@1.5.3(@types/node@20.12.7)) + version: 0.5.4(eslint@8.57.0)(typescript@5.4.5)(vitest@1.5.3(@types/node@20.12.7)) mrmime: specifier: ^2.0.0 version: 2.0.0 @@ -72,6 +75,9 @@ importers: typescript: specifier: ^5.4.5 version: 5.4.5 + typescript-eslint: + specifier: ^7.8.0 + version: 7.8.0(eslint@8.57.0)(typescript@5.4.5) vite: specifier: ^5.2.10 version: 5.2.10(@types/node@20.12.7) @@ -465,6 +471,10 @@ packages: resolution: {integrity: sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + '@eslint/js@9.1.1': + resolution: {integrity: sha512-5WoDz3Y19Bg2BnErkZTp0en+c/i9PvgFS7MBe1+m60HjFr0hrphlAGp4yzI7pxpt4xShln4ZyYp4neJm8hmOkQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@humanwhocodes/config-array@0.11.14': resolution: {integrity: sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==} engines: {node: '>=10.10.0'} @@ -650,6 +660,15 @@ packages: '@sinclair/typebox@0.27.8': resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} + '@types/eslint-config-prettier@6.11.3': + resolution: {integrity: sha512-3wXCiM8croUnhg9LdtZUJQwNcQYGWxxdOWDjPe1ykCqJFPVpzAKfs/2dgSoCtAvdPeaponcWPI7mPcGGp9dkKQ==} + + '@types/eslint@8.56.10': + resolution: {integrity: sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==} + + '@types/eslint__js@8.42.3': + resolution: {integrity: sha512-alfG737uhmPdnvkrLdZLcEKJ/B8s9Y4hrZ+YAdzUeoArBlSUERA2E87ROfOaS4jd/C45fzOoZzidLc1IPwLqOw==} + '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} @@ -2214,6 +2233,16 @@ packages: typed-array-length@1.0.4: resolution: {integrity: sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==} + typescript-eslint@7.8.0: + resolution: {integrity: sha512-sheFG+/D8N/L7gC3WT0Q8sB97Nm573Yfr+vZFzl/4nBdYcmviBPtwGSX9TJ7wpVg28ocerKVOt+k2eGmHzcgVA==} + engines: {node: ^18.18.0 || >=20.0.0} + peerDependencies: + eslint: ^8.56.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + typescript@5.4.5: resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} engines: {node: '>=14.17'} @@ -2760,6 +2789,8 @@ snapshots: '@eslint/js@8.57.0': {} + '@eslint/js@9.1.1': {} + '@humanwhocodes/config-array@0.11.14': dependencies: '@humanwhocodes/object-schema': 2.0.2 @@ -2902,6 +2933,17 @@ snapshots: '@sinclair/typebox@0.27.8': {} + '@types/eslint-config-prettier@6.11.3': {} + + '@types/eslint@8.56.10': + dependencies: + '@types/estree': 1.0.5 + '@types/json-schema': 7.0.15 + + '@types/eslint__js@8.42.3': + dependencies: + '@types/eslint': 8.56.10 + '@types/estree@1.0.5': {} '@types/fs-extra@11.0.4': @@ -3445,12 +3487,11 @@ snapshots: dependencies: eslint: 8.57.0 - eslint-plugin-vitest@0.5.4(@typescript-eslint/eslint-plugin@7.8.0(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5)(vitest@1.5.3(@types/node@20.12.7)): + eslint-plugin-vitest@0.5.4(eslint@8.57.0)(typescript@5.4.5)(vitest@1.5.3(@types/node@20.12.7)): dependencies: '@typescript-eslint/utils': 7.8.0(eslint@8.57.0)(typescript@5.4.5) eslint: 8.57.0 optionalDependencies: - '@typescript-eslint/eslint-plugin': 7.8.0(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5) vitest: 1.5.3(@types/node@20.12.7) transitivePeerDependencies: - supports-color @@ -4613,6 +4654,17 @@ snapshots: for-each: 0.3.3 is-typed-array: 1.1.12 + typescript-eslint@7.8.0(eslint@8.57.0)(typescript@5.4.5): + dependencies: + '@typescript-eslint/eslint-plugin': 7.8.0(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/parser': 7.8.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/utils': 7.8.0(eslint@8.57.0)(typescript@5.4.5) + eslint: 8.57.0 + optionalDependencies: + typescript: 5.4.5 + transitivePeerDependencies: + - supports-color + typescript@5.4.5: {} ufo@1.3.2: {}