-
-
Notifications
You must be signed in to change notification settings - Fork 523
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
fix(all): disallow throwing literals (@typescript-eslint/no-throw-literal
)
#3086
Conversation
9ce20c9
to
8cb8c30
Compare
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.
Can we add tests?😅
I mostly ask because this seems like a regression... |
@malept You're right. If I'm reading the code correctly, it seems like it regressed way back in #2520, where we added the I'm guessing the spike in reports is because we have a larger active userbase now that we've brought Forge under the Electron umbrella. I can add a simple set of tests for this utility function! |
@typescript-eslint/no-throw-literal
)
@@ -7,7 +7,6 @@ function redConsoleError(msg: string) { | |||
process.on('unhandledRejection', (reason: string, promise: Promise<unknown>) => { | |||
redConsoleError('\nAn unhandled rejection has occurred inside Forge:'); | |||
redConsoleError(reason.toString().trim()); | |||
redConsoleError('\nElectron Forge was terminated. Location:'); |
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.
This was just an unnecessary log line
throw err; | ||
} else { | ||
throw new Error(`An unknown error occured while making for target: ${maker.name}`); |
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.
typo fix
@malept After some consideration, enabling a lint rule to make sure all errors get thrown properly is better for code quality in the future. The regression itself was caused by us doing bad stuff with errors rather than the |
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.
Sounds good to me
Better linting
This PR adds the
@typescript-eslint/no-throw-literal
ESLint rule, which removes the ability to throw non-Error
errors.Slight changes to tsconfig generation
In Forge, we generate each
tsconfig.json
per-package in a postinstall script. This means there is no globaltsconfig.json
for the project (aside from atsconfig.test.json
that we use for tests.)However, since the
@typescript-eslint/no-throw-literal
rule requires a config to be specified inparserOptions.project
, I moved the base TSConfig JavaScript object that we use to generate each package's TSConfig into its owntsconfig.base.json
file in the project's root folder.No more
[object Object]
errorsRef #3084
We used to throw a non-standard error object in the core Make API, which ended up logging a
[object Object]
error in the CLI. This is fixed by following the new lint rule.Testing
You can test this case easily on macOS by attempting to build the Squirrel.Windows without
mono
installed. As you can see, this PR adds a lot more clarity to the exact error message.Before:
After: