From 8ce5dda81fb6c5a2882f5b5dac04180ce263fb04 Mon Sep 17 00:00:00 2001 From: Bu Kinoshita Date: Thu, 19 Dec 2024 12:46:19 +0000 Subject: [PATCH] fix: Minor tweak --- biome.json | 85 ++----------------- packages/button/src/utils/parse-padding.ts | 3 +- packages/button/src/utils/px-to-pt.ts | 2 +- packages/code-block/src/code-block.tsx | 3 +- packages/create-email/src/tree.js | 3 +- packages/heading/src/utils/spaces.ts | 2 +- .../src/actions/get-email-path-from-slug.ts | 9 +- .../hot-reloading/create-dependency-graph.ts | 5 +- .../src/cli/utils/preview/start-dev-server.ts | 3 +- .../utils/css/resolve-all-css-variables.ts | 3 +- 10 files changed, 23 insertions(+), 95 deletions(-) diff --git a/biome.json b/biome.json index 1844057ee3..d091abe9ea 100644 --- a/biome.json +++ b/biome.json @@ -24,93 +24,19 @@ "suspicious": { "noArrayIndexKey": "off", "noExplicitAny": "off", - "noAssignInExpressions": "off", - "noGlobalIsNan": "off" + "noAssignInExpressions": "off" }, "correctness": { "useExhaustiveDependencies": "off", "useJsxKeyInIterable": "off", - "noChildrenProp": "off", - "noConstantCondition": "off", - "noConstAssign": "off", - "noConstructorReturn": "off", - "noEmptyCharacterClassInRegex": "off", - "noEmptyPattern": "off", - "noGlobalObjectCalls": "off", - "noInnerDeclarations": "off", - "noInvalidConstructorSuper": "off", - "noInvalidNewBuiltin": "off", - "noInvalidUseBeforeDeclaration": "off", - "noNewSymbol": "off", - "noNonoctalDecimalEscape": "off", - "noPrecisionLoss": "off", - "noRenderReturnValue": "off", - "noSelfAssign": "off", - "noSetterReturn": "off", - "noStringCaseMismatch": "off", - "noSwitchDeclarations": "off", - "noUndeclaredVariables": "off", - "noUnnecessaryContinue": "off", - "noUnreachable": "off", - "noUnreachableSuper": "off", - "noUnsafeFinally": "off", - "noUnsafeOptionalChaining": "off", - "noUnusedImports": "off", - "noUnusedLabels": "off", - "noUnusedPrivateClassMembers": "off", - "noUnusedVariables": "off", - "noVoidElementsWithChildren": "off", - "noVoidTypeReturn": "off", - "useHookAtTopLevel": "off", - "useIsNan": "off", - "useValidForDirection": "off", - "useYield": "off" + "noChildrenProp": "off" }, "complexity": { "noUselessFragments": "off", - "noForEach": "off", - "useArrowFunction": "off", - "useOptionalChain": "off" + "noForEach": "off" }, "style": { - "noUselessElse": "off", - "noNonNullAssertion": "off", - "useConst": "off", - "useNodejsImportProtocol": "off", - "useSelfClosingElements": "off", - "noArguments": "off", - "noCommaOperator": "off", - "noDefaultExport": "off", - "noImplicitBoolean": "off", - "noInferrableTypes": "off", - "noNamespace": "off", - "noNamespaceImport": "off", - "noNegationElse": "off", - "noParameterAssign": "off", - "noParameterProperties": "off", - "noRestrictedGlobals": "off", - "noShoutyConstants": "off", - "noUnusedTemplateLiteral": "off", - "noVar": "off", - "useAsConstAssertion": "off", - "useBlockStatements": "off", - "useCollapsedElseIf": "off", - "useConsistentArrayType": "off", - "useDefaultParameterLast": "off", - "useEnumInitializers": "off", - "useExponentiationOperator": "off", - "useExportType": "off", - "useFilenamingConvention": "off", - "useForOf": "off", - "useFragmentSyntax": "off", - "useLiteralEnumMembers": "off", - "useNamingConvention": "off", - "useNodeAssertStrict": "off", - "useNumberNamespace": "off", - "useNumericLiterals": "off", - "useShorthandArrayType": "off", - "useSingleVarDeclarator": "off", - "useTemplate": "off" + "noNonNullAssertion": "off" }, "security": { "noDangerouslySetInnerHtml": "off" @@ -130,7 +56,8 @@ "./**/.react-email/**/*", "./**/node_modules/**/*", "./**/*.d.ts", - "./**/**/prism.ts" + "./**/**/prism.ts", + ".turbo" ] } } diff --git a/packages/button/src/utils/parse-padding.ts b/packages/button/src/utils/parse-padding.ts index 2e2cf23d55..95d257ae9d 100644 --- a/packages/button/src/utils/parse-padding.ts +++ b/packages/button/src/utils/parse-padding.ts @@ -42,9 +42,8 @@ export function convertToPx(value: PaddingType) { default: return numValue; } - } else { - return 0; } + return 0; } /** diff --git a/packages/button/src/utils/px-to-pt.ts b/packages/button/src/utils/px-to-pt.ts index cdc326f90f..df8dbfb9bd 100644 --- a/packages/button/src/utils/px-to-pt.ts +++ b/packages/button/src/utils/px-to-pt.ts @@ -1,2 +1,2 @@ export const pxToPt = (px: number): number | null => - typeof px === 'number' && !isNaN(Number(px)) ? (px * 3) / 4 : null; + typeof px === 'number' && !Number.isNaN(Number(px)) ? (px * 3) / 4 : null; diff --git a/packages/code-block/src/code-block.tsx b/packages/code-block/src/code-block.tsx index c8dfca2c61..82516ef08c 100644 --- a/packages/code-block/src/code-block.tsx +++ b/packages/code-block/src/code-block.tsx @@ -53,7 +53,8 @@ const CodeBlockLine = ({ ); - } else if (typeof token.content === 'string') { + } + if (typeof token.content === 'string') { return {token.content}; } return ( diff --git a/packages/create-email/src/tree.js b/packages/create-email/src/tree.js index 026000f9b3..bf434a066e 100644 --- a/packages/create-email/src/tree.js +++ b/packages/create-email/src/tree.js @@ -26,7 +26,8 @@ const getTreeLines = async (dirPath, depth, currentDepth = 0) => { // orders directories before files if (a.isDirectory() && b.isFile()) { return -1; - } else if (a.isFile() && b.isDirectory()) { + } + if (a.isFile() && b.isDirectory()) { return 1; } diff --git a/packages/heading/src/utils/spaces.ts b/packages/heading/src/utils/spaces.ts index 3f436b91e3..7e6e8b8d28 100644 --- a/packages/heading/src/utils/spaces.ts +++ b/packages/heading/src/utils/spaces.ts @@ -40,7 +40,7 @@ export const withSpace = ( ) => { return properties.reduce((styles, property) => { // Check to ensure string value is a valid number - if (!isNaN(Number.parseFloat(value as string))) { + if (!Number.isNaN(Number.parseFloat(value as string))) { return { ...styles, [property as keyof MarginCSSProperty]: `${value}px` }; } return styles; diff --git a/packages/react-email/src/actions/get-email-path-from-slug.ts b/packages/react-email/src/actions/get-email-path-from-slug.ts index 36c4741000..f357919d5e 100644 --- a/packages/react-email/src/actions/get-email-path-from-slug.ts +++ b/packages/react-email/src/actions/get-email-path-from-slug.ts @@ -12,11 +12,14 @@ export const getEmailPathFromSlug = async (slug: string) => { if (fs.existsSync(`${pathWithoutExtension}.tsx`)) { return `${pathWithoutExtension}.tsx`; - } else if (fs.existsSync(`${pathWithoutExtension}.jsx`)) { + } + if (fs.existsSync(`${pathWithoutExtension}.jsx`)) { return `${pathWithoutExtension}.jsx`; - } else if (fs.existsSync(`${pathWithoutExtension}.ts`)) { + } + if (fs.existsSync(`${pathWithoutExtension}.ts`)) { return `${pathWithoutExtension}.ts`; - } else if (fs.existsSync(`${pathWithoutExtension}.js`)) { + } + if (fs.existsSync(`${pathWithoutExtension}.js`)) { return `${pathWithoutExtension}.js`; } diff --git a/packages/react-email/src/cli/utils/preview/hot-reloading/create-dependency-graph.ts b/packages/react-email/src/cli/utils/preview/hot-reloading/create-dependency-graph.ts index d79ab4a1a9..d1fdce7633 100644 --- a/packages/react-email/src/cli/utils/preview/hot-reloading/create-dependency-graph.ts +++ b/packages/react-email/src/cli/utils/preview/hot-reloading/create-dependency-graph.ts @@ -157,10 +157,9 @@ export const createDependencyGraph = async (directory: string) => { } return pathToDependencyFromDirectory; - } else { - // when either the path is a module or is absolute - return dependencyPath; } + // when either the path is a module or is absolute + return dependencyPath; }, ); diff --git a/packages/react-email/src/cli/utils/preview/start-dev-server.ts b/packages/react-email/src/cli/utils/preview/start-dev-server.ts index 55ac362072..8658596c28 100644 --- a/packages/react-email/src/cli/utils/preview/start-dev-server.ts +++ b/packages/react-email/src/cli/utils/preview/start-dev-server.ts @@ -57,8 +57,7 @@ export const startDevServer = async ( try { if ( - parsedUrl.path && - parsedUrl.path.includes('static/') && + parsedUrl.path?.includes('static/') && !parsedUrl.path.includes('_next/static/') ) { void serveStaticFile(res, parsedUrl, staticBaseDirRelativePath); diff --git a/packages/tailwind/src/utils/css/resolve-all-css-variables.ts b/packages/tailwind/src/utils/css/resolve-all-css-variables.ts index fd48461935..8de51e63d3 100644 --- a/packages/tailwind/src/utils/css/resolve-all-css-variables.ts +++ b/packages/tailwind/src/utils/css/resolve-all-css-variables.ts @@ -39,8 +39,7 @@ export const resolveAllCSSVariables = (root: Root) => { if (/--[^\s]+/.test(otherDecl.prop)) { const variable = `var(${otherDecl.prop})`; if ( - variablesUsed && - variablesUsed.includes(variable) && + variablesUsed?.includes(variable) && doNodesMatch(decl.parent, otherDecl.parent) ) { if (