Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint): add auto-fix for unused imports and vars #106

Merged
merged 1 commit into from
Dec 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.