diff --git a/.eslintrc.js b/.eslintrc.js index 7c78fecf..cc83fed4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,7 +7,7 @@ const config = { complexity: "off", "default-case": "off", "no-use-before-define": "off", - "@typescript-eslint/no-use-before-define": "warn", + "@typescript-eslint/no-use-before-define": "off", "@typescript-eslint/no-unnecessary-condition": "off", "space-before-function-paren": [ "error", diff --git a/src/flutter/flutterMain.ts b/src/flutter/flutterMain.ts index 2fc85e82..09349ec3 100644 --- a/src/flutter/flutterMain.ts +++ b/src/flutter/flutterMain.ts @@ -4,7 +4,8 @@ import { AltRectangleNode, AltGroupNode, AltTextNode, - AltSceneNode } from "../altNodes/altMixins"; + AltSceneNode, +} from "../altNodes/altMixins"; import { numToAutoFixed } from "../common/numToAutoFixed"; import { retrieveTopFill } from "../common/retrieveFill"; import { FlutterDefaultBuilder } from "./flutterDefaultBuilder"; @@ -163,7 +164,7 @@ const makeRowColumn = (node: AltFrameNode, children: string): string => { } const crossAxisAlignment = `\ncrossAxisAlignment: CrossAxisAlignment.${crossAlignType},`; - let mainAlignType; + let mainAlignType = ""; switch (node.primaryAxisAlignItems) { case "MIN": mainAlignType = "start"; @@ -180,18 +181,16 @@ const makeRowColumn = (node: AltFrameNode, children: string): string => { } const mainAxisAlignment = `\nmainAxisAlignment: MainAxisAlignment.${mainAlignType},`; - let mainAxisSize; + let mainAxisSize = ""; if (node.layoutGrow === 1) { mainAxisSize = "\nmainAxisSize: MainAxisSize.max,"; } else { mainAxisSize = "\nmainAxisSize: MainAxisSize.min,"; } - const properties = - `${mainAxisSize + - mainAxisAlignment + - crossAxisAlignment - }\nchildren:[\n${indentString(children, 1)}\n],`; + const properties = `${ + mainAxisSize + mainAxisAlignment + crossAxisAlignment + }\nchildren:[\n${indentString(children, 1)}\n],`; return `${rowOrColumn}(${indentString(properties, 1)}\n),`; }; diff --git a/src/html/htmlMain.ts b/src/html/htmlMain.ts index 2f9d91a2..6974cbcc 100644 --- a/src/html/htmlMain.ts +++ b/src/html/htmlMain.ts @@ -285,7 +285,7 @@ export const rowColumnProps = (node: AltFrameNode, isJsx: boolean): string => { // [optimization] // when all children are STRETCH and layout is Vertical, align won't matter. Otherwise, center it. - let counterAlign: string; + let counterAlign: string = ""; switch (node.counterAxisAlignItems) { case "MIN": counterAlign = "flex-start"; diff --git a/src/html/htmlTextBuilder.ts b/src/html/htmlTextBuilder.ts index 836d8ff0..7f90de3f 100644 --- a/src/html/htmlTextBuilder.ts +++ b/src/html/htmlTextBuilder.ts @@ -7,9 +7,9 @@ import { htmlTextSize as htmlTextSizeBox } from "./builderImpl/htmlTextSize"; import { numToAutoFixed } from "./../common/numToAutoFixed"; export class HtmlTextBuilder extends HtmlDefaultBuilder { - constructor(node: AltTextNode, showLayerName: boolean, optIsJSX: boolean) { - super(node, showLayerName, optIsJSX); - } + // constructor(node: AltTextNode, showLayerName: boolean, optIsJSX: boolean) { + // super(node, showLayerName, optIsJSX); + // } // must be called before Position method textAutoSize(node: AltTextNode): this { diff --git a/src/nearest-color/nearestColor.ts b/src/nearest-color/nearestColor.ts index 5f78dcbb..0e98eaca 100644 --- a/src/nearest-color/nearestColor.ts +++ b/src/nearest-color/nearestColor.ts @@ -58,17 +58,19 @@ function nearestColor(needle: RGB | string, colors: Array): string { needle = parseColor(needle); let distanceSq; - let minDistanceSq = Infinity, - rgb, - value: ColorSpec; + let minDistanceSq = Infinity; + // eslint-disable-next-line one-var + let rgb; + // eslint-disable-next-line one-var + let value: ColorSpec; for (let i = 0; i < colors.length; ++i) { rgb = colors[i].rgb; distanceSq = - (needle.r - rgb.r)**2 + - (needle.g - rgb.g)**2 + - (needle.b - rgb.b)**2; + (needle.r - rgb.r) ** 2 + + (needle.g - rgb.g) ** 2 + + (needle.b - rgb.b) ** 2; if (distanceSq < minDistanceSq) { minDistanceSq = distanceSq; @@ -202,7 +204,7 @@ function parseColor(source: RGB | string): RGB { return { r: red, g: green, b: blue }; } - throw Error(`"${ source }" is not a valid color`); + throw Error(`"${source}" is not a valid color`); } type RGB = { @@ -211,12 +213,12 @@ type RGB = { b: number; }; -type ColorMatch = { - name: string; - value: string; - rgb: RGB; - distance: number; -}; +// type ColorMatch = { +// name: string; +// value: string; +// rgb: RGB; +// distance: number; +// }; type ColorSpec = { source: string; diff --git a/src/swiftui/builderImpl/swiftuiEffects.ts b/src/swiftui/builderImpl/swiftuiEffects.ts index 6ef0a80a..390f10da 100644 --- a/src/swiftui/builderImpl/swiftuiEffects.ts +++ b/src/swiftui/builderImpl/swiftuiEffects.ts @@ -6,8 +6,8 @@ export const swiftuiShadow = (node: AltSceneNode): string => { return ""; } - const dropShadow: Array = node.effects.filter( - (d): d is ShadowEffect => d.type === "DROP_SHADOW" && d.visible + const dropShadow: Array = node.effects.filter( + (d): d is DropShadowEffect => d.type === "DROP_SHADOW" && d.visible ); if (dropShadow.length === 0) { diff --git a/src/tailwind/builderImpl/tailwindBorder.ts b/src/tailwind/builderImpl/tailwindBorder.ts index 45af6d6d..42d29038 100644 --- a/src/tailwind/builderImpl/tailwindBorder.ts +++ b/src/tailwind/builderImpl/tailwindBorder.ts @@ -1,4 +1,4 @@ -import { AltSceneNode , AltGeometryMixin } from "../../altNodes/altMixins"; +import { AltSceneNode, AltGeometryMixin } from "../../altNodes/altMixins"; import { nearestValue, pxToBorderRadius } from "../conversionTables"; /** @@ -31,8 +31,10 @@ export const tailwindBorderRadius = (node: AltSceneNode): string => { return "rounded-full "; } else if ( (!("cornerRadius" in node) && !("topLeftRadius" in node)) || - (node.cornerRadius === figma.mixed && node.topLeftRadius === undefined) || - node.cornerRadius === 0 + ("cornerRadius" in node && + node.cornerRadius === figma.mixed && + node.topLeftRadius === undefined) || + ("cornerRadius" in node && node.cornerRadius === 0) ) { // the second condition is used on tests. On Figma, topLeftRadius is never undefined. // ignore when 0, undefined or non existent @@ -41,6 +43,10 @@ export const tailwindBorderRadius = (node: AltSceneNode): string => { let comp = ""; + if (!("cornerRadius" in node)) { + return ""; + } + if (node.cornerRadius !== figma.mixed) { if (node.cornerRadius >= node.height / 2) { // special case. If height is 90 and cornerRadius is 45, it is full. diff --git a/src/tailwind/tailwindMain.ts b/src/tailwind/tailwindMain.ts index 6239b3ab..cbe487d7 100644 --- a/src/tailwind/tailwindMain.ts +++ b/src/tailwind/tailwindMain.ts @@ -296,7 +296,7 @@ export const rowColumnProps = (node: AltFrameNode): string => { // [optimization] // when all children are STRETCH and layout is Vertical, align won't matter. Otherwise, center it. - let counterAlign: string; + let counterAlign: string = ""; switch (node.counterAxisAlignItems) { case "MIN": counterAlign = "items-start "; diff --git a/src/tailwind/vector.ts b/src/tailwind/vector.ts index 31d41502..fbf82a8e 100644 --- a/src/tailwind/vector.ts +++ b/src/tailwind/vector.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import { AltFrameNode, AltGroupNode } from "../altNodes/altMixins"; // import { TailwindDefaultBuilder } from "./tailwindDefaultBuilder";