Skip to content

Commit 874ef3b

Browse files
authored
Lint: Add eslint import plugin (#5955)
## Summary Adds the linter, turns on the recommended and a few extra rules, fixes existing violations. Doesn't prohibit `../../...` imports yet, that'll be it's own PR. ## Changes - **What**: Consistent and fixable imports - **Dependencies**: The plugin and parser ## Review Focus How do you feel about the recommended rules? What about the extra ones? [Any more](https://github.com/un-ts/eslint-plugin-import-x?tab=readme-ov-file#rules) you'd want to turn on? ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5955-Lint-Add-eslint-import-plugin-2856d73d3650819985c0fb9ca3fa94b0) by [Unito](https://www.unito.io)
1 parent 45ebc59 commit 874ef3b

File tree

149 files changed

+1755
-483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+1755
-483
lines changed

eslint.config.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
22
import pluginJs from '@eslint/js'
33
import pluginI18n from '@intlify/eslint-plugin-vue-i18n'
4+
import { importX } from 'eslint-plugin-import-x'
45
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
56
import storybook from 'eslint-plugin-storybook'
67
import unusedImports from 'eslint-plugin-unused-imports'
@@ -47,6 +48,12 @@ export default defineConfig([
4748
sourceType: 'module',
4849
extraFileExtensions
4950
}
51+
},
52+
settings: {
53+
'import/resolver': {
54+
typescript: true,
55+
node: true
56+
}
5057
}
5158
},
5259
{
@@ -65,13 +72,24 @@ export default defineConfig([
6572
sourceType: 'module',
6673
extraFileExtensions
6774
}
75+
},
76+
settings: {
77+
'import/resolver': {
78+
typescript: true,
79+
node: true
80+
}
6881
}
6982
},
7083
pluginJs.configs.recommended,
84+
// eslint-disable-next-line import-x/no-named-as-default-member
7185
tseslint.configs.recommended,
7286
pluginVue.configs['flat/recommended'],
7387
eslintPluginPrettierRecommended,
7488
storybook.configs['flat/recommended'],
89+
// @ts-expect-error Bad types in the plugin
90+
importX.flatConfigs.recommended,
91+
// @ts-expect-error Bad types in the plugin
92+
importX.flatConfigs.typescript,
7593
{
7694
plugins: {
7795
'unused-imports': unusedImports,
@@ -91,6 +109,9 @@ export default defineConfig([
91109
allowInterfaces: 'always'
92110
}
93111
],
112+
'import-x/consistent-type-specifier-style': ['error', 'prefer-top-level'],
113+
'import-x/no-useless-path-segments': 'error',
114+
'import-x/no-relative-packages': 'error',
94115
'unused-imports/no-unused-imports': 'error',
95116
'no-console': ['error', { allow: ['warn', 'error'] }],
96117
'vue/no-v-html': 'off',

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"cross-env": "catalog:",
7070
"eslint": "catalog:",
7171
"eslint-config-prettier": "catalog:",
72+
"eslint-import-resolver-typescript": "catalog:",
73+
"eslint-plugin-import-x": "catalog:",
7274
"eslint-plugin-prettier": "catalog:",
7375
"eslint-plugin-storybook": "catalog:",
7476
"eslint-plugin-unused-imports": "catalog:",

0 commit comments

Comments
 (0)