diff --git a/.changeset/stupid-bats-fix.md b/.changeset/stupid-bats-fix.md new file mode 100644 index 0000000..509f7db --- /dev/null +++ b/.changeset/stupid-bats-fix.md @@ -0,0 +1,5 @@ +--- +'@mheob/eslint-config': minor +--- + +add auto-fix for unused imports and vars diff --git a/.changeset/wet-donkeys-confess.md b/.changeset/wet-donkeys-confess.md new file mode 100644 index 0000000..18be469 --- /dev/null +++ b/.changeset/wet-donkeys-confess.md @@ -0,0 +1,5 @@ +--- +'@mheob/eslint-config': patch +--- + +bump `eslint-config-next` to `13.1.0` diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 116a52b..bf0f8f2 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -51,14 +51,15 @@ "dependencies": { "@typescript-eslint/eslint-plugin": "^5.47.0", "@typescript-eslint/parser": "^5.47.0", - "eslint-config-next": "^13.0.7", + "eslint-config-next": "^13.1.0", "eslint-config-prettier": "^8.5.0", "eslint-import-resolver-typescript": "^3.5.2", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-react": "^7.31.11", "eslint-plugin-simple-import-sort": "^8.0.0", - "eslint-plugin-unicorn": "^45.0.2" + "eslint-plugin-unicorn": "^45.0.2", + "eslint-plugin-unused-imports": "^2.0.0" }, "devDependencies": { "@mheob/tsconfig": "workspace:*", diff --git a/packages/eslint-config/src/base.ts b/packages/eslint-config/src/base.ts index fdb8214..c12fcab 100644 --- a/packages/eslint-config/src/base.ts +++ b/packages/eslint-config/src/base.ts @@ -1,7 +1,7 @@ import type { Linter } from 'eslint'; const config: Linter.Config = { - plugins: ['@typescript-eslint', 'simple-import-sort'], + plugins: ['@typescript-eslint', 'simple-import-sort', 'unused-imports'], extends: [ 'eslint:recommended', 'plugin:unicorn/recommended', @@ -19,7 +19,6 @@ const config: Linter.Config = { 'prettier/prettier': 'warn', 'no-console': ['warn', { allow: ['warn', 'error'] }], 'no-implicit-coercion': ['error', { allow: ['!!', '+', '~'] }], - 'no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], 'simple-import-sort/imports': [ 'error', { @@ -57,6 +56,10 @@ const config: Linter.Config = { }, }, ], + // Disable the default rule so that `unused-imports` can auto-fix + 'no-unused-vars': 'off', + 'unused-imports/no-unused-imports': 'warn', + 'unused-imports/no-unused-vars': ['warn', { varsIgnorePattern: '^_', argsIgnorePattern: '^_' }], }, overrides: [ { @@ -76,10 +79,8 @@ const config: Linter.Config = { 'warn', { allowExpressions: true, allowTypedFunctionExpressions: true }, ], - '@typescript-eslint/no-unused-vars': [ - 'warn', - { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, - ], + // Disable the default rule so that `unused-imports` can auto-fix + '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/quotes': ['warn', 'single', { avoidEscape: true }], }, }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6d6c3ca..8ae3bd5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,7 +41,7 @@ importers: '@typescript-eslint/eslint-plugin': ^5.47.0 '@typescript-eslint/parser': ^5.47.0 eslint: ^8.30.0 - eslint-config-next: ^13.0.7 + eslint-config-next: ^13.1.0 eslint-config-prettier: ^8.5.0 eslint-import-resolver-typescript: ^3.5.2 eslint-plugin-import: ^2.26.0 @@ -49,12 +49,13 @@ importers: eslint-plugin-react: ^7.31.11 eslint-plugin-simple-import-sort: ^8.0.0 eslint-plugin-unicorn: ^45.0.2 + eslint-plugin-unused-imports: ^2.0.0 prettier: ^2.8.1 typescript: ^4.9.4 dependencies: '@typescript-eslint/eslint-plugin': 5.47.0_ncmi6noazr3nzas7jxykisekym '@typescript-eslint/parser': 5.47.0_lzzuuodtsqwxnvqeq4g4likcqa - eslint-config-next: 13.0.7_lzzuuodtsqwxnvqeq4g4likcqa + eslint-config-next: 13.1.0_lzzuuodtsqwxnvqeq4g4likcqa eslint-config-prettier: 8.5.0_eslint@8.30.0 eslint-import-resolver-typescript: 3.5.2_2lbwmhbr7bncddqbzzpg77o75m eslint-plugin-import: 2.26.0_p6eswnf3xl3aaa2djfyukgz5eq @@ -62,6 +63,7 @@ importers: eslint-plugin-react: 7.31.11_eslint@8.30.0 eslint-plugin-simple-import-sort: 8.0.0_eslint@8.30.0 eslint-plugin-unicorn: 45.0.2_eslint@8.30.0 + eslint-plugin-unused-imports: 2.0.0_juver2u3xbiwnjfu6d55vmnoem devDependencies: '@mheob/tsconfig': link:../tsconfig '@types/eslint': 8.4.10 @@ -106,8 +108,8 @@ packages: chalk: 2.4.2 js-tokens: 4.0.0 - /@babel/runtime-corejs3/7.20.6: - resolution: {integrity: sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==} + /@babel/runtime-corejs3/7.20.7: + resolution: {integrity: sha512-jr9lCZ4RbRQmCR28Q8U8Fu49zvFqLxTY9AMOUz+iyMohMoAgpEcVxY+wJNay99oXOpOcCTODkk70NDN2aaJEeg==} engines: {node: '>=6.9.0'} dependencies: core-js-pure: 3.26.1 @@ -119,6 +121,14 @@ packages: engines: {node: '>=6.9.0'} dependencies: regenerator-runtime: 0.13.11 + dev: true + + /@babel/runtime/7.20.7: + resolution: {integrity: sha512-UF0tvkUtxwAgZ5W/KrkHf0Rn0fdnLDU9ScxBrEVNUprE/MzirjK4MJUX1/BVDv00Sv8cljtukVK1aky++X1SjQ==} + engines: {node: '>=6.9.0'} + dependencies: + regenerator-runtime: 0.13.11 + dev: false /@changesets/apply-release-plan/6.1.3: resolution: {integrity: sha512-ECDNeoc3nfeAe1jqJb5aFQX7CqzQhD2klXRez2JDb/aVpGUbX673HgKrnrgJRuQR/9f2TtLoYIzrGB9qwD77mg==} @@ -577,8 +587,8 @@ packages: - encoding dev: true - /@next/eslint-plugin-next/13.0.7: - resolution: {integrity: sha512-Q/Z0V3D3UpKhhzFU6/s17wD4rqJ+ZDGded8UpqNyzX1nUdD+/PnsZexPhSIZ2Yf/c8QESeirmJVRb3eAfCQkRQ==} + /@next/eslint-plugin-next/13.1.0: + resolution: {integrity: sha512-LGh0iqcEwxs0HmEK96cXXuhofcOGSUGl8Zms279JW8Zq/6GJkXo87gtRpfJrwD+a77nEIdRaORPM91Us3xW0Qw==} dependencies: glob: 7.1.7 dev: false @@ -926,8 +936,8 @@ packages: resolution: {integrity: sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==} engines: {node: '>=6.0'} dependencies: - '@babel/runtime': 7.20.6 - '@babel/runtime-corejs3': 7.20.6 + '@babel/runtime': 7.20.7 + '@babel/runtime-corejs3': 7.20.7 dev: false /array-ify/1.0.0: @@ -1485,8 +1495,8 @@ packages: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} - /eslint-config-next/13.0.7_lzzuuodtsqwxnvqeq4g4likcqa: - resolution: {integrity: sha512-X7DB7iDJ9iHi5DAZbnFdWm4M0dwarj5h5y6Vpm9INCYzFgAwSWslq3v0qjYEjtUO5IQ8n1WK6IU5FkOQ2HBhOA==} + /eslint-config-next/13.1.0_lzzuuodtsqwxnvqeq4g4likcqa: + resolution: {integrity: sha512-UdZm8GTR8PWys1dw+gJY+aLR/etkbTTsrRxiQ57nxqAE4Fw6PGZ2prLjqV6IhNkFve3c8ZgbCrUolfGad2mryA==} peerDependencies: eslint: ^7.23.0 || ^8.0.0 typescript: '>=3.3.1' @@ -1494,7 +1504,7 @@ packages: typescript: optional: true dependencies: - '@next/eslint-plugin-next': 13.0.7 + '@next/eslint-plugin-next': 13.1.0 '@rushstack/eslint-patch': 1.2.0 '@typescript-eslint/parser': 5.47.0_lzzuuodtsqwxnvqeq4g4likcqa eslint: 8.30.0 @@ -1615,7 +1625,7 @@ packages: peerDependencies: eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 dependencies: - '@babel/runtime': 7.20.6 + '@babel/runtime': 7.20.7 aria-query: 4.2.2 array-includes: 3.1.6 ast-types-flow: 0.0.7 @@ -1714,6 +1724,26 @@ packages: strip-indent: 3.0.0 dev: false + /eslint-plugin-unused-imports/2.0.0_juver2u3xbiwnjfu6d55vmnoem: + resolution: {integrity: sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + '@typescript-eslint/eslint-plugin': ^5.0.0 + eslint: ^8.0.0 + peerDependenciesMeta: + '@typescript-eslint/eslint-plugin': + optional: true + dependencies: + '@typescript-eslint/eslint-plugin': 5.47.0_ncmi6noazr3nzas7jxykisekym + eslint: 8.30.0 + eslint-rule-composer: 0.3.0 + dev: false + + /eslint-rule-composer/0.3.0: + resolution: {integrity: sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==} + engines: {node: '>=4.0.0'} + dev: false + /eslint-scope/5.1.1: resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} engines: {node: '>=8.0.0'}