Skip to content

Commit

Permalink
feat(eslint): add auto-fix for unused imports and vars
Browse files Browse the repository at this point in the history
Also update all dependecies.
  • Loading branch information
mheob committed Dec 24, 2022
1 parent a61b6d2 commit d5271ec
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/stupid-bats-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mheob/eslint-config': minor
---

add auto-fix for unused imports and vars
5 changes: 5 additions & 0 deletions .changeset/wet-donkeys-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mheob/eslint-config': patch
---

bump `eslint-config-next` to `13.1.0`
5 changes: 3 additions & 2 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
13 changes: 7 additions & 6 deletions packages/eslint-config/src/base.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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',
{
Expand Down Expand Up @@ -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: [
{
Expand All @@ -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 }],
},
},
Expand Down
54 changes: 42 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d5271ec

Please sign in to comment.