Minor Changes
-
#209
46d2360Thanks @SukkaW! - Wheneslint-plugin-import-xwas forked fromeslint-plugin-import, we copied over the default resolver (which iseslint-import-resolver-node) as well. However, this resolver doesn't supportsexportsin thepackage.jsonfile, and the current maintainer of theeslint-import-resolver-node(@ljharb) doesn't have the time implementing this feature and he locked the issue import-js/eslint-plugin-import#1810.So we decided to implement our own resolver that "just works". The new resolver is built upon the
enhanced-resolvethat implements the full Node.js Resolver Algorithm. The new resolver only implements the import resolver interface v3, which means you can only use it with ESLint Flat config. For more details about the import resolver interface v3, please check out #192.In the next major version of
eslint-plugin-import-x, we will remove theeslint-import-resolver-nodeand use this new resolver by default. In the meantime, you can try out this new resolver by setting theimport-x/resolver-nextoption in youreslint.config.jsfile:// eslint.config.js const eslintPluginImportX = require('eslint-plugin-import-x'); const { createNodeResolver } = eslintPluginImportX; module.exports = { plugins: { 'import-x': eslintPluginImportX, }, settings: { 'import-x/resolver-next': [ // This is the new resolver we are introducing createNodeResolver({ /** * The allowed extensions the resolver will attempt to find when resolving a module * By default it uses a relaxed extension list to search for both ESM and CJS modules * You can customize this list to fit your needs * * @default ['.mjs', '.cjs', '.js', '.json', '.node'] */ extensions?: string[]; /** * Optional, the import conditions the resolver will used when reading the exports map from "package.json" * By default it uses a relaxed condition list to search for both ESM and CJS modules * You can customize this list to fit your needs * * @default ['default', 'module', 'import', 'require'] */ conditions: ['default', 'module', 'import', 'require'], // You can pass more options here, see the enhanced-resolve documentation for more details // https://github.com/webpack/enhanced-resolve/tree/v5.17.1?tab=readme-ov-file#resolver-options }), // you can add more resolvers down below require('eslint-import-resolver-typescript').createTypeScriptImportResolver( /** options of eslint-import-resolver-typescript */ ) ], }, };
We do not plan to implement reading
baseUrlandpathsfrom thetsconfig.jsonfile in this resolver. If you need this feature, please checkout eslint-import-resolver-typescript (also powered byenhanced-resolve), eslint-import-resolver-oxc (powered byoxc-resolver), eslint-import-resolver-next (also powered byoxc-resolver), or other similar resolvers.
Patch Changes
- #206
449738fThanks @privatenumber! - insert type prefix without new line
Full Changelog: v4.5.1...v4.6.0