Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typescript-estree): add support for custom module resolution
- Loading branch information
1 parent
06c2d9b
commit c3b24eb
Showing
13 changed files
with
170 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
36 changes: 36 additions & 0 deletions
36
packages/typescript-estree/tests/fixtures/moduleResolver/moduleResolver.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const ts = require('typescript'); | ||
|
||
module.exports = { | ||
version: 1, | ||
resolveModuleNames: ( | ||
moduleNames, | ||
containingFile, | ||
_reusedNames, | ||
_redirectedReferences, | ||
compilerOptions, | ||
) => { | ||
const resolvedModules = []; | ||
|
||
for (const moduleName of moduleNames) { | ||
let parsedModuleName = moduleName; | ||
|
||
if (parsedModuleName === '__PLACEHOLDER__') { | ||
parsedModuleName = './something'; | ||
} | ||
|
||
const resolution = ts.resolveModuleName( | ||
parsedModuleName, | ||
containingFile, | ||
compilerOptions, | ||
{ | ||
fileExists: ts.sys.fileExists, | ||
readFile: ts.sys.readFile, | ||
}, | ||
); | ||
|
||
resolvedModules.push(resolution.resolvedModule); | ||
} | ||
|
||
return resolvedModules; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/typescript-estree/tests/fixtures/moduleResolver/something.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const something = true; |
3 changes: 3 additions & 0 deletions
3
packages/typescript-estree/tests/fixtures/moduleResolver/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"include": ["./file.ts", "./something.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters