style: add sonarjs/no-gratuitous-expressions rule (#9360)

This commit is contained in:
Brooooooklyn
2024-12-27 03:30:20 +00:00
parent 5eb48343a3
commit 706b614006
4 changed files with 6 additions and 5 deletions

View File

@@ -34,3 +34,4 @@ packages/frontend/graphql/src/schema.ts
packages/frontend/apps/android/App/app/build/** packages/frontend/apps/android/App/app/build/**
blocksuite/tests-legacy/snapshots blocksuite/tests-legacy/snapshots
**/.storybook **/.storybook
**/.coverage

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { import {
AutoConnectLeftIcon, AutoConnectLeftIcon,
AutoConnectRightIcon, AutoConnectRightIcon,
@@ -48,7 +47,7 @@ function calculatePosition(gap: number, count: number, iconWidth: number) {
for (let j = 0; j < count; j++) { for (let j = 0; j < count; j++) {
let left = 10; let left = 10;
if (isEven) { if (isEven) {
if (Math.abs(j - middleIndex) < 1 && isEven) { if (Math.abs(j - middleIndex) < 1) {
left = 10 + middleOffset * getSign(j); left = 10 + middleOffset * getSign(j);
} else { } else {
left = left =

View File

@@ -61,7 +61,7 @@ export const test = baseTest.extend<{}>({
}); });
if (scope) { if (scope) {
test.beforeEach(async ({ browser }, testInfo) => { test.beforeEach(async ({ browser }, testInfo) => {
if (scope && !testInfo.title.startsWith(scope)) { if (!testInfo.title.startsWith(scope!)) {
testInfo.fn = () => { testInfo.fn = () => {
testInfo.skip(); testInfo.skip();
}; };
@@ -76,9 +76,9 @@ if (scope) {
page = await browser.newPage(); page = await browser.newPage();
}); });
// eslint-disable-next-line no-empty-pattern // oxlint-disable-next-line no-empty-pattern
test.afterAll(async ({}, testInfo) => { test.afterAll(async ({}, testInfo) => {
if (!scope || !testInfo.title.startsWith(scope)) { if (!testInfo.title.startsWith(scope!)) {
return; return;
} }
const focusInSecondEditor = await page.evaluate( const focusInSecondEditor = await page.evaluate(

View File

@@ -192,6 +192,7 @@ export default tseslint.config(
'sonarjs/no-duplicated-branches': 'error', 'sonarjs/no-duplicated-branches': 'error',
'sonarjs/no-collection-size-mischeck': 'error', 'sonarjs/no-collection-size-mischeck': 'error',
'sonarjs/no-identical-functions': 'error', 'sonarjs/no-identical-functions': 'error',
'sonarjs/no-gratuitous-expressions': 'error',
'simple-import-sort/imports': 'error', 'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error', 'simple-import-sort/exports': 'error',