fix: add prefer-array-some rule (#5109)

This commit is contained in:
LongYinan
2023-11-29 04:43:43 +00:00
parent 23cfc58fe2
commit d267029761
5 changed files with 7 additions and 6 deletions
+1
View File
@@ -209,6 +209,7 @@ const config = {
'unicorn/no-useless-fallback-in-spread': 'error', 'unicorn/no-useless-fallback-in-spread': 'error',
'unicorn/prefer-dom-node-dataset': 'error', 'unicorn/prefer-dom-node-dataset': 'error',
'unicorn/prefer-dom-node-append': 'error', 'unicorn/prefer-dom-node-append': 'error',
'unicorn/prefer-array-some': 'error',
'sonarjs/no-all-duplicated-branches': 'error', 'sonarjs/no-all-duplicated-branches': 'error',
'sonarjs/no-element-overwrite': 'error', 'sonarjs/no-element-overwrite': 'error',
'sonarjs/no-empty-collection': 'error', 'sonarjs/no-empty-collection': 'error',
+1 -1
View File
@@ -33,7 +33,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 --import-plugin -D correctness -D nursery -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 -A no-undef -A consistent-type-exports -A default -A named -A ban-ts-comment",
"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",
@@ -130,7 +130,7 @@ export const SettingModal = ({
<WorkspaceSetting key={workspaceId} workspaceId={workspaceId} /> <WorkspaceSetting key={workspaceId} workspaceId={workspaceId} />
</Suspense> </Suspense>
) : null} ) : null}
{generalSettingList.find(v => v.key === activeTab) ? ( {generalSettingList.some(v => v.key === activeTab) ? (
<GeneralSetting generalKey={activeTab as GeneralSettingKeys} /> <GeneralSetting generalKey={activeTab as GeneralSettingKeys} />
) : null} ) : null}
{activeTab === 'account' && loginStatus === 'authenticated' ? ( {activeTab === 'account' && loginStatus === 'authenticated' ? (
+2 -2
View File
@@ -57,9 +57,9 @@ const standardizeLocale = (language: string) => {
} else if (language.slice(0, 2).toLowerCase() === 'zh') { } else if (language.slice(0, 2).toLowerCase() === 'zh') {
language = 'zh-Hant'; language = 'zh-Hant';
} }
if (LOCALES.find(locale => locale.tag === language)) return language; if (LOCALES.some(locale => locale.tag === language)) return language;
if ( if (
LOCALES.find(locale => locale.tag === language.slice(0, 2).toLowerCase()) LOCALES.some(locale => locale.tag === language.slice(0, 2).toLowerCase())
) { ) {
return language.slice(0, 2).toLowerCase(); return language.slice(0, 2).toLowerCase();
} }
@@ -143,7 +143,7 @@ const ImagePreviewModalImpl = (
if ( if (
page page
.getPreviousSiblings(block) .getPreviousSiblings(block)
.findLast( .some(
(block): block is ImageBlockModel => (block): block is ImageBlockModel =>
block.flavour === 'affine:image' block.flavour === 'affine:image'
) )
@@ -160,7 +160,7 @@ const ImagePreviewModalImpl = (
} else if ( } else if (
page page
.getNextSiblings(block) .getNextSiblings(block)
.find( .some(
(block): block is ImageBlockModel => (block): block is ImageBlockModel =>
block.flavour === 'affine:image' block.flavour === 'affine:image'
) )