-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat(website): Show tsconfig parsing errors in tab #10991
base: main
Are you sure you want to change the base?
feat(website): Show tsconfig parsing errors in tab #10991
Conversation
Thanks for the PR, @developer-bandi! 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. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
View your CI Pipeline Execution ↗ for commit f8903df.
☁️ Nx Cloud last updated this comment at |
maybe we should just extends fs to contain info about errors for specific files, with that we could change/swap what we display based on file that is selected? tsconfig is a file (model) in monaco, similar to any other file, and its cloned as vfs file |
If I understand correctly, you mean changing the type of markers to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this started! I think I found a bug? Also left a question and a few refactor suggestions.
console.error(e); | ||
if (e instanceof Error) { | ||
const error = { | ||
group: 'Typescript', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group: 'Typescript', | |
group: 'TypeScript', |
prev.tsconfig.map(error => [error.group, error]), | ||
); | ||
|
||
activeTabErrors.Typescript = error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and in other places that refer to Typescript
:
activeTabErrors.Typescript = error; | |
activeTabErrors.TypeScript = error; |
fixer: undefined, | ||
location: '', | ||
message, | ||
severity: 8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Docs] It's not clear where this magic number comes from at first. Keeping in line with...
typescript-eslint/packages/website/src/components/linter/utils.ts
Lines 144 to 146 in ee38b52
message.severity === 2 | |
? 8 // MarkerSeverity.Error | |
: 4, // MarkerSeverity.Warning |
severity: 8, | |
severity: 8, // MarkerSeverity.Error |
.split('\n') | ||
.map((message: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have an example of a message that needs to be split? I've only been able to make versions with a single reported error at a time.
fixer: undefined, | ||
location: '', | ||
message, | ||
severity: 8, | ||
suggestions: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Refactor] Suggestion: what do you think about making these empty/falsy values optional in the ErrorItem
type? IMO if they don't need to always have a real value, they should be allowed to not exist.
fixer: undefined, | |
location: '', | |
message, | |
severity: 8, | |
suggestions: [], | |
message, | |
severity: 8, |
Object.fromEntries(prev[activeTab].map(error => [error.group, error])) | ||
.Typescript; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Refactor] This confused me at first - we don't really need a whole grouped object, just the first tsconfig error.
Object.fromEntries(prev[activeTab].map(error => [error.group, error])) | |
.Typescript; | |
Object.values(prev[activeTab]).find( | |
error => error.group === 'TypeScript', | |
); |
In fact, we don't care about this at all if errors.length
, so this callback body can be rewritten like:
const tsconfigErrors =
activeTab === 'tsconfig' &&
!errors.length &&
Object.values(prev[activeTab]).filter(
error => error.group === 'TypeScript',
);
return {
...prev,
[activeTab]: tsconfigErrors || errors,
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bug] These changes properly show a new error 👍. But when the user changes their tsconfig tab contents to no longer have an error, the shown error stays.
Repro steps:
- Create a playground with an error
- Modify the text in the tsconfig tab to no longer have the error: playground with modified state, no error
PR Checklist
Overview
I'm trying to manage tsconfig errors with different markers and statuses.Because I couldn't integrate tsconfig errors into markers since markers change depending on editor changes, and I thought it was wrong to apply tsconfig where markers are created.treat in below comment, change marker type to
Record<TabType,ErrorGroup[]>