fix: add no-useless-promise-resolve-reject rule (#5111)

This commit is contained in:
LongYinan 2023-11-29 04:43:46 +00:00
parent d267029761
commit 45690c2756
No known key found for this signature in database
GPG Key ID: 30B1140CE1C07C99
5 changed files with 7 additions and 8 deletions

View File

@ -210,6 +210,7 @@ const config = {
'unicorn/prefer-dom-node-dataset': 'error',
'unicorn/prefer-dom-node-append': 'error',
'unicorn/prefer-array-some': 'error',
'unicorn/no-useless-promise-resolve-reject': 'error',
'sonarjs/no-all-duplicated-branches': 'error',
'sonarjs/no-element-overwrite': 'error',
'sonarjs/no-empty-collection': 'error',

View File

@ -33,7 +33,7 @@
"lint:eslint:fix": "yarn lint:eslint --fix",
"lint:prettier": "prettier --ignore-unknown --cache --check .",
"lint:prettier:fix": "prettier --ignore-unknown --cache --write .",
"lint:ox": "oxlint --deny-warnings --import-plugin -D correctness -D nursery -D prefer-array-some -A no-undef -A consistent-type-exports -A default -A named -A ban-ts-comment",
"lint:ox": "oxlint --deny-warnings --import-plugin -D correctness -D nursery -D prefer-array-some -D no-useless-promise-resolve-reject -A no-undef -A consistent-type-exports -A default -A named -A ban-ts-comment",
"lint": "yarn lint:eslint && yarn lint:prettier",
"lint:fix": "yarn lint:eslint:fix && yarn lint:prettier:fix",
"test": "vitest --run",

View File

@ -65,9 +65,7 @@ test.afterEach.always(async t => {
test('should get blob size limit', async t => {
const { resolver } = t.context;
fakeUserService.getStorageQuotaById.returns(
Promise.resolve(100 * 1024 * 1024 * 1024)
);
fakeUserService.getStorageQuotaById.resolves(100 * 1024 * 1024 * 1024);
const res = await resolver.checkBlobSize(new FakePrisma().fakeUser, '', 100);
t.not(res, false);
// @ts-expect-error

View File

@ -81,7 +81,7 @@ export async function bootstrapPluginSystem(
logger.debug(`registering plugin ${pluginName}`);
logger.debug(`package.json: ${packageJson}`);
if (!release && !runtimeConfig.enablePlugin) {
return Promise.resolve();
return;
}
const baseURL = url;
const entryURL = `${baseURL}/${core}`;
@ -95,7 +95,7 @@ export async function bootstrapPluginSystem(
const loadedAssetName = `${pluginName}_${asset}`;
// todo(himself65): add assets into shadow dom
if (loadedAssets.has(loadedAssetName)) {
return Promise.resolve();
return;
}
if (asset.endsWith('.css')) {
loadedAssets.add(loadedAssetName);
@ -111,7 +111,7 @@ export async function bootstrapPluginSystem(
}
return null;
} else {
return Promise.resolve();
return;
}
})
);

View File

@ -255,6 +255,6 @@ export const fetchWithTraceReport = async (
requestId,
...(event ? { event } : {}),
});
return await Promise.reject(err);
throw err;
}
};