Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor tsconfigs to use project references #9038

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JamesHenry
Copy link
Member

No description provided.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JamesHenry!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link

netlify bot commented May 2, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 98923ad
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/663a260acf47890009796d4e
😎 Deploy Preview https://deploy-preview-9038--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🟢 up 3 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented May 2, 2024

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 88.09%. Comparing base (7984ef7) to head (98923ad).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9038      +/-   ##
==========================================
+ Coverage   88.04%   88.09%   +0.04%     
==========================================
  Files         410      409       -1     
  Lines       14186    14175      -11     
  Branches     4135     4135              
==========================================
- Hits        12490    12487       -3     
+ Misses       1391     1383       -8     
  Partials      305      305              
Flag Coverage Δ
unittest 88.09% <88.23%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...-plugin/src/rules/naming-convention-utils/enums.ts 100.00% <ø> (ø)
...kages/eslint-plugin/src/rules/naming-convention.ts 94.50% <ø> (ø)
.../eslint-plugin/src/util/explicitReturnTypeUtils.ts 97.61% <ø> (ø)
packages/eslint-plugin/src/util/misc.ts 98.63% <ø> (ø)
packages/scope-manager/src/analyze.ts 61.11% <100.00%> (ø)
packages/scope-manager/src/index.ts 100.00% <100.00%> (+27.27%) ⬆️
...kages/scope-manager/src/referencer/ClassVisitor.ts 78.78% <ø> (ø)
...ges/scope-manager/src/referencer/PatternVisitor.ts 68.29% <100.00%> (ø)
packages/scope-manager/src/referencer/Reference.ts 90.32% <100.00%> (ø)
...ackages/scope-manager/src/referencer/Referencer.ts 95.52% <100.00%> (ø)
... and 13 more

... and 4 files with indirect coverage changes

@JamesHenry JamesHenry changed the title wip chore: refactor tsconfigs to use project references May 2, 2024
"noImplicitReturns": true,
"paths": {},
"noUnusedLocals": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we turn this off?
no-unused-vars does this without causing TS errors (so we can remove the @ts-expect-errors)
it also means the build won't error out due to a measly unused variable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool yeah I just took a relatively strong starting point inspired by other projects, we can change any of it to whatever's best. It isn't something that is generated or controlled by Nx in any way, it's completely up to us

Comment on lines +2 to +3
export { visitorKeys } from './visitor-keys';
export type { VisitorKeys } from './visitor-keys';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably turn on our consistent-type-exports rule

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah all of these type changes allowed compilation isolatedModules to work

"lib": ["es2022"],
"module": "NodeNext",
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto here - there's an eslint rule for this
i'd rather not use TS for linting if we can avoid it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah same comment

@jakebailey
Copy link
Collaborator

Tested this out locally and it does seem to work; tsc -b at the root does the right thing (awesome), and opening up typescript-estree/src/index.ts and doing a find-all-refs on getCanonicalFileName finds the other projects, including the use in semanticInfo-singleRun.test.ts which it previously couldn't find until that was opened.

Copy link
Collaborator

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-looking at the config layout, I do think you can get away with fewer configs, actually, via some restructuring. But it technically already functions now, of course.

Comment on lines +6 to +14
"files": [],
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.spec.json"
}
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting; I assume these are the main code and the tests, in which case I would have actually expected you to have tsconfig.json here be the main code, then have a tsconfig.test.json (or spec, that's bikeshedding) separate and then referenced from the repo root

Comment on lines -2 to +4
"extends": "./tsconfig.build.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": false,
"rootDir": "."
"outDir": "../../dist/out-tsc/ast-spec"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a "solution" file, there's actually no reason to extend anything here; these options are all noops.

But, I'm not sure that this layout is quite right, depending on other tooling which may assume that the tsconfig contains the options for the code. Maybe this extension is why you dont' have problems?

Comment on lines +4 to +6
"rootDir": "src",
"outDir": "dist",
"emitDeclarationOnly": false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, hm, you're using emitDeclarationOnly, but only sometimes. It seems simpler to only set noEmit for test projects, then leave all emit on in the base config, then only have tsconfig.json and tsconfig.spec.json per-package if you want to split apart tests.

Comment on lines +5 to +11
"references": [
{
"path": "./packages/ast-spec"
},
{
"path": "./packages/eslint-plugin"
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One gotcha here may be that TS won't do rebuilds in some situations if all projects are not listed here. Right now, you're using this top-level "solution" that points to other "solutions". Related is: microsoft/TypeScript#30608 / microsoft/TypeScript#55339

Comment on lines +13 to +14
"experimentalDecorators": false,
"forceConsistentCasingInFileNames": true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of these settings are already their defaults and could be removed for clarity, e.g. allowJs, decorators, pretty, and so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants