core icon indicating copy to clipboard operation
core copied to clipboard

Add linting for TypeScript configuration files

Open mcmire opened this issue 3 years ago • 1 comments

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, references should 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, references should match references in tsconfig.json except that all paths should end with /tsconfig.build.json and point to valid files.

For each public workspace package, the following should hold true:

  • tsconfig.json should be present and:
    • extends should be "../../tsconfig.packages.json"
    • compilerOptions.baseUrl should 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]
    • include should include "../../types" and "./src"
  • tsconfig.build.json should be present and:
    • extends should be "../../tsconfig.packages.build.json"
    • compilerOptions.baseUrl should be "./"
    • compilerOptions.dist should be "./dist"
    • compilerOptions.rootDir should be "./src"
    • all paths in references (if present) should match those in tsconfig.json except they should end with /tsconfig.build.json and should be valid files
    • include should include "../../types" and "./src"

mcmire avatar Nov 16 '22 17:11 mcmire

We may be able to auto-generate project references from Yarn workspaces. See various solutions posted here: https://github.com/microsoft/TypeScript/issues/25376

mcmire avatar May 28 '24 20:05 mcmire