Skip to content

Commit

Permalink
fix(all): disallow throwing literals (`@typescript-eslint/no-throw-li…
Browse files Browse the repository at this point in the history
…teral`) (#3086)
  • Loading branch information
erickzhao committed Nov 22, 2022
1 parent 3c6e7eb commit 3ede278
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 28 deletions.
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:');
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}`);
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"]
}

0 comments on commit 3ede278

Please sign in to comment.