Closed controversial closed 3 months ago
+1. It's currently not working with the below setup
settings: {
'import-x/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx', ...vue ? ['.vue'] : []],
},
'import-x/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
typescript: true,
},
}
It results in this error
I'm not sure whether bump typescript-eslint
to v8 will help, or some fix is also needed in eslint-import-resolver-typescript
, but they are just not working together at the moment.
eslint-import-resolver-typescript
v3.6.2 and v3.6.3 all failed to release by the way
CC @SukkaW as I can see you worked on both projects, really appreciate that
Importing default configs (import-x/recommended + import-x/typescript) breaks with below error message:
But I have managed to configure the plugin and all rules manually.
My packages:
eslint.config.cjs
:
const globals = require('globals');
const js = require('@eslint/js');
const tsEsLint = require('typescript-eslint');
const importX = require('eslint-plugin-import-x');
const react = require('eslint-plugin-react');
const prettier = require('eslint-plugin-prettier/recommended');
const eslint = require('@eslint/js');
module.exports = tsEsLint.config(
{
ignores: [
'**/node_modules',
'**/build',
'**/.gitignore',
'**/.env',
'**/.env.production',
'**/.npmrc',
'**/.prettierrc',
'**/.prettierrc.js',
'**/.prettierignore',
'**/config-overrides.js',
'**/package-lock.json',
'**/package.json',
'**/README.md',
'**/tsconfig.json',
'**/eslint.config.cjs',
],
},
eslint.configs.recommended,
...tsEsLint.configs.recommended,
react.configs.flat.recommended,
prettier,
{
plugins: {
'import-x': importX,
},
languageOptions: {
globals: {
...globals.browser,
},
ecmaVersion: 2023,
sourceType: 'module',
parserOptions: {
projectService: true,
tsconfigRootDir: __dirname,
},
},
settings: {
'import-x/parsers': {
'@typescript-eslint/parser': ['**/*.ts', '**/*.tsx'],
},
'import-x/resolver': {
typescript: true,
node: true,
},
react: {
version: 'detect',
},
},
rules: {
'react/require-default-props': ['off'],
'@typescript-eslint/no-use-before-define': ['warn'],
'no-param-reassign': [
'error',
{
props: false,
},
],
'import-x/no-unresolved': "error",
'import-x/named': "off",
'import-x/namespace': "error",
'import-x/default': "error",
'import-x/export': "error",
'import-x/no-named-as-default': "warn",
'import-x/no-named-as-default-member': "warn",
'import-x/no-duplicates': "warn",
'import-x/prefer-default-export': 'error',
'import-x/no-deprecated': 'warn',
'import-x/no-extraneous-dependencies': 'error',
'import-x/no-unused-modules': 'error',
'import-x/no-absolute-path': 'error',
'import-x/imports-first': 'error',
'import-x/newline-after-import': 'error',
'import-x/no-cycle': 'error',
},
}
);
Importing default configs (import-x/recommended + import-x/typescript) breaks with below error message:
But I have managed to configure the plugin and all rules manually.
My packages:
- @eslint/compat: 1.1.1
- @eslint/eslintrc: 3.1.0
- @eslint/js: 9.8.0
- typescript-eslint: 8.0.1
- eslint: 9.8.0
- eslint-config-prettier: 9.1.0
- eslint-import-resolver-typescript: 3.6.1
- eslint-plugin-import-x: 3.1.0
- eslint-plugin-prettier: 5.2.1
- eslint-plugin-react: 7.35.0
eslint.config.cjs
:const globals = require('globals'); const js = require('@eslint/js'); const tsEsLint = require('typescript-eslint'); const importX = require('eslint-plugin-import-x'); const react = require('eslint-plugin-react'); const prettier = require('eslint-plugin-prettier/recommended'); const eslint = require('@eslint/js'); module.exports = tsEsLint.config( { ignores: [ '**/node_modules', '**/build', '**/.gitignore', '**/.env', '**/.env.production', '**/.npmrc', '**/.prettierrc', '**/.prettierrc.js', '**/.prettierignore', '**/config-overrides.js', '**/package-lock.json', '**/package.json', '**/README.md', '**/tsconfig.json', '**/eslint.config.cjs', ], }, eslint.configs.recommended, ...tsEsLint.configs.recommended, react.configs.flat.recommended, prettier, { plugins: { 'import-x': importX, }, languageOptions: { globals: { ...globals.browser, }, ecmaVersion: 2023, sourceType: 'module', parserOptions: { projectService: true, tsconfigRootDir: __dirname, }, }, settings: { 'import-x/parsers': { '@typescript-eslint/parser': ['**/*.ts', '**/*.tsx'], }, 'import-x/resolver': { typescript: true, node: true, }, react: { version: 'detect', }, }, rules: { 'react/require-default-props': ['off'], '@typescript-eslint/no-use-before-define': ['warn'], 'no-param-reassign': [ 'error', { props: false, }, ], 'import-x/no-unresolved': "error", 'import-x/named': "off", 'import-x/namespace': "error", 'import-x/default': "error", 'import-x/export': "error", 'import-x/no-named-as-default': "warn", 'import-x/no-named-as-default-member': "warn", 'import-x/no-duplicates': "warn", 'import-x/prefer-default-export': 'error', 'import-x/no-deprecated': 'warn', 'import-x/no-extraneous-dependencies': 'error', 'import-x/no-unused-modules': 'error', 'import-x/no-absolute-path': 'error', 'import-x/imports-first': 'error', 'import-x/newline-after-import': 'error', 'import-x/no-cycle': 'error', }, } );
it works for me, just add these lines inside your rules object: ...importXPlugin.configs.recommended.rules, ...importXPlugin.configs.typescript.rules,
https://github.com/un-ts/eslint-plugin-import-x/pull/112#issuecomment-2264466503
I've decided to postpone the work on this PR. The sheer volume of configurations that need to be migrated without a codemod is overwhelming. I'll focus on backporting import-js#3018 to
eslint-plugin-import-x
instead, which seems to be a more worthwhile task at the moment.If anyone would like to take over the PR, please fork my forked repository at https://github.com/SukkaW/eslint-plugin-import-x/tree/tseslint-v8, make changes on the
tseslint-v8
branch, and then submit PRs to my forked repository.
Once the change is released I’ll test & close this :)
@controversial what about adding pkg.pr.new for testing PRs in scenarios like this?
Any update on what are the blocking points and the roadmap before release? @controversial @SukkaW
Before they made the release, I made a fork with the latest commit to workaround this: https://github.com/antfu/eslint-plugin-import-x/tree/fork#readme
@pnodet @antfu I was waiting for #130 where a util function from typescript-eslint v8 coule be adopted. There is a type mismatch (I overcame that with type cast). I was going to wait for the typescript-eslint team to fix the typing.
Since it will take time for them to triage the issue, I will merge #130 right now and release a new version.
eslint-plugin-import-x@4.0.0
is now released with peerDeps of @typescript-eslint/utils
bumps to 8.
Thanks a lot for the release!
typescript-eslint v8 was released last week with support for eslint@9 and performance + stability upgrades
This repo currently depends on
@typescript-eslint
^7