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

Rework error collection, error if tslint.json is present #950

Merged
merged 4 commits into from
Feb 12, 2024

Conversation

jakebailey
Copy link
Member

This is a noisy change; meant to just send the PR to error if tslint.json is present, but found myself changing a few other things to prevent dtslint from bailing early for simple problems like "npmignore is wrong" or "OTHER_FILES.txt or tslint.json is present".

We'll now not bail out early on errors, e.g.

putting some random garbage in a dts file in a types version dir:

[email protected]
testing from 4.6 to 4.8 in /home/jabaile/work/DefinitelyTyped/types/node/ts4.8
testing from 4.9 to 5.4 in /home/jabaile/work/DefinitelyTyped/types/node
Error: 
/home/jabaile/work/DefinitelyTyped/types/node/ts4.8/cluster.d.ts
  433:1  error  [email protected], 4.7, 4.8 compile error: 
Statements are not allowed in ambient contexts  @definitelytyped/expect
  433:1  error  [email protected], 4.7, 4.8 compile error: 
Cannot find name 'asdagnsdogsdf'                @definitelytyped/expect

✖ 2 problems (2 errors, 0 warnings)

    at combineErrorsAndWarnings (/home/jabaile/work/DefinitelyTyped-tools/packages/dtslint/src/index.ts:250:26)
    at runTests (/home/jabaile/work/DefinitelyTyped-tools/packages/dtslint/src/index.ts:241:18)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at main (/home/jabaile/work/DefinitelyTyped-tools/packages/dtslint/src/index.ts:103:22)
 ELIFECYCLE  Test failed. See above for more details.

Then with the new error about having a tslint.json:

[email protected]
testing from 4.6 to 4.8 in /home/jabaile/work/DefinitelyTyped/types/node/ts4.8
testing from 4.9 to 5.4 in /home/jabaile/work/DefinitelyTyped/types/node
Error: /home/jabaile/work/DefinitelyTyped/types/node/ts4.8: Should not contain 'tslint.json'. This file is no longer required; place all lint-related options into .eslintrc.json.
    at combineErrorsAndWarnings (/home/jabaile/work/DefinitelyTyped-tools/packages/dtslint/src/index.ts:250:26)
    at runTests (/home/jabaile/work/DefinitelyTyped-tools/packages/dtslint/src/index.ts:241:18)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at main (/home/jabaile/work/DefinitelyTyped-tools/packages/dtslint/src/index.ts:103:22)

Perhaps not bailing out early is unwise; before, if there were errors, we would effectively skip ATTW. Maybe I should just make it not run ATTW if there are preceding errors?

assertIndexdts(dirPath);
): Promise<{ errors: string[] }> {
const errors = [];
const checkExpectedFilesResult = checkExpectedFiles(dirPath, isLatest);
Copy link
Member Author

Choose a reason for hiding this comment

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

This check is now happening per types version, since those folders can also have lint configs... This code may not run if this kind of testing is disabled, e.g. npmChecksOnly mode, which is unfortunate. Was not sure how to clean be able to run on each versioned dir, though.

const tsconfigErrors = checkTsconfig(dirPath, getCompilerOptions(dirPath));
if (tsconfigErrors.length > 0) {
throw new Error("\n\t* " + tsconfigErrors.join("\n\t* "));
errors.push("\n\t* " + tsconfigErrors.join("\n\t* "));
Copy link
Member

Choose a reason for hiding this comment

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

It may soon be worth collecting structured error data and making a nice reporter/formatter, or using a dependency if you know of a good one. Our newlines and indentation are pretty inconsistent.

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, I saw this and was like "Oh yeah this has some pretty formatting, doesn't it".

From what I can tell, this eventually gets thrown as an error, so as long as it adds a leading newline, it actually turns out okay. But we don't do that in many cases.

@andrewbranch
Copy link
Member

andrewbranch commented Feb 12, 2024

Maybe I should just make it not run ATTW if there are preceding errors?

I think running everything is fine. Some eslint errors are trivial enough that you’d want to know if your entire module structure is wrong before fixing the eslint stuff.

@jakebailey jakebailey merged commit 57bb3ea into microsoft:main Feb 12, 2024
6 checks passed
@jakebailey jakebailey deleted the error-redo-more branch February 12, 2024 22:30
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.

2 participants