mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
Chore: Add no-throw-literal
and prefer-promise-reject-errors
eslint rules (#10371)
This commit is contained in:
parent
bce71a00e9
commit
0670ad92d7
@ -70,6 +70,10 @@ module.exports = {
|
|||||||
'no-var': ['error'],
|
'no-var': ['error'],
|
||||||
'no-new-func': ['error'],
|
'no-new-func': ['error'],
|
||||||
'import/prefer-default-export': ['error'],
|
'import/prefer-default-export': ['error'],
|
||||||
|
'prefer-promise-reject-errors': ['error', {
|
||||||
|
allowEmptyReject: true,
|
||||||
|
}],
|
||||||
|
'no-throw-literal': ['error'],
|
||||||
|
|
||||||
// This rule should not be enabled since it matters in what order
|
// This rule should not be enabled since it matters in what order
|
||||||
// imports are done, in particular in relation to the shim.setReact
|
// imports are done, in particular in relation to the shim.setReact
|
||||||
|
@ -19,7 +19,7 @@ const generateChecksumFile = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (appImageName === '') {
|
if (appImageName === '') {
|
||||||
throw 'AppImage not found!';
|
throw new Error('AppImage not found!');
|
||||||
}
|
}
|
||||||
const appImagePath = path.join(distPath, appImageName);
|
const appImagePath = path.join(distPath, appImageName);
|
||||||
const appImageContent = fs.readFileSync(appImagePath);
|
const appImageContent = fs.readFileSync(appImagePath);
|
||||||
|
@ -133,7 +133,7 @@ export const createJsDrawEditor = (
|
|||||||
const request = new XMLHttpRequest();
|
const request = new XMLHttpRequest();
|
||||||
|
|
||||||
const onError = () => {
|
const onError = () => {
|
||||||
reject(`Failed to load initial SVG data: ${request.status}, ${request.statusText}, ${request.responseText}`);
|
reject(new Error(`Failed to load initial SVG data: ${request.status}, ${request.statusText}, ${request.responseText}`));
|
||||||
};
|
};
|
||||||
|
|
||||||
request.addEventListener('load', _ => {
|
request.addEventListener('load', _ => {
|
||||||
|
@ -30,7 +30,7 @@ export interface ValueMap {
|
|||||||
|
|
||||||
export default function getResponsiveValue(valueMap: ValueMap): number {
|
export default function getResponsiveValue(valueMap: ValueMap): number {
|
||||||
if (Object.keys(valueMap).length === 0) {
|
if (Object.keys(valueMap).length === 0) {
|
||||||
throw 'valueMap cannot be an empty object!';
|
throw new Error('valueMap cannot be an empty object!');
|
||||||
}
|
}
|
||||||
|
|
||||||
const width = Dimensions.get('window').width;
|
const width = Dimensions.get('window').width;
|
||||||
|
@ -252,6 +252,7 @@ class FileApiDriverAmazonS3 {
|
|||||||
output = await response.text();
|
output = await response.text();
|
||||||
// we need to make sure that errors get thrown as we are manually fetching above.
|
// we need to make sure that errors get thrown as we are manually fetching above.
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
// eslint-disable-next-line no-throw-literal -- Old code before rule was applied
|
||||||
throw { name: response.statusText, output: output };
|
throw { name: response.statusText, output: output };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,8 +228,8 @@ function shimInit(options: ShimInitOptions = null) {
|
|||||||
image.src = filePath;
|
image.src = filePath;
|
||||||
await new Promise<void>((resolve, reject) => {
|
await new Promise<void>((resolve, reject) => {
|
||||||
image.onload = () => resolve();
|
image.onload = () => resolve();
|
||||||
image.onerror = () => reject(`Image at ${filePath} failed to load.`);
|
image.onerror = () => reject(new Error(`Image at ${filePath} failed to load.`));
|
||||||
image.onabort = () => reject(`Loading stopped for image at ${filePath}.`);
|
image.onabort = () => reject(new Error(`Loading stopped for image at ${filePath}.`));
|
||||||
});
|
});
|
||||||
if (!image.complete || (image.width === 0 && image.height === 0)) {
|
if (!image.complete || (image.width === 0 && image.height === 0)) {
|
||||||
throw new Error(`Image is invalid or does not exist: ${filePath}`);
|
throw new Error(`Image is invalid or does not exist: ${filePath}`);
|
||||||
|
@ -164,7 +164,7 @@ export function execCommandWithPipes(executable: string, args: string[]) {
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||||
child.on('close', (code: any) => {
|
child.on('close', (code: any) => {
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
reject(`Ended with code ${code}`);
|
reject(new Error(`Ended with code ${code}`));
|
||||||
} else {
|
} else {
|
||||||
resolve(null);
|
resolve(null);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user