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

fix(all): disallow throwing literals (@typescript-eslint/no-throw-literal) #3086

Merged
merged 6 commits into from Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .eslintrc.json
Expand Up @@ -43,7 +43,12 @@
{
"files": ["**/*.ts"],
"extends": ["@malept/eslint-config/src/typescript"],
"parserOptions": {
"project": ["./tsconfig.base.json"]
},
"rules": {
"no-throw-literal": "off",
"@typescript-eslint/no-throw-literal": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
Expand Down
1 change: 0 additions & 1 deletion packages/api/cli/src/util/terminate.ts
Expand Up @@ -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:');
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 was just an unnecessary log line

promise.catch((err: Error) => {
if ('stack' in err) {
const usefulStack = err.stack;
Expand Down
9 changes: 2 additions & 7 deletions packages/api/core/src/api/make.ts
Expand Up @@ -282,15 +282,10 @@ export const listrMake = (
arch: targetArch,
});
} catch (err) {
if (err instanceof Error) {
throw {
message: `An error occured while making for target: ${maker.name}`,
stack: `${err.message}\n${err.stack}`,
};
} else if (err) {
if (err) {
throw err;
} else {
throw new Error(`An unknown error occured while making for target: ${maker.name}`);
Copy link
Member Author

Choose a reason for hiding this comment

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

typo fix

throw new Error(`An unknown error occurred while making for target: ${maker.name}`);
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/api/core/src/util/resolve-dir.ts
Expand Up @@ -53,7 +53,7 @@ export default async (dir: string): Promise<string | null> => {
return bestGuessDir;
}
if (lastError) {
throw lastError;
throw new Error(lastError);
}
return null;
};
20 changes: 1 addition & 19 deletions tools/gen-tsconfigs.ts
Expand Up @@ -3,25 +3,6 @@ import * as path from 'path';

import { getPackageInfo } from './utils';

const BASE_TS_CONFIG = {
'//': '⚠️ AUTOGENERATED ⚠️ This file was automatically generated by tools/gen-tsconfigs.ts, do not edit manually.',
compilerOptions: {
module: 'commonjs',
target: 'es2019',
outDir: 'dist',
lib: ['dom', 'es2019'],
sourceMap: true,
rootDir: 'src',
experimentalDecorators: true,
strict: true,
esModuleInterop: true,
declaration: true,
composite: true,
declarationMap: true,
},
exclude: ['node_modules', 'dist', 'test', 'index.ts', 'tmpl'],
};

/**
* Filters out non-unique items in an array.
*/
Expand All @@ -30,6 +11,7 @@ function filterDupes<T>(arr: readonly T[]): T[] {
}

(async () => {
const BASE_TS_CONFIG = JSON.parse(await fs.readFile(path.resolve(__dirname, '../tsconfig.base.json'), 'utf-8'));
const packages = await getPackageInfo();

// Do each package in parallel
Expand Down
17 changes: 17 additions & 0 deletions tsconfig.base.json
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2019",
"outDir": "dist",
"lib": ["dom", "es2019"],
"sourceMap": true,
"rootDir": "src",
"experimentalDecorators": true,
"strict": true,
"esModuleInterop": true,
"declaration": true,
"composite": true,
"declarationMap": true
},
"exclude": ["node_modules", "dist", "test", "index.ts", "tmpl"]
}