Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement import-x resolver interface v3 #326

Merged
merged 5 commits into from
Dec 3, 2024

Conversation

SukkaW
Copy link
Collaborator

@SukkaW SukkaW commented Dec 3, 2024

Fixes #318.

Introduces support for flat config support and support for eslint-plugin-import-x's v3 interface.

cc @mcshaman @melroy89 @Leonardo-Vieira-Andela

Also, README has been updated w/ the flat config usage.


This version has implemented the eslint-plugin-import-x's v3 resolver interface. This allows you to use import/require to reference eslint-import-resolver-typescript directly in your ESLint flat config:

Previously

// eslint.config.js
module.exports = {
  settings: {
    'import-x/resolver': {
      typescript: {
        alwaysTryTypes: true,
      },
      // or
      require.resolve('eslint-import-resolver-typescript'):
        alwaysTryTypes: true,
      }
    }
  }
}

Now

// eslint.config.js
const {
  createTypeScriptImportResolver,
} = require('eslint-import-resolver-typescript')

module.exports = {
  settings: {
    'import-x/resolver-next': [
      createTypeScriptImportResolver({
        alwaysTryTypes: true,
      }),
    ],
  },
}

Note that this only works with eslint-plugin-import-x@>=4.5.0. You can't use createTypeScriptImportResolver with the older versions of eslint-plugin-import-x or any existing versions of eslint-plugin-import.

Copy link

changeset-bot bot commented Dec 3, 2024

🦋 Changeset detected

Latest commit: d207c0e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-import-resolver-typescript Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codesandbox-ci bot commented Dec 3, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link

socket-security bot commented Dec 3, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

Copy link

Report too large to display inline

View full report↗︎

@SukkaW SukkaW requested a review from JounQin December 3, 2024 09:10
@mcshaman
Copy link

mcshaman commented Dec 3, 2024

Thanks @SukkaW, nice work

@melroy89
Copy link

melroy89 commented Dec 3, 2024

Love it!

What about improving the import, to something like similar this (Eslint prettier example):

import eslint from '@eslint/js';
import eslintPrettier from 'eslint-config-prettier';

export default tseslint.config(
    eslintPrettier,
    
);

Meaning less boilerplate for the end-user.

@SukkaW
Copy link
Collaborator Author

SukkaW commented Dec 3, 2024

Love it!

What about improving the import, to something like similar this (Eslint prettier example):

import eslint from '@eslint/js';
import eslintPrettier from 'eslint-config-prettier';

export default tseslint.config(
    eslintPrettier,
    
);

Meaning less boilerplate for the end-user.

eslint-import-resolver-typescript is kinda a plugin for eslint plugin. The eslint flat presets should be provided by the eslint plugin IMO.

If you are using eslint-plugin-import-x, you can use require('eslint-plugin-import-x').flatConfigs.recommended, require('eslint-plugin-import-x').flatConfigs.typescript, and many more presets!

@SukkaW SukkaW added this pull request to the merge queue Dec 3, 2024
Merged via the queue into import-js:master with commit 93ea130 Dec 3, 2024
9 checks passed
@SukkaW SukkaW deleted the implement-resolver-interface-v3 branch December 3, 2024 13:51
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Dec 6, 2024
| datasource | package                           | from  | to    |
| ---------- | --------------------------------- | ----- | ----- |
| npm        | eslint-import-resolver-typescript | 3.6.3 | 3.7.0 |


## [v3.7.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#370)

##### Minor Changes

-   [#326](import-js/eslint-import-resolver-typescript#326) [`93ea130`](import-js/eslint-import-resolver-typescript@93ea130) Thanks [@SukkaW](https://github.com/SukkaW)! - This version has implemented the `eslint-plugin-import-x`'s v3 resolver interface. This allows you to use import/require to reference `eslint-import-resolver-typescript` directly in your ESLint flat config:

    **Previously**

    ```js
    // eslint.config.js
    module.exports = {
      settings: {
        'import-x/resolver': {
          typescript: {
            alwaysTryTypes: true,
          },
          // or
          require.resolve('eslint-import-resolver-typescript'):
            alwaysTryTypes: true,
          }
        }
      }
    }
    ```

    **Now**

    ```js
    // eslint.config.js
    const {
      createTypeScriptImportResolver,
    } = require('eslint-import-resolver-typescript')

    module.exports = {
      settings: {
        'import-x/resolver-next': [
          createTypeScriptImportResolver({
            alwaysTryTypes: true,
          }),
        ],
      },
    }
    ```

    Note that this only works with `eslint-plugin-import-x@>=4.5.0`. You can't use `createTypeScriptImportResolver` with the older versions of `eslint-plugin-import-x` or any existing versions of `eslint-plugin-import`.
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Dec 6, 2024
| datasource | package                           | from  | to    |
| ---------- | --------------------------------- | ----- | ----- |
| npm        | eslint-import-resolver-typescript | 3.6.3 | 3.7.0 |


## [v3.7.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#370)

##### Minor Changes

-   [#326](import-js/eslint-import-resolver-typescript#326) [`93ea130`](import-js/eslint-import-resolver-typescript@93ea130) Thanks [@SukkaW](https://github.com/SukkaW)! - This version has implemented the `eslint-plugin-import-x`'s v3 resolver interface. This allows you to use import/require to reference `eslint-import-resolver-typescript` directly in your ESLint flat config:

    **Previously**

    ```js
    // eslint.config.js
    module.exports = {
      settings: {
        'import-x/resolver': {
          typescript: {
            alwaysTryTypes: true,
          },
          // or
          require.resolve('eslint-import-resolver-typescript'):
            alwaysTryTypes: true,
          }
        }
      }
    }
    ```

    **Now**

    ```js
    // eslint.config.js
    const {
      createTypeScriptImportResolver,
    } = require('eslint-import-resolver-typescript')

    module.exports = {
      settings: {
        'import-x/resolver-next': [
          createTypeScriptImportResolver({
            alwaysTryTypes: true,
          }),
        ],
      },
    }
    ```

    Note that this only works with `eslint-plugin-import-x@>=4.5.0`. You can't use `createTypeScriptImportResolver` with the older versions of `eslint-plugin-import-x` or any existing versions of `eslint-plugin-import`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

feature request: FlatConfig support
3 participants