From 84d1b3ddf0c80030ebffc81677e0fe7edbf3b47c Mon Sep 17 00:00:00 2001 From: Riley Tomasek Date: Sat, 2 Mar 2024 23:28:18 -0500 Subject: [PATCH] Switch back to simple-import-sort plugin The other once has way too many weird edge cases and doesn't sort within import destructures. The simple version is what is used in the TypeScript source repo ESLint config... --- config/core.js | 2 +- config/import.js | 11 ----------- config/typescript.js | 14 ++++++++++++-- index.js | 1 - 4 files changed, 13 insertions(+), 15 deletions(-) delete mode 100644 config/import.js diff --git a/config/core.js b/config/core.js index ac29038..7101e28 100644 --- a/config/core.js +++ b/config/core.js @@ -19,7 +19,7 @@ module.exports = { 'no-duplicate-case': 'warn', 'no-empty-character-class': 'warn', 'no-empty-pattern': 'warn', - 'no-duplicate-imports': 'warn', + 'no-duplicate-imports': 'error', 'no-empty': ['warn', { allowEmptyCatch: true }], 'no-eval': 'error', 'no-ex-assign': 'warn', diff --git a/config/import.js b/config/import.js deleted file mode 100644 index a1955c4..0000000 --- a/config/import.js +++ /dev/null @@ -1,11 +0,0 @@ -/** @type {import('eslint').Linter.Config} */ -module.exports = { - files: ['**/*.{ts,tsx,mts}'], - - plugins: ['simple-import-sort'], - - rules: { - 'simple-import-sort/imports': 'error', - 'simple-import-sort/exports': 'error', - }, -}; diff --git a/config/typescript.js b/config/typescript.js index b4b8f00..99dce98 100644 --- a/config/typescript.js +++ b/config/typescript.js @@ -2,7 +2,7 @@ module.exports = { files: ['**/*.{ts,tsx,mts,cts}'], - plugins: ['@typescript-eslint'], + plugins: ['@typescript-eslint', 'simple-import-sort'], extends: [ 'plugin:@typescript-eslint/recommended', @@ -10,7 +10,9 @@ module.exports = { ], rules: { - // @typescript-eslint/eslint-plugin + 'simple-import-sort/imports': 'error', + 'simple-import-sort/exports': 'error', + '@typescript-eslint/naming-convention': [ 'error', { @@ -74,6 +76,14 @@ module.exports = { 'error', { allowTernary: true }, ], + '@typescript-eslint/consistent-type-imports': [ + 'error', + { + prefer: 'type-imports', + disallowTypeAnnotations: true, + fixStyle: 'inline-type-imports', + }, + ], // Rules enabled in typescript-eslint configs that are not applicable here '@typescript-eslint/ban-ts-comment': 'off', diff --git a/index.js b/index.js index 54e9501..e5fa430 100644 --- a/index.js +++ b/index.js @@ -25,7 +25,6 @@ module.exports = { overrides: [ './config/typescript', - './config/import', './config/react', './config/tests', './config/prettier',