Skip to content

Commit

Permalink
replace eslint-plugin-import with eslint-plugin-import-x
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Aug 27, 2024
1 parent 3a9e064 commit b88eff1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1,268 deletions.
23 changes: 9 additions & 14 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import js from '@eslint/js';
import ts from 'typescript-eslint';
import prettier from 'eslint-plugin-prettier/recommended';
import chai from 'eslint-plugin-chai-friendly';
import importRecommented from 'eslint-plugin-import/config/recommended.js';
import imports from 'eslint-plugin-import-x';
import jhipster from './lib/eslint/index.js';

export default ts.config(
Expand Down Expand Up @@ -44,6 +44,7 @@ export default ts.config(
},
},
{
extends: [imports.flatConfigs.recommended, imports.flatConfigs.typescript],
languageOptions: {
// import plugin does not use ecmaVersion and sourceType from languageOptions object
parserOptions: {
Expand All @@ -52,28 +53,22 @@ export default ts.config(
},
},
settings: {
'import/parsers': {
espree: ['.js', '.cjs', '.mjs'],
'@typescript-eslint/parser': ['.ts'],
},
'import/resolver': {
node: true,
'import-x/resolver': {
typescript: true,
},
},
rules: {
...importRecommented.rules,
'import/no-named-as-default-member': 'off',
'import/named': 'off',
'import/extensions': [0, { pattern: { '{c,m,}{js,ts}': 'always' } }],
'import/prefer-default-export': 'off',
'import/namespace': 'off',
'import-x/no-named-as-default-member': 'off',
// 'import-x/named': 'off',
// 'import-x/extensions': [0, { pattern: { '{c,m,}{js,ts}': 'always' } }],
// 'import-x/prefer-default-export': 'off',
'import-x/namespace': 'off',
},
},
{
files: ['bin/**/*', '**/*.spec.ts', 'testing/**/*', 'test/**/*'],
rules: {
'import/no-unresolved': 'off',
'import-/no-unresolved': 'off',
},
},
{
Expand Down
9 changes: 4 additions & 5 deletions lib/eslint/base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import unusedImports from 'eslint-plugin-unused-imports';
import imports from 'eslint-plugin-import';
import { fixupPluginRules } from '@eslint/compat';
import imports from 'eslint-plugin-import-x';

/**
* @type {import('typescript-eslint').ConfigWithExtends}
Expand All @@ -11,7 +10,7 @@ import { fixupPluginRules } from '@eslint/compat';
const baseConfig = {
plugins: {
'unused-imports': unusedImports,
import: fixupPluginRules(imports),
...imports.flatConfigs.recommended.plugins,
},
rules: {
'dot-notation': 'error',
Expand All @@ -31,8 +30,8 @@ const baseConfig = {

// Configure unused-imports rule
'no-unused-vars': 'off',
'import/no-duplicates': 'error',
'import/order': 'error',
'import-x/no-duplicates': 'error',
'import-x/order': 'error',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
Expand Down
Loading

0 comments on commit b88eff1

Please sign in to comment.