Add tsconfigPath option to customize TypeScript config file path #189
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for maintaining this useful plugin! I use it regularly and it's been very helpful for managing module dependencies in my projects.
Summary
Added
tsconfigPathoption to allow customization of the TypeScript configuration file path.Background & Motivation
Currently, this plugin hardcodes reading from
tsconfig.json. However, in real-world projects, there are cases where multipletsconfig.jsonfiles are used (e.g.,tsconfig.json,tsconfig.app.json,tsconfig.test.json). The current implementation always reads fromtsconfig.json, which prevents loading application-specific configurations.In particular, recent Vite templates create
tsconfig.app.jsonby default alongsidetsconfig.jsonandtsconfig.node.jsonto separate application-specific settings from the base configuration. This separation allows different TypeScript settings for different parts of the project (client-side application vs. Node.js build tools), improving maintainability and flexibility.To solve this problem, we added the
tsconfigPathoption to allow users to flexibly specify which TypeScript configuration file to use.Changes
New Feature
tsconfigPathoptiontsconfig.json(maintains existing behavior)tsconfig.app.json,tsconfig.base.json)Modified Files
strict-dependencies/index.js: AddedtsconfigPathoption to schemastrict-dependencies/resolveImportPath.js: Modified to accepttsconfigPathparameter and read the specified file__tests__/resolveImportPath.js: Added test cases fortsconfigPathoption__tests__/index.js: UpdatedresolveImportPathcalls to support the 4th parameterREADME.md: Added documentation fortsconfigPathoptionUsage Example
Backward Compatibility
tsconfigPathoption is not specified, existing behavior (defaults totsconfig.json) is maintainedAdditional Notes
This change enables projects using multiple
tsconfig.jsonfiles to specify the appropriate configuration file for ESLint rules.