style: add perf rules (#5413)

This commit is contained in:
LongYinan
2023-12-28 05:09:30 +00:00
parent 4fcf589fe7
commit 3148f93ee7
7 changed files with 46 additions and 50 deletions

View File

@@ -31,7 +31,7 @@
"lint:eslint:fix": "yarn lint:eslint --fix", "lint:eslint:fix": "yarn lint:eslint --fix",
"lint:prettier": "prettier --ignore-unknown --cache --check .", "lint:prettier": "prettier --ignore-unknown --cache --check .",
"lint:prettier:fix": "prettier --ignore-unknown --cache --write .", "lint:prettier:fix": "prettier --ignore-unknown --cache --write .",
"lint:ox": "oxlint --deny-warnings -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:ox": "oxlint --import-plugin --deny-warnings -D correctness -D nursery -D prefer-array-some -D no-useless-promise-resolve-reject -D perf -A no-undef -A consistent-type-exports -A default -A named -A ban-ts-comment -A export",
"lint": "yarn lint:eslint && yarn lint:prettier", "lint": "yarn lint:eslint && yarn lint:prettier",
"lint:fix": "yarn lint:eslint:fix && yarn lint:prettier:fix", "lint:fix": "yarn lint:eslint:fix && yarn lint:prettier:fix",
"test": "vitest --run", "test": "vitest --run",
@@ -97,7 +97,7 @@
"nx": "^17.1.3", "nx": "^17.1.3",
"nx-cloud": "^16.5.2", "nx-cloud": "^16.5.2",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"oxlint": "0.0.21", "oxlint": "0.0.22",
"prettier": "^3.1.0", "prettier": "^3.1.0",
"semver": "^7.5.4", "semver": "^7.5.4",
"serve": "^14.2.1", "serve": "^14.2.1",

View File

@@ -244,8 +244,7 @@ const states: Partial<Record<ArticleId, EdgelessSwitchState>> = {
export const articles: Record<ArticleId, ArticleOption> = ids.reduce( export const articles: Record<ArticleId, ArticleOption> = ids.reduce(
(acc, id) => { (acc, id) => {
return { return Object.assign(acc, {
...acc,
[id]: { [id]: {
id, id,
location: paperLocations[id], location: paperLocations[id],
@@ -254,7 +253,7 @@ export const articles: Record<ArticleId, ArticleOption> = ids.reduce(
blocks: contents[id], blocks: contents[id],
initState: states[id], initState: states[id],
} satisfies ArticleOption, } satisfies ArticleOption,
}; });
}, },
{} as Record<ArticleId, ArticleOption> {} as Record<ArticleId, ArticleOption>
); );

View File

@@ -45,10 +45,9 @@ export function useI18N() {
return i18n; return i18n;
} }
const resources = LOCALES.reduce<Resource>( const resources = LOCALES.reduce<Resource>((acc, { tag, res }) => {
(acc, { tag, res }) => ({ ...acc, [tag]: { translation: res } }), return Object.assign(acc, { [tag]: { translation: res } });
{} }, {});
);
const fallbackLng = 'en'; const fallbackLng = 'en';
const standardizeLocale = (language: string) => { const standardizeLocale = (language: string) => {

View File

@@ -27,9 +27,9 @@ export const flattenTranslation = (
if (!(obj instanceof Object)) return { [path ?? '']: obj }; if (!(obj instanceof Object)) return { [path ?? '']: obj };
return Object.keys(obj).reduce((output, key) => { return Object.keys(obj).reduce((output, key) => {
return { return Object.assign(
...output, output,
...flattenTranslation(obj[key], path ? path + '.' + key : key), flattenTranslation(obj[key], path ? path + '.' + key : key)
}; );
}, {}); }, {});
}; };

View File

@@ -42,10 +42,9 @@ export function createCloudAwarenessProvider(
return; return;
} }
const changedClients = Object.values(changes).reduce((res, cur) => [ const changedClients = Object.values(changes).reduce((res, cur) =>
...res, res.concat(cur)
...cur, );
]);
const update = encodeAwarenessUpdate(awareness, changedClients); const update = encodeAwarenessUpdate(awareness, changedClients);
uint8ArrayToBase64(update) uint8ArrayToBase64(update)

View File

@@ -23,10 +23,9 @@ export function createBroadcastChannelAwarenessProvider(
return; return;
} }
const changedClients = Object.values(changes).reduce((res, cur) => [ const changedClients = Object.values(changes).reduce((res, cur) =>
...res, res.concat(cur)
...cur, );
]);
const update = encodeAwarenessUpdate(awareness, changedClients); const update = encodeAwarenessUpdate(awareness, changedClients);
channel.postMessage({ channel.postMessage({

View File

@@ -582,7 +582,7 @@ __metadata:
nx: "npm:^17.1.3" nx: "npm:^17.1.3"
nx-cloud: "npm:^16.5.2" nx-cloud: "npm:^16.5.2"
nyc: "npm:^15.1.0" nyc: "npm:^15.1.0"
oxlint: "npm:0.0.21" oxlint: "npm:0.0.22"
prettier: "npm:^3.1.0" prettier: "npm:^3.1.0"
semver: "npm:^7.5.4" semver: "npm:^7.5.4"
serve: "npm:^14.2.1" serve: "npm:^14.2.1"
@@ -9328,44 +9328,44 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@oxlint/darwin-arm64@npm:0.0.21": "@oxlint/darwin-arm64@npm:0.0.22":
version: 0.0.21 version: 0.0.22
resolution: "@oxlint/darwin-arm64@npm:0.0.21" resolution: "@oxlint/darwin-arm64@npm:0.0.22"
conditions: os=darwin & cpu=arm64 conditions: os=darwin & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@oxlint/darwin-x64@npm:0.0.21": "@oxlint/darwin-x64@npm:0.0.22":
version: 0.0.21 version: 0.0.22
resolution: "@oxlint/darwin-x64@npm:0.0.21" resolution: "@oxlint/darwin-x64@npm:0.0.22"
conditions: os=darwin & cpu=x64 conditions: os=darwin & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@oxlint/linux-arm64@npm:0.0.21": "@oxlint/linux-arm64@npm:0.0.22":
version: 0.0.21 version: 0.0.22
resolution: "@oxlint/linux-arm64@npm:0.0.21" resolution: "@oxlint/linux-arm64@npm:0.0.22"
conditions: os=linux & cpu=arm64 conditions: os=linux & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@oxlint/linux-x64@npm:0.0.21": "@oxlint/linux-x64@npm:0.0.22":
version: 0.0.21 version: 0.0.22
resolution: "@oxlint/linux-x64@npm:0.0.21" resolution: "@oxlint/linux-x64@npm:0.0.22"
conditions: os=linux & cpu=x64 conditions: os=linux & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@oxlint/win32-arm64@npm:0.0.21": "@oxlint/win32-arm64@npm:0.0.22":
version: 0.0.21 version: 0.0.22
resolution: "@oxlint/win32-arm64@npm:0.0.21" resolution: "@oxlint/win32-arm64@npm:0.0.22"
conditions: os=win32 & cpu=arm64 conditions: os=win32 & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@oxlint/win32-x64@npm:0.0.21": "@oxlint/win32-x64@npm:0.0.22":
version: 0.0.21 version: 0.0.22
resolution: "@oxlint/win32-x64@npm:0.0.21" resolution: "@oxlint/win32-x64@npm:0.0.22"
conditions: os=win32 & cpu=x64 conditions: os=win32 & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
@@ -28564,16 +28564,16 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"oxlint@npm:0.0.21": "oxlint@npm:0.0.22":
version: 0.0.21 version: 0.0.22
resolution: "oxlint@npm:0.0.21" resolution: "oxlint@npm:0.0.22"
dependencies: dependencies:
"@oxlint/darwin-arm64": "npm:0.0.21" "@oxlint/darwin-arm64": "npm:0.0.22"
"@oxlint/darwin-x64": "npm:0.0.21" "@oxlint/darwin-x64": "npm:0.0.22"
"@oxlint/linux-arm64": "npm:0.0.21" "@oxlint/linux-arm64": "npm:0.0.22"
"@oxlint/linux-x64": "npm:0.0.21" "@oxlint/linux-x64": "npm:0.0.22"
"@oxlint/win32-arm64": "npm:0.0.21" "@oxlint/win32-arm64": "npm:0.0.22"
"@oxlint/win32-x64": "npm:0.0.21" "@oxlint/win32-x64": "npm:0.0.22"
dependenciesMeta: dependenciesMeta:
"@oxlint/darwin-arm64": "@oxlint/darwin-arm64":
optional: true optional: true
@@ -28589,7 +28589,7 @@ __metadata:
optional: true optional: true
bin: bin:
oxlint: bin/oxlint oxlint: bin/oxlint
checksum: 8de4a2d5252a459c0ef59634ba6bc4546da65e3c80f91c11e0d65c7df8ebb2f280e7256ef5997d5b1c18d8d98da87c6babc93fc88dd280c147c05eef93935411 checksum: 9d780f3293b08c83e45996187c8098e2ef8323ed02427c7a15d5cfa542f967b0e7862f76814ef3b8c4b94badd2f21eb92130de7f2f8f0dfec91e4a3a3797c63f
languageName: node languageName: node
linkType: hard linkType: hard