core
core copied to clipboard
Add linting for TypeScript configuration files
It is easy for the TypeScript files to be misconfigured due to requirements that aren't obvious.
At the project level, the following should hold true:
- In
tsconfig.json,referencesshould cover all public workspace packages, and all paths should point to valid files and end with/tsconfig.json[note: this is not the case now but we can add it for consistency with the next rule] - In
tsconfig.build.json,referencesshould matchreferencesintsconfig.jsonexcept that all paths should end with/tsconfig.build.jsonand point to valid files.
For each public workspace package, the following should hold true:
-
tsconfig.jsonshould be present and:-
extendsshould be "../../tsconfig.packages.json" -
compilerOptions.baseUrlshould be "./" - all paths in
references(if present) should point to valid files and end with/tsconfig.json[note: this is not the case now but we can add it for consistency with the next rule] -
includeshould include "../../types" and "./src"
-
-
tsconfig.build.jsonshould be present and:-
extendsshould be "../../tsconfig.packages.build.json" -
compilerOptions.baseUrlshould be "./" -
compilerOptions.distshould be "./dist" -
compilerOptions.rootDirshould be "./src" - all paths in
references(if present) should match those intsconfig.jsonexcept they should end with/tsconfig.build.jsonand should be valid files -
includeshould include "../../types" and "./src"
-
We may be able to auto-generate project references from Yarn workspaces. See various solutions posted here: https://github.com/microsoft/TypeScript/issues/25376