Last active
May 23, 2024 16:31
-
-
Save karlhorky/b78fdf61c9d284986177daa04430a9a0 to your computer and use it in GitHub Desktop.
Migrate from eslint-plugin-import to eslint-plugin-import-x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Migrate from eslint-plugin-import (no ESLint v9 support, multiple issues and missing features) | |
// to eslint-plugin-import-x | |
// | |
// - https://www.npmjs.com/package/eslint-plugin-import | |
// - https://www.npmjs.com/package/eslint-plugin-import-x | |
// First, install `eslint-plugin-import-x` (and for TypeScript support, `@typescript-eslint/parser`) | |
-import eslintImport from 'eslint-plugin-import'; | |
+import eslintImportX from 'eslint-plugin-import-x'; | |
/** @type {import('@typescript-eslint/utils/ts-eslint').FlatConfig.ConfigArray} */ | |
const configArray = [ | |
{ | |
plugins: { | |
- import: eslintImport, | |
+ 'import-x': eslintImportX, | |
}, | |
settings: { | |
+ 'import-x/parsers': { | |
+ '@typescript-eslint/parser': ['.ts', '.tsx'], | |
+ }, | |
+ 'import-x/resolver': { | |
+ typescript: true, | |
+ node: true, | |
+ }, | |
}, | |
rules: { | |
// Error on imports that don't match the underlying file system | |
- // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md | |
- 'import/no-unresolved': 'error', | |
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unresolved.md | |
+ 'import-x/no-unresolved': 'error', | |
}, | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment