import-js / import-js/eslint-import-resolver-typescript
paths are not resolved in Solution Style (Project References) setup unless explicitly listed in project array
- Dominant language
- TypeScript
- Stars
- 825
- Forks
- 73
- PR merge metrics
- No merged PRs in 30d
Description
I am using a standard Vite + TypeScript setup which uses the "Solution Style" configuration (a root `tsconfig.json` that references `tsconfig.app.json` and `tsconfig.node.json`).
According to the [[README](https://www.npmjs.com/package/eslint-import-resolver-typescript)](https://www.npmjs.com/package/eslint-import-resolver-typescript), using an array of projects is "discouraged in favor of `references` supported".
However, when I follow this advice and omit the `project` setting (or point it strictly to the root `tsconfig.json`), the resolver fails to read the `paths` defined in the referenced `tsconfig.app.json`. It appears the resolver does not traverse/merge the `paths` from the referenced projects into the current context.
To make it work, I am forced to use the "discouraged" array approach.
### Reproduction
**File Structure:**
```text
/
├── tsconfig.json (Root)
├── tsconfig.app.json (Contains paths)
├── tsconfig.node.json
└── src/
└── components/
└── StateButton.tsx
```
**1. Root `tsconfig.json`**
```json
{
"files": [],
"references": [
{ "path": "./tsconfig.node.json" },
{ "path": "./tsconfig.app.json" }
]
}
```
**2. `tsconfig.app.json` (Where paths are defined)**
```json
{
"compilerOptions": {
"paths": {
"@components/*": ["./src/components/*"]
}
// ... other options
},
"include": ["src/**/*"]
}
```
**3. ESLint Configuration (`eslint.config.js`)**
**FAILING CONFIG (Following README advice):**
```javascript
settings: {
'import-x/resolver-next': [
createTypeScriptImportResolver({
alwaysTryTypes: true,
// Omitted 'project' (defaults to root tsconfig.json)
// OR explicitly set to: project: "tsconfig.json"
})
]
}
```
**WORKING CONFIG (The "Discouraged" workaround):**
```javascript
settings: {
'import-x/resolver-next': [
createTypeScriptImportResolver({
alwaysTryTypes: true,
// Explicitly listing the referenced projects works
project: [
'tsconfig.app.json',
'tsconfig.node.json'
]
})
]
}
```
### Actual Behavior
When using the Failing Config, imports using aliases throw:
`import-x/no-unresolved: Unable to resolve path to module '@components/StateButton'`
### Expected Behavior
The resolver should detect that `tsconfig.json` uses `references`, parse the referenced configuration files (`tsconfig.app.json`), and resolve the `paths` aliases defined inside them without needing to manually list every project file in the ESLint settings.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure with tsconfig.json referencing tsconfig.app.json and tsconfig.node.json, using the settings in eslint.config.js. Start by tracing how the resolver reads the root configuration and its references; done means @components/StateButton resolves without explicitly listing the referenced projects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100