You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The resolver currently supports three reference methods:
name -> eslint-import-resolver-name
npm package name
filesystem path
I propose to support the direct use of any object satisfied Resolver type, and I further propose configuration other than this should be deprecated in the future.
Advantage:
Reduce complexity when trying to require resolvers
Defining a custom resolver is more convenient
For advantage 1, you can refer to ESLint’s thoughts on the introduction of flat config:
Use native loading for everything - one of our biggest regrets about eslintrc was recreating the Node.js require resolution in a custom way. This was a significant source of complexity and, in hindsight, unnecessary. Going forward, we wanted to leverage the loading capabilities of the JavaScript runtime directly.
For advantage 2, there may be cases when existing resolvers don't meet the needs and needs to be temporarily added.
In this case, if the direct use of objects is supported, the steps of "creating new file -> processing filesystem path" can be eliminated, and the object can be created in place and used immediately.
For example, suppose I want to bundle the eslint configuration and all dependencies into a single file for use. In this case, none of the above three configuration methods will work. However, if the feature of directly using the resolver object is provided, my needs can be well met.
In order to support the use of Resolver objects, the configuration structure of the import-x/resolver configuration item needs to be modified.
Sorry, I found out after opening the issue that there has been a discussion before: #40 (comment)
But I still want to emphasize that custom resolver should be supported. This does not conflict with the current logic of trying to require resolvers. On the contrary, it will bring certain conveniences.
The resolver currently supports three reference methods:
I propose to support the direct use of any object satisfied
Resolver
type, and I further propose configuration other than this should be deprecated in the future.Advantage:
For advantage 1, you can refer to ESLint’s thoughts on the introduction of flat config:
Reference: https://eslint.org/blog/2022/08/new-config-system-part-2/#the-goals-of-flat-config
For advantage 2, there may be cases when existing resolvers don't meet the needs and needs to be temporarily added.
In this case, if the direct use of objects is supported, the steps of "creating new file -> processing filesystem path" can be eliminated, and the object can be created in place and used immediately.
For example, suppose I want to bundle the eslint configuration and all dependencies into a single file for use. In this case, none of the above three configuration methods will work. However, if the feature of directly using the resolver object is provided, my needs can be well met.
In order to support the use of
Resolver
objects, the configuration structure of theimport-x/resolver
configuration item needs to be modified.Before:
After:
The text was updated successfully, but these errors were encountered: