diff --git a/eslint.config.ts b/eslint.config.ts index 225f81d848..14f4ad9ce7 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -3,6 +3,7 @@ import url from "node:url"; import eslintJs from "@eslint/js"; import eslintMarkdown from "@eslint/markdown"; +import eslintStylistic from "@stylistic/eslint-plugin"; import eslintPluginImport from "eslint-plugin-import-x"; import eslintPluginJsdoc from "eslint-plugin-jsdoc"; import eslintPluginLocal from "@workspace/eslint-plugin-local"; @@ -128,6 +129,7 @@ export default tseslint.config( }, }, plugins: { + ["@stylistic"]: eslintStylistic, ["@susisu/safe-typescript"]: eslintPluginSafeTypeScript, ["local"]: eslintPluginLocal, ["simple-import-sort"]: eslintPluginSimpleImportSort, @@ -137,6 +139,7 @@ export default tseslint.config( { files: [...GLOB_JS, ...GLOB_TS], rules: { + curly: "warn", eqeqeq: ["error", "always"], "no-console": "error", "no-else-return": "error", @@ -195,6 +198,8 @@ export default tseslint.config( // Part: simple-import-sort rules "simple-import-sort/exports": "warn", "simple-import-sort/imports": "warn", + // Part: stylistic rules + "@stylistic/curly-newline": ["warn", "always"], // Part: perfectionist rules "perfectionist/sort-exports": "off", "perfectionist/sort-imports": "off", diff --git a/examples/dual-react-dom-lib/package.json b/examples/dual-react-dom-lib/package.json index 9e9748d5ec..4f7d71dce8 100644 --- a/examples/dual-react-dom-lib/package.json +++ b/examples/dual-react-dom-lib/package.json @@ -2,6 +2,7 @@ "name": "@examples/dual-react-dom-lib", "version": "0.0.0", "license": "MIT", + "sideEffects": false, "exports": { ".": { "import": { @@ -16,6 +17,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -29,7 +31,7 @@ "prepare": "pnpm run build" }, "devDependencies": { - "@eslint-react/eslint-plugin": "^1.23.1", + "@eslint-react/eslint-plugin": "^1.23.2", "@eslint/js": "^9.17.0", "@tsconfig/node22": "^22.0.0", "@tsconfig/strictest": "^2.0.5", @@ -46,10 +48,8 @@ "peerDependencies": { "react": "^19.0.0" }, + "packageManager": "pnpm@9.15.3", "engines": { "node": ">=18.18.0" - }, - "sideEffects": false, - "module": "dist/index.mjs", - "packageManager": "pnpm@9.15.3" + } } diff --git a/examples/next-app/package.json b/examples/next-app/package.json index e75306ca01..de60d3ad98 100644 --- a/examples/next-app/package.json +++ b/examples/next-app/package.json @@ -16,7 +16,7 @@ "react-dom": "latest" }, "devDependencies": { - "@eslint-react/eslint-plugin": "^1.23.1", + "@eslint-react/eslint-plugin": "^1.23.2", "@eslint/config-inspector": "^0.7.0", "@eslint/js": "^9.17.0", "@next/eslint-plugin-next": "^15.1.3", diff --git a/examples/vite-react-dom-app/package.json b/examples/vite-react-dom-app/package.json index 3849152f9d..2377c839e9 100644 --- a/examples/vite-react-dom-app/package.json +++ b/examples/vite-react-dom-app/package.json @@ -15,7 +15,7 @@ "react-dom": "^19.0.0" }, "devDependencies": { - "@eslint-react/eslint-plugin": "^1.23.1", + "@eslint-react/eslint-plugin": "^1.23.2", "@eslint/config-inspector": "^0.7.0", "@eslint/js": "^9.17.0", "@tsconfig/node22": "^22.0.0", diff --git a/examples/vite-react-dom-js-app/package.json b/examples/vite-react-dom-js-app/package.json index 3dffdbb946..4ffa701072 100644 --- a/examples/vite-react-dom-js-app/package.json +++ b/examples/vite-react-dom-js-app/package.json @@ -15,7 +15,7 @@ "react-dom": "^19.0.0" }, "devDependencies": { - "@eslint-react/eslint-plugin": "^1.23.1", + "@eslint-react/eslint-plugin": "^1.23.2", "@eslint/config-inspector": "^0.7.0", "@eslint/js": "^9.17.0", "@types/react": "^19.0.3", diff --git a/examples/vite-react-dom-js-with-babel-app/package.json b/examples/vite-react-dom-js-with-babel-app/package.json index 064e4cdba1..ee1cd0901b 100644 --- a/examples/vite-react-dom-js-with-babel-app/package.json +++ b/examples/vite-react-dom-js-with-babel-app/package.json @@ -19,7 +19,7 @@ "@babel/eslint-parser": "^7.25.9", "@babel/preset-env": "^7.26.0", "@babel/preset-react": "^7.26.3", - "@eslint-react/eslint-plugin": "^1.23.1", + "@eslint-react/eslint-plugin": "^1.23.2", "@eslint/config-inspector": "^0.7.0", "@eslint/js": "^9.17.0", "@types/babel__core": "~7.20.5", diff --git a/packages/core/package.json b/packages/core/package.json index 10894f295f..82287b8a4a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -13,6 +13,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -27,6 +28,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -59,7 +61,5 @@ "engines": { "bun": ">=1.0.15", "node": ">=18.18.0" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/core/src/component/component-collector-legacy.ts b/packages/core/src/component/component-collector-legacy.ts index 698463e1c9..524d6c7e95 100644 --- a/packages/core/src/component/component-collector-legacy.ts +++ b/packages/core/src/component/component-collector-legacy.ts @@ -14,7 +14,9 @@ import { ERClassComponentFlag } from "./component-flag"; * @returns `true` if the node is a class component, `false` otherwise */ export function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClass { - if (!("superClass" in node && node.superClass)) return false; + if (!("superClass" in node && node.superClass)) { + return false; + } const { superClass } = node; return match(superClass) .with({ @@ -87,7 +89,9 @@ export function useComponentCollectorLegacy() { } as const; const collect = (node: AST.TSESTreeClass) => { - if (!isClassComponent(node)) return; + if (!isClassComponent(node)) { + return; + } const id = AST.getClassIdentifier(node); const key = getId(); const flag = isPureComponent(node) diff --git a/packages/core/src/component/component-collector.ts b/packages/core/src/component/component-collector.ts index e6fcb0fd11..dca99248f5 100644 --- a/packages/core/src/component/component-collector.ts +++ b/packages/core/src/component/component-collector.ts @@ -79,7 +79,9 @@ export function useComponentCollector( }; const onFunctionExit = () => { const { key, node, isComponent } = functionEntries.at(-1) ?? {}; - if (!key || !node || !isComponent) return functionEntries.pop(); + if (!key || !node || !isComponent) { + return functionEntries.pop(); + } const shouldDrop = AST.getNestedReturnStatements(node.body) .slice() .reverse() @@ -88,7 +90,9 @@ export function useComponentCollector( && r.argument !== null && !JSX.isJSXValue(r.argument, jsxCtx, hint); }); - if (shouldDrop) components.delete(key); + if (shouldDrop) { + components.delete(key); + } return functionEntries.pop(); }; @@ -107,13 +111,17 @@ export function useComponentCollector( ":function[type]:exit": onFunctionExit, "ArrowFunctionExpression[type][body.type!='BlockStatement']"() { const mbEntry = getCurrentFunction(); - if (O.isNone(mbEntry)) return; + if (O.isNone(mbEntry)) { + return; + } const entry = mbEntry.value; const { body } = entry.node; const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint); - if (!isComponent) return; + if (!isComponent) { + return; + } const initPath = AST.getFunctionInitPath(entry.node); const id = getFunctionComponentIdentifier(entry.node, context); const name = O.flatMapNullable(id, getComponentNameFromIdentifier); @@ -138,33 +146,45 @@ export function useComponentCollector( const mbComponentName = match(left.object) .with({ type: T.Identifier }, n => O.some(n.name)) .otherwise(O.none); - if (O.isNone(mbComponentName)) return; + if (O.isNone(mbComponentName)) { + return; + } const componentName = mbComponentName.value; const component = Array .from(components.values()) .findLast(({ name }) => O.exists(name, n => n === componentName)); - if (!component) return; + if (!component) { + return; + } components.set(component._, { ...component, displayName: O.some(right), }); }, "CallExpression[type]:exit"(node: TSESTree.CallExpression) { - if (!isReactHookCall(node)) return; + if (!isReactHookCall(node)) { + return; + } const mbEntry = getCurrentFunction(); - if (O.isNone(mbEntry)) return; + if (O.isNone(mbEntry)) { + return; + } const entry = mbEntry.value; functionEntries.pop(); functionEntries.push({ ...entry, hookCalls: [...entry.hookCalls, node] }); }, "ReturnStatement[type]"(node: TSESTree.ReturnStatement) { const mbEntry = getCurrentFunction(); - if (O.isNone(mbEntry)) return; + if (O.isNone(mbEntry)) { + return; + } const entry = mbEntry.value; const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint); - if (!isComponent) return; + if (!isComponent) { + return; + } functionEntries.pop(); functionEntries.push({ ...entry, isComponent }); const initPath = AST.getFunctionInitPath(entry.node); diff --git a/packages/core/src/component/component-id.ts b/packages/core/src/component/component-id.ts index 0a593ef9c3..4a2fbd3bb6 100644 --- a/packages/core/src/component/component-id.ts +++ b/packages/core/src/component/component-id.ts @@ -8,7 +8,9 @@ import { isReactHookCallWithNameLoose } from "../hook"; import { isForwardRefCall, isMemoCall } from "../utils"; function isComponentWrapperCall(node: TSESTree.Node, context: RuleContext) { - if (node.type !== T.CallExpression) return false; + if (node.type !== T.CallExpression) { + return false; + } return isMemoCall(node, context) || isForwardRefCall(node, context) || isReactHookCallWithNameLoose(node)("useCallback"); @@ -19,7 +21,9 @@ export function getFunctionComponentIdentifier( context: RuleContext, ): O.Option { const functionId = AST.getFunctionIdentifier(node); - if (O.isSome(functionId)) return functionId; + if (O.isSome(functionId)) { + return functionId; + } const { parent } = node; // Get function component identifier from `const Component = memo(() => {});` if ( diff --git a/packages/core/src/component/component-render-method.ts b/packages/core/src/component/component-render-method.ts index 4d57ece75c..b1afdb7c68 100644 --- a/packages/core/src/component/component-render-method.ts +++ b/packages/core/src/component/component-render-method.ts @@ -21,7 +21,9 @@ const isRenderMethodLike = isMatching({ }); export function isFunctionOfRenderMethod(node: AST.TSESTreeFunction) { - if (!isRenderMethodLike(node.parent)) return false; + if (!isRenderMethodLike(node.parent)) { + return false; + } return isClassComponent(node.parent.parent.parent); } diff --git a/packages/core/src/effect/is.ts b/packages/core/src/effect/is.ts index 8351ae3416..65cb64f57f 100644 --- a/packages/core/src/effect/is.ts +++ b/packages/core/src/effect/is.ts @@ -15,9 +15,13 @@ export function isSetupFunction(node: TSESTree.Node) { export function isCleanupFunction(node: TSESTree.Node) { const nearestRet = O.getOrNull(AST.findParentNodeGuard(node, AST.is(T.ReturnStatement))); - if (!nearestRet) return false; + if (!nearestRet) { + return false; + } const nearestFunction = O.getOrNull(AST.findParentNodeGuard(node, AST.isFunction)); const nearestFunctionOfRet = O.getOrNull(AST.findParentNodeGuard(nearestRet, AST.isFunction)); - if (!nearestFunction || !nearestFunctionOfRet) return false; + if (!nearestFunction || !nearestFunctionOfRet) { + return false; + } return nearestFunction === nearestFunctionOfRet && isSetupFunction(nearestFunction); } diff --git a/packages/core/src/element/get-element-represent-name.ts b/packages/core/src/element/get-element-represent-name.ts index e66823ecba..13adfccc4f 100644 --- a/packages/core/src/element/get-element-represent-name.ts +++ b/packages/core/src/element/get-element-represent-name.ts @@ -6,10 +6,14 @@ import type { TSESTree } from "@typescript-eslint/types"; export function getElementRepresentName(node: TSESTree.JSXOpeningElement, context: RuleContext) { const rawElementName = JSX.getElementName(node); - if (rawElementName === rawElementName.toLowerCase()) return rawElementName; + if (rawElementName === rawElementName.toLowerCase()) { + return rawElementName; + } const { components, polymorphicPropName } = getSettingsFromContext(context); const asElementName = components.get(rawElementName); - if (isString(asElementName)) return asElementName; + if (isString(asElementName)) { + return asElementName; + } return F.pipe( O.fromNullable(polymorphicPropName), O.flatMap(JSX.findPropInAttributes(node.attributes, context.sourceCode.getScope(node))), diff --git a/packages/core/src/hook/hook-collector.ts b/packages/core/src/hook/hook-collector.ts index 74be702b24..9ac89a8889 100644 --- a/packages/core/src/hook/hook-collector.ts +++ b/packages/core/src/hook/hook-collector.ts @@ -45,9 +45,13 @@ export function useHookCollector() { ":function[type]": onFunctionEnter, ":function[type]:exit": onFunctionExit, "CallExpression[type]"(node) { - if (!isReactHookCall(node)) return; + if (!isReactHookCall(node)) { + return; + } const [fNode, hookId] = fStack.at(-1) ?? []; - if (!fNode || !hookId) return; + if (!fNode || !hookId) { + return; + } F.pipe( O.Do, O.bind("id", () => hookId), diff --git a/packages/core/src/hook/is.ts b/packages/core/src/hook/is.ts index cffbf18ba7..7f958c9ceb 100644 --- a/packages/core/src/hook/is.ts +++ b/packages/core/src/hook/is.ts @@ -22,8 +22,12 @@ export function isReactHook(node: AST.TSESTreeFunction) { * @returns `true` if the node is a React Hook call, `false` otherwise. */ export function isReactHookCall(node: TSESTree.Node) { - if (node.type !== T.CallExpression) return false; - if (node.callee.type === T.Identifier) return isReactHookName(node.callee.name); + if (node.type !== T.CallExpression) { + return false; + } + if (node.callee.type === T.Identifier) { + return isReactHookName(node.callee.name); + } if (node.callee.type === T.MemberExpression) { return node.callee.property.type === T.Identifier && isReactHookName(node.callee.property.name); } @@ -86,7 +90,9 @@ export function isReactHookCallWithNameAlias(name: string, context: RuleContext, } export function isUseEffectCallLoose(node: TSESTree.Node) { - if (node.type !== T.CallExpression) return false; + if (node.type !== T.CallExpression) { + return false; + } switch (node.callee.type) { case T.Identifier: return /^use\w*Effect$/u.test(node.callee.name); diff --git a/packages/core/src/render-prop/is.ts b/packages/core/src/render-prop/is.ts index 7081b8f56f..c9fc35c239 100644 --- a/packages/core/src/render-prop/is.ts +++ b/packages/core/src/render-prop/is.ts @@ -48,7 +48,9 @@ export function isRenderFunctionLoose(node: AST.TSESTreeFunction, context: RuleC * @returns `true` if node is a render prop, `false` if not */ export function isRenderPropLoose(node: TSESTree.JSXAttribute, context: RuleContext) { - if (node.name.type !== T.JSXIdentifier) return false; + if (node.name.type !== T.JSXIdentifier) { + return false; + } return node.name.name.startsWith("render") && node.value?.type === T.JSXExpressionContainer && AST.isFunction(node.value.expression) diff --git a/packages/core/src/utils/is-from-react.ts b/packages/core/src/utils/is-from-react.ts index d45a7bf1ed..ea0e18d542 100644 --- a/packages/core/src/utils/is-from-react.ts +++ b/packages/core/src/utils/is-from-react.ts @@ -56,8 +56,12 @@ export function isFromReactMember( ) => { const settings = unsafeDecodeSettings(context.settings); if (!settings.strictImportCheck) { - if (node.property.type !== T.Identifier || node.property.name !== name) return false; - if (node.object.type === T.Identifier && node.object.name === memberName) return true; + if (node.property.type !== T.Identifier || node.property.name !== name) { + return false; + } + if (node.object.type === T.Identifier && node.object.name === memberName) { + return true; + } if ( node.object.type === T.MemberExpression && node.object.object.type === T.Identifier @@ -68,7 +72,9 @@ export function isFromReactMember( return false; } const initialScope = context.sourceCode.getScope(node); - if (node.property.type !== T.Identifier || node.property.name !== name) return false; + if (node.property.type !== T.Identifier || node.property.name !== name) { + return false; + } if (node.object.type === T.Identifier && node.object.name === memberName) { return isInitializedFromReact(node.object.name, initialScope, settings.importSource); } @@ -91,8 +97,12 @@ type IsCallFromReact = { export function isCallFromReact(name: string): IsCallFromReact { return F.dual(2, (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression => { - if (node.type !== T.CallExpression) return false; - if (!AST.isOneOf([T.Identifier, T.MemberExpression])(node.callee)) return false; + if (node.type !== T.CallExpression) { + return false; + } + if (!AST.isOneOf([T.Identifier, T.MemberExpression])(node.callee)) { + return false; + } return isFromReact(name)(node.callee, context); }); } @@ -120,8 +130,12 @@ export function isCallFromReactMember( & TSESTree.CallExpression & { callee: TSESTree.MemberExpression } => { - if (node.type !== T.CallExpression) return false; - if (!AST.is(T.MemberExpression)(node.callee)) return false; + if (node.type !== T.CallExpression) { + return false; + } + if (!AST.is(T.MemberExpression)(node.callee)) { + return false; + } return isFromReactMember(pragmaMemberName, name)(node.callee, context); }); } diff --git a/packages/plugins/eslint-plugin-react-debug/package.json b/packages/plugins/eslint-plugin-react-debug/package.json index bfb78f8feb..b450df44e8 100644 --- a/packages/plugins/eslint-plugin-react-debug/package.json +++ b/packages/plugins/eslint-plugin-react-debug/package.json @@ -21,6 +21,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -35,6 +36,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "./dist/index.d.ts", "files": [ "dist", @@ -85,7 +87,5 @@ }, "publishConfig": { "access": "public" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/plugins/eslint-plugin-react-debug/src/rules/is-from-react.ts b/packages/plugins/eslint-plugin-react-debug/src/rules/is-from-react.ts index a6451ef022..4e7045b98a 100644 --- a/packages/plugins/eslint-plugin-react-debug/src/rules/is-from-react.ts +++ b/packages/plugins/eslint-plugin-react-debug/src/rules/is-from-react.ts @@ -62,10 +62,14 @@ export default createRule<[], MessageID>({ const shouldSkipDuplicate = node.parent.type === T.ImportSpecifier && node.parent.imported === node && node.parent.imported.name === node.parent.local.name; - if (shouldSkipDuplicate) return O.none(); + if (shouldSkipDuplicate) { + return O.none(); + } const name = node.name; const initialScope = context.sourceCode.getScope(node); - if (!isFromReact(node, initialScope)) return O.none(); + if (!isFromReact(node, initialScope)) { + return O.none(); + } return O.some({ messageId: "isFromReact", node, diff --git a/packages/plugins/eslint-plugin-react-dom/package.json b/packages/plugins/eslint-plugin-react-dom/package.json index a46b72b89d..fca1999274 100644 --- a/packages/plugins/eslint-plugin-react-dom/package.json +++ b/packages/plugins/eslint-plugin-react-dom/package.json @@ -21,6 +21,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -35,6 +36,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -85,7 +87,5 @@ }, "publishConfig": { "access": "public" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/plugins/eslint-plugin-react-dom/src/rules/no-dangerously-set-innerhtml-with-children.ts b/packages/plugins/eslint-plugin-react-dom/src/rules/no-dangerously-set-innerhtml-with-children.ts index 98c9c3fc8f..e066973474 100644 --- a/packages/plugins/eslint-plugin-react-dom/src/rules/no-dangerously-set-innerhtml-with-children.ts +++ b/packages/plugins/eslint-plugin-react-dom/src/rules/no-dangerously-set-innerhtml-with-children.ts @@ -44,7 +44,9 @@ export default createRule<[], MessageID>({ const hasChildrenProp = () => JSX.hasProp(node.openingElement.attributes, "children", initialScope); // dprint-ignore const hasDanger = () => JSX.hasProp(node.openingElement.attributes, "dangerouslySetInnerHTML", initialScope); - if (!(hasChildrenWithIn() || hasChildrenProp()) || !hasDanger()) return; + if (!(hasChildrenWithIn() || hasChildrenProp()) || !hasDanger()) { + return; + } context.report({ messageId: "noDangerouslySetInnerhtmlWithChildren", node, diff --git a/packages/plugins/eslint-plugin-react-dom/src/rules/no-missing-button-type.ts b/packages/plugins/eslint-plugin-react-dom/src/rules/no-missing-button-type.ts index 7946825e4e..0f9999c41c 100644 --- a/packages/plugins/eslint-plugin-react-dom/src/rules/no-missing-button-type.ts +++ b/packages/plugins/eslint-plugin-react-dom/src/rules/no-missing-button-type.ts @@ -32,11 +32,15 @@ export default createRule<[], MessageID>({ return { JSXElement(node) { const elementName = getElementRepresentName(node.openingElement, context); - if (elementName !== "button") return; + if (elementName !== "button") { + return; + } const { attributes } = node.openingElement; const initialScope = context.sourceCode.getScope(node); const mbProp = JSX.findPropInAttributes(attributes, initialScope)("type"); - if (O.isSome(mbProp)) return; + if (O.isSome(mbProp)) { + return; + } context.report({ messageId: "noMissingButtonType", node, diff --git a/packages/plugins/eslint-plugin-react-dom/src/rules/no-missing-iframe-sandbox.ts b/packages/plugins/eslint-plugin-react-dom/src/rules/no-missing-iframe-sandbox.ts index 86d281b17e..d67c39a4b3 100644 --- a/packages/plugins/eslint-plugin-react-dom/src/rules/no-missing-iframe-sandbox.ts +++ b/packages/plugins/eslint-plugin-react-dom/src/rules/no-missing-iframe-sandbox.ts @@ -51,7 +51,9 @@ export default createRule<[], MessageID>({ return { JSXElement(node) { const elementName = getElementRepresentName(node.openingElement, context); - if (elementName !== "iframe") return; + if (elementName !== "iframe") { + return; + } const { attributes } = node.openingElement; const initialScope = context.sourceCode.getScope(node); const mbProp = JSX.findPropInAttributes(attributes, initialScope)("sandbox"); @@ -69,7 +71,9 @@ export default createRule<[], MessageID>({ O.map((value) => value.split(" ")), O.exists((values) => values.every((value) => validTypes.some((validType) => validType === value))), ); - if (hasValidSandbox) return; + if (hasValidSandbox) { + return; + } context.report({ messageId: "noMissingIframeSandbox", node: prop, diff --git a/packages/plugins/eslint-plugin-react-dom/src/rules/no-namespace.ts b/packages/plugins/eslint-plugin-react-dom/src/rules/no-namespace.ts index 93e84d5bff..9fefa60833 100644 --- a/packages/plugins/eslint-plugin-react-dom/src/rules/no-namespace.ts +++ b/packages/plugins/eslint-plugin-react-dom/src/rules/no-namespace.ts @@ -30,7 +30,9 @@ export default createRule<[], MessageID>({ return { JSXOpeningElement(node) { const name = JSX.getElementName(node); - if (!isString(name) || !name.includes(":")) return; + if (!isString(name) || !name.includes(":")) { + return; + } context.report({ messageId: "noNamespace", node, diff --git a/packages/plugins/eslint-plugin-react-dom/src/rules/no-render-return-value.ts b/packages/plugins/eslint-plugin-react-dom/src/rules/no-render-return-value.ts index c62316bc97..2016bc463b 100644 --- a/packages/plugins/eslint-plugin-react-dom/src/rules/no-render-return-value.ts +++ b/packages/plugins/eslint-plugin-react-dom/src/rules/no-render-return-value.ts @@ -38,9 +38,15 @@ export default createRule<[], MessageID>({ return { CallExpression(node) { const { callee, parent } = node; - if (callee.type !== T.MemberExpression) return; - if (callee.object.type !== T.Identifier) return; - if (!("name" in callee.object)) return; + if (callee.type !== T.MemberExpression) { + return; + } + if (callee.object.type !== T.Identifier) { + return; + } + if (!("name" in callee.object)) { + return; + } const objectName = callee.object.name; if ( objectName.toLowerCase() !== "reactdom" diff --git a/packages/plugins/eslint-plugin-react-dom/src/rules/no-script-url.ts b/packages/plugins/eslint-plugin-react-dom/src/rules/no-script-url.ts index 57b369fb01..e69027f822 100644 --- a/packages/plugins/eslint-plugin-react-dom/src/rules/no-script-url.ts +++ b/packages/plugins/eslint-plugin-react-dom/src/rules/no-script-url.ts @@ -35,7 +35,9 @@ export default createRule<[], MessageID>({ create(context) { return { JSXAttribute(node) { - if (node.name.type !== T.JSXIdentifier || !node.value) return; + if (node.name.type !== T.JSXIdentifier || !node.value) { + return; + } const isJavaScript = F.pipe( JSX.getPropValue(node, context.sourceCode.getScope(node)), O.filter(isString), diff --git a/packages/plugins/eslint-plugin-react-dom/src/rules/no-unsafe-iframe-sandbox.ts b/packages/plugins/eslint-plugin-react-dom/src/rules/no-unsafe-iframe-sandbox.ts index 275a89ec0b..5db5960171 100644 --- a/packages/plugins/eslint-plugin-react-dom/src/rules/no-unsafe-iframe-sandbox.ts +++ b/packages/plugins/eslint-plugin-react-dom/src/rules/no-unsafe-iframe-sandbox.ts @@ -38,11 +38,15 @@ export default createRule<[], MessageID>({ return { JSXElement(node) { const elementName = getElementRepresentName(node.openingElement, context); - if (elementName !== "iframe") return; + if (elementName !== "iframe") { + return; + } const { attributes } = node.openingElement; const initialScope = context.sourceCode.getScope(node); const mbProp = JSX.findPropInAttributes(attributes, initialScope)("sandbox"); - if (O.isNone(mbProp)) return; + if (O.isNone(mbProp)) { + return; + } const prop = mbProp.value; const isSafeSandboxValue = !F.pipe( JSX.getPropValue(prop, context.sourceCode.getScope(prop)), @@ -58,7 +62,9 @@ export default createRule<[], MessageID>({ unsafeCombinations.some(combinations => combinations.every(unsafeValue => values.includes(unsafeValue))) ), ); - if (isSafeSandboxValue) return; + if (isSafeSandboxValue) { + return; + } context.report({ messageId: "noUnsafeIframeSandbox", node: prop, diff --git a/packages/plugins/eslint-plugin-react-dom/src/rules/no-unsafe-target-blank.ts b/packages/plugins/eslint-plugin-react-dom/src/rules/no-unsafe-target-blank.ts index fb5db78136..6208c7858e 100644 --- a/packages/plugins/eslint-plugin-react-dom/src/rules/no-unsafe-target-blank.ts +++ b/packages/plugins/eslint-plugin-react-dom/src/rules/no-unsafe-target-blank.ts @@ -49,7 +49,9 @@ export default createRule<[], MessageID>({ function getReportDescriptor(node: TSESTree.JSXElement): O.Option> { const name = JSX.getElementName(node.openingElement); const elementName = getElementRepresentName(node.openingElement, context); - if (elementName !== "a" && !additionalComponents.some(c => c.re.test(name))) return O.none(); + if (elementName !== "a" && !additionalComponents.some(c => c.re.test(name))) { + return O.none(); + } const { attributes } = node.openingElement; const initialScope = context.sourceCode.getScope(node); const additionalAttributes = additionalComponents @@ -74,7 +76,9 @@ export default createRule<[], MessageID>({ ), O.filter(isString), ); - if (!O.exists(targetPropValue, t => t === "_blank")) return O.none(); + if (!O.exists(targetPropValue, t => t === "_blank")) { + return O.none(); + } const [ hrefPropName, hrefPropDefaultValue, @@ -93,7 +97,9 @@ export default createRule<[], MessageID>({ ), O.filter(isString), ); - if (!O.exists(hrefPropValue, isExternalLinkLike)) return O.none(); + if (!O.exists(hrefPropValue, isExternalLinkLike)) { + return O.none(); + } const [ relPropName, relPropDefaultValue, @@ -112,7 +118,9 @@ export default createRule<[], MessageID>({ ), O.filter(isString), ); - if (O.exists(relPropValue, isSafeRel)) return O.none(); + if (O.exists(relPropValue, isSafeRel)) { + return O.none(); + } return O.some({ messageId: "noUnsafeTargetBlank", node, diff --git a/packages/plugins/eslint-plugin-react-dom/src/rules/no-void-elements-with-children.ts b/packages/plugins/eslint-plugin-react-dom/src/rules/no-void-elements-with-children.ts index f134c80903..7411e80937 100644 --- a/packages/plugins/eslint-plugin-react-dom/src/rules/no-void-elements-with-children.ts +++ b/packages/plugins/eslint-plugin-react-dom/src/rules/no-void-elements-with-children.ts @@ -50,7 +50,9 @@ export default createRule<[], MessageID>({ return { JSXElement(node) { const elementName = JSX.getElementName(node.openingElement); - if (!elementName || !voidElements.has(elementName)) return; + if (!elementName || !voidElements.has(elementName)) { + return; + } if (node.children.length > 0) { context.report({ messageId: "noVoidElementsWithChildren", diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/package.json b/packages/plugins/eslint-plugin-react-hooks-extra/package.json index f7b8157c60..938db86021 100644 --- a/packages/plugins/eslint-plugin-react-hooks-extra/package.json +++ b/packages/plugins/eslint-plugin-react-hooks-extra/package.json @@ -22,6 +22,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -36,6 +37,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -86,7 +88,5 @@ }, "publishConfig": { "access": "public" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-direct-set-state-in-use-effect.ts b/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-direct-set-state-in-use-effect.ts index 983a23b0c8..baed7c5632 100644 --- a/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-direct-set-state-in-use-effect.ts +++ b/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-direct-set-state-in-use-effect.ts @@ -42,7 +42,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!/use\w*Effect/u.test(context.sourceCode.text)) return {}; + if (!/use\w*Effect/u.test(context.sourceCode.text)) { + return {}; + } const settings = getSettingsFromContext(context); const additionalHooks = settings.additionalHooks ?? {}; @@ -110,10 +112,14 @@ export default createRule<[], MessageID>({ CallExpression(node) { const setupFunction = O.getOrNull(setupFunctionRef.current); const pEntry = functionStack.at(-1); - if (pEntry?.node.async) return; + if (pEntry?.node.async) { + return; + } match(getCallKind(node)) .with("setState", () => { - if (!pEntry) return; + if (!pEntry) { + return; + } switch (true) { case pEntry.node === setupFunction || pEntry.kind === "immediate": { @@ -141,41 +147,59 @@ export default createRule<[], MessageID>({ }) // .with(P.union("useMemo", "useCallback"), () => {}) .with("useEffect", () => { - if (AST.isFunction(node.arguments.at(0))) return; + if (AST.isFunction(node.arguments.at(0))) { + return; + } setupFunctionIdentifiers.push(...AST.getNestedIdentifiers(node)); }) .with("other", () => { - if (pEntry?.node !== setupFunction) return; + if (pEntry?.node !== setupFunction) { + return; + } indFunctionCalls.push(node); }) .otherwise(F.constVoid); }, Identifier(node) { - if (node.parent.type === T.CallExpression && node.parent.callee === node) return; - if (!isIdFromUseStateCall(node)) return; + if (node.parent.type === T.CallExpression && node.parent.callee === node) { + return; + } + if (!isIdFromUseStateCall(node)) { + return; + } switch (node.parent.type) { case T.ArrowFunctionExpression: { const parent = node.parent.parent; - if (parent.type !== T.CallExpression) break; + if (parent.type !== T.CallExpression) { + break; + } // const [state, setState] = useState(); // const set = useMemo(() => setState, []); // useEffect(set, []); - if (!isUseMemoCall(parent)) break; + if (!isUseMemoCall(parent)) { + break; + } const mbVariableDeclarator = AST.findParentNodeGuard(parent, isVariableDeclaratorFromHookCall); - if (O.isNone(mbVariableDeclarator)) break; + if (O.isNone(mbVariableDeclarator)) { + break; + } const variableDeclarator = mbVariableDeclarator.value; const calls = indSetStateCallsInUseEffectArg0.get(variableDeclarator.init) ?? []; indSetStateCallsInUseEffectArg0.set(variableDeclarator.init, [...calls, node]); break; } case T.CallExpression: { - if (node !== node.parent.arguments.at(0)) break; + if (node !== node.parent.arguments.at(0)) { + break; + } // const [state, setState] = useState(); // const set = useCallback(setState, []); // useEffect(set, []); if (isUseCallbackCall(node.parent)) { const mbVariableDeclarator = AST.findParentNodeGuard(node.parent, isVariableDeclaratorFromHookCall); - if (O.isNone(mbVariableDeclarator)) break; + if (O.isNone(mbVariableDeclarator)) { + break; + } const variableDeclarator = mbVariableDeclarator.value; const prevs = indSetStateCallsInUseEffectArg0.get(variableDeclarator.init) ?? []; indSetStateCallsInUseEffectArg0.set(variableDeclarator.init, [...prevs, node]); @@ -216,7 +240,9 @@ export default createRule<[], MessageID>({ } } for (const { callee } of indFunctionCalls) { - if (!("name" in callee)) continue; + if (!("name" in callee)) { + continue; + } const { name } = callee; const setStateCalls = getSetStateCalls(name, context.sourceCode.getScope(callee)); for (const setStateCall of setStateCalls) { diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-direct-set-state-in-use-layout-effect.ts b/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-direct-set-state-in-use-layout-effect.ts index c8fb3ad13d..5e00d87f48 100644 --- a/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-direct-set-state-in-use-layout-effect.ts +++ b/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-direct-set-state-in-use-layout-effect.ts @@ -43,7 +43,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!/use\w*Effect/u.test(context.sourceCode.text)) return {}; + if (!/use\w*Effect/u.test(context.sourceCode.text)) { + return {}; + } const settings = getSettingsFromContext(context); const additionalHooks = settings.additionalHooks ?? {}; @@ -115,10 +117,14 @@ export default createRule<[], MessageID>({ CallExpression(node) { const setupFunction = O.getOrNull(setupFunctionRef.current); const pEntry = functionStack.at(-1); - if (pEntry?.node.async) return; + if (pEntry?.node.async) { + return; + } match(getCallKind(node)) .with("setState", () => { - if (!pEntry) return; + if (!pEntry) { + return; + } switch (true) { case pEntry.node === setupFunction || pEntry.kind === "immediate": { @@ -146,41 +152,59 @@ export default createRule<[], MessageID>({ }) // .with(P.union("useMemo", "useCallback"), () => {}) .with("useLayoutEffect", () => { - if (AST.isFunction(node.arguments.at(0))) return; + if (AST.isFunction(node.arguments.at(0))) { + return; + } setupFunctionIdentifiers.push(...AST.getNestedIdentifiers(node)); }) .with("other", () => { - if (pEntry?.node !== setupFunction) return; + if (pEntry?.node !== setupFunction) { + return; + } indFunctionCalls.push(node); }) .otherwise(F.constVoid); }, Identifier(node) { - if (node.parent.type === T.CallExpression && node.parent.callee === node) return; - if (!isIdFromUseStateCall(node)) return; + if (node.parent.type === T.CallExpression && node.parent.callee === node) { + return; + } + if (!isIdFromUseStateCall(node)) { + return; + } switch (node.parent.type) { case T.ArrowFunctionExpression: { const parent = node.parent.parent; - if (parent.type !== T.CallExpression) break; + if (parent.type !== T.CallExpression) { + break; + } // const [state, setState] = useState(); // const set = useMemo(() => setState, []); // useLayoutEffect(set, []); - if (!isUseMemoCall(parent)) break; + if (!isUseMemoCall(parent)) { + break; + } const mbVariableDeclarator = AST.findParentNodeGuard(parent, isVariableDeclaratorFromHookCall); - if (O.isNone(mbVariableDeclarator)) break; + if (O.isNone(mbVariableDeclarator)) { + break; + } const variableDeclarator = mbVariableDeclarator.value; const calls = indSetStateCallsInUseLayoutEffectArg0.get(variableDeclarator.init) ?? []; indSetStateCallsInUseLayoutEffectArg0.set(variableDeclarator.init, [...calls, node]); break; } case T.CallExpression: { - if (node !== node.parent.arguments.at(0)) break; + if (node !== node.parent.arguments.at(0)) { + break; + } // const [state, setState] = useState(); // const set = useCallback(setState, []); // useLayoutEffect(set, []); if (isUseCallbackCall(node.parent)) { const mbVariableDeclarator = AST.findParentNodeGuard(node.parent, isVariableDeclaratorFromHookCall); - if (O.isNone(mbVariableDeclarator)) break; + if (O.isNone(mbVariableDeclarator)) { + break; + } const variableDeclarator = mbVariableDeclarator.value; const prevs = indSetStateCallsInUseLayoutEffectArg0.get(variableDeclarator.init) ?? []; indSetStateCallsInUseLayoutEffectArg0.set(variableDeclarator.init, [...prevs, node]); @@ -222,7 +246,9 @@ export default createRule<[], MessageID>({ } } for (const { callee } of indFunctionCalls) { - if (!("name" in callee)) continue; + if (!("name" in callee)) { + continue; + } const { name } = callee; const setStateCalls = getSetStateCalls(name, context.sourceCode.getScope(callee)); for (const setStateCall of setStateCalls) { diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-unnecessary-use-callback.ts b/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-unnecessary-use-callback.ts index ef013b6baa..891da24478 100644 --- a/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-unnecessary-use-callback.ts +++ b/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-unnecessary-use-callback.ts @@ -33,18 +33,28 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("use")) return {}; + if (!context.sourceCode.text.includes("use")) { + return {}; + } const alias = getSettingsFromContext(context).additionalHooks?.useCallback ?? []; return { CallExpression(node) { - if (!isReactHookCall(node)) return; + if (!isReactHookCall(node)) { + return; + } const initialScope = context.sourceCode.getScope(node); - if (!isUseCallbackCall(node, context) && !alias.some(isReactHookCallWithNameLoose(node))) return; + if (!isUseCallbackCall(node, context) && !alias.some(isReactHookCallWithNameLoose(node))) { + return; + } const scope = context.sourceCode.getScope(node); const component = scope.block; - if (!AST.isFunction(component)) return; + if (!AST.isFunction(component)) { + return; + } const [arg0, arg1] = node.arguments; - if (!arg0 || !arg1) return; + if (!arg0 || !arg1) { + return; + } const hasEmptyDeps = F.pipe( match(arg1) .with({ type: T.ArrayExpression }, O.some) @@ -58,7 +68,9 @@ export default createRule<[], MessageID>({ .otherwise(O.none), O.exists(x => x.elements.length === 0), ); - if (!hasEmptyDeps) return; + if (!hasEmptyDeps) { + return; + } const isReferencedToComponentScope = F.pipe( match(arg0) .with({ type: T.ArrowFunctionExpression }, n => { diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-unnecessary-use-memo.ts b/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-unnecessary-use-memo.ts index 604248015a..0cbe327067 100644 --- a/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-unnecessary-use-memo.ts +++ b/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-unnecessary-use-memo.ts @@ -32,24 +32,36 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("use")) return {}; + if (!context.sourceCode.text.includes("use")) { + return {}; + } const alias = getSettingsFromContext(context).additionalHooks?.useMemo ?? []; return { CallExpression(node) { - if (!isReactHookCall(node)) return; + if (!isReactHookCall(node)) { + return; + } const initialScope = context.sourceCode.getScope(node); - if (!isUseMemoCall(node, context) && !alias.some(isReactHookCallWithNameLoose(node))) return; + if (!isUseMemoCall(node, context) && !alias.some(isReactHookCallWithNameLoose(node))) { + return; + } const scope = context.sourceCode.getScope(node); const component = scope.block; - if (!AST.isFunction(component)) return; + if (!AST.isFunction(component)) { + return; + } const [arg0, arg1] = node.arguments; - if (!arg0 || !arg1) return; + if (!arg0 || !arg1) { + return; + } const hasCallInArg0 = F.pipe( O.some(arg0), O.filter(n => AST.isFunction(n)), O.exists(n => [...AST.getNestedCallExpressions(n.body), ...AST.getNestedNewExpressions(n.body)].length > 0), ); - if (hasCallInArg0) return; + if (hasCallInArg0) { + return; + } const hasEmptyDeps = F.pipe( match(arg1) .with({ type: T.ArrayExpression }, O.some) @@ -63,7 +75,9 @@ export default createRule<[], MessageID>({ .otherwise(O.none), O.exists(x => x.elements.length === 0), ); - if (!hasEmptyDeps) return; + if (!hasEmptyDeps) { + return; + } const isReferencedToComponentScope = F.pipe( match(arg0) .with({ type: T.ArrowFunctionExpression }, n => { diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-useless-custom-hooks.ts b/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-useless-custom-hooks.ts index 75fcc2650b..395ba696fe 100644 --- a/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-useless-custom-hooks.ts +++ b/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-useless-custom-hooks.ts @@ -44,11 +44,17 @@ export default createRule<[], MessageID>({ const allHooks = ctx.getAllHooks(node); for (const { name, node, hookCalls } of allHooks.values()) { // Skip empty functions - if (AST.isEmptyFunction(node)) continue; + if (AST.isEmptyFunction(node)) { + continue; + } // Skip useful hooks - if (hookCalls.length > 0) continue; + if (hookCalls.length > 0) { + continue; + } // Skip hooks with comments that contain calls to other hooks - if (isNodeContainsUseCallComments(node, context)) continue; + if (isNodeContainsUseCallComments(node, context)) { + continue; + } context.report({ messageId: "noUselessCustomHooks", node, diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/prefer-use-state-lazy-initialization.ts b/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/prefer-use-state-lazy-initialization.ts index 82bbdab051..b13d250fe4 100644 --- a/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/prefer-use-state-lazy-initialization.ts +++ b/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/prefer-use-state-lazy-initialization.ts @@ -34,14 +34,22 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("use")) return {}; + if (!context.sourceCode.text.includes("use")) { + return {}; + } const alias = getSettingsFromContext(context).additionalHooks?.useState ?? []; return { CallExpression(node) { - if (!isReactHookCall(node)) return; - if (!isUseStateCall(node, context) && !alias.some(isReactHookCallWithNameLoose(node))) return; + if (!isReactHookCall(node)) { + return; + } + if (!isUseStateCall(node, context) && !alias.some(isReactHookCallWithNameLoose(node))) { + return; + } const [useStateInput] = node.arguments; - if (!useStateInput) return; + if (!useStateInput) { + return; + } const nestedCallExpressions = AST.getNestedCallExpressions(useStateInput); const hasFunctionCall = nestedCallExpressions.some((n) => { return "name" in n.callee @@ -51,7 +59,9 @@ export default createRule<[], MessageID>({ return "name" in n.callee && !ALLOW_LIST.includes(n.callee.name); }); - if (!hasFunctionCall && !hasNewCall) return; + if (!hasFunctionCall && !hasNewCall) { + return; + } context.report({ messageId: "preferUseStateLazyInitialization", node: useStateInput, diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-from-use-state-call.ts b/packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-from-use-state-call.ts index b8b48620a8..5ff1bcc77b 100644 --- a/packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-from-use-state-call.ts +++ b/packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-from-use-state-call.ts @@ -8,7 +8,9 @@ import { isFromHookCall } from "./is-from-hook-call"; export function isFromUseStateCall(context: RuleContext, settings: ESLintReactSettings) { const predicate = (topLevelId: TSESTree.Identifier, call: TSESTree.CallExpression) => { const { parent } = call; - if (!("id" in parent && parent.id?.type === T.ArrayPattern)) return true; + if (!("id" in parent && parent.id?.type === T.ArrayPattern)) { + return true; + } return parent.id.elements.findIndex(e => e?.type === T.Identifier && e.name === topLevelId.name) === 1; }; return isFromHookCall("useState", context, settings, predicate); diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-set-function-call.ts b/packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-set-function-call.ts index accf23cdee..7775669141 100644 --- a/packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-set-function-call.ts +++ b/packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-set-function-call.ts @@ -16,8 +16,12 @@ export function isSetFunctionCall(context: RuleContext, settings: ESLintReactSet // data.at(1)(); case T.CallExpression: { const { callee } = node.callee; - if (callee.type !== T.MemberExpression) return false; - if (!("name" in callee.object)) return false; + if (callee.type !== T.MemberExpression) { + return false; + } + if (!("name" in callee.object)) { + return false; + } const isAt = isMatching({ type: T.MemberExpression, property: { @@ -26,7 +30,9 @@ export function isSetFunctionCall(context: RuleContext, settings: ESLintReactSet }, }, callee); const [index] = node.callee.arguments; - if (!isAt || !index) return false; + if (!isAt || !index) { + return false; + } const initialScope = context.sourceCode.getScope(node); return O.exists(VAR.getStaticValue(index, initialScope), (v) => v === 1) && isIdFromUseStateCall(callee.object); @@ -39,7 +45,9 @@ export function isSetFunctionCall(context: RuleContext, settings: ESLintReactSet // const data = useState(); // data[1](); case T.MemberExpression: { - if (!("name" in node.callee.object)) return false; + if (!("name" in node.callee.object)) { + return false; + } const initialScope = context.sourceCode.getScope(node); return O.exists(VAR.getStaticValue(node.callee.property, initialScope), (v) => v === 1) && isIdFromUseStateCall(node.callee.object); diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-variable-declarator-from-hook-call.ts b/packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-variable-declarator-from-hook-call.ts index b9395176f4..e109a215b0 100644 --- a/packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-variable-declarator-from-hook-call.ts +++ b/packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-variable-declarator-from-hook-call.ts @@ -13,9 +13,15 @@ export function isVariableDeclaratorFromHookCall(node: TSESTree.Node): node is } & TSESTree.VariableDeclarator { - if (node.type !== T.VariableDeclarator) return false; - if (node.id.type !== T.Identifier) return false; - if (node.init?.type !== T.CallExpression) return false; + if (node.type !== T.VariableDeclarator) { + return false; + } + if (node.id.type !== T.Identifier) { + return false; + } + if (node.init?.type !== T.CallExpression) { + return false; + } switch (node.init.callee.type) { case T.Identifier: return isReactHookName(node.init.callee.name); diff --git a/packages/plugins/eslint-plugin-react-naming-convention/package.json b/packages/plugins/eslint-plugin-react-naming-convention/package.json index db43d6d91e..9b2d4085c4 100644 --- a/packages/plugins/eslint-plugin-react-naming-convention/package.json +++ b/packages/plugins/eslint-plugin-react-naming-convention/package.json @@ -21,6 +21,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -35,6 +36,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -84,7 +86,5 @@ }, "publishConfig": { "access": "public" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/plugins/eslint-plugin-react-naming-convention/src/rules/component-name.ts b/packages/plugins/eslint-plugin-react-naming-convention/src/rules/component-name.ts index 2d8bc52b4b..6902fc81f1 100644 --- a/packages/plugins/eslint-plugin-react-naming-convention/src/rules/component-name.ts +++ b/packages/plugins/eslint-plugin-react-naming-convention/src/rules/component-name.ts @@ -75,8 +75,12 @@ const schema = [ function normalizeOptions(options: Options) { const [opts] = options; - if (isNullable(opts)) return defaultOptions[0]; - if (isString(opts)) return { ...defaultOptions[0], rule: opts } as const; + if (isNullable(opts)) { + return defaultOptions[0]; + } + if (isString(opts)) { + return { ...defaultOptions[0], rule: opts } as const; + } return { ...opts, excepts: opts.excepts?.map(pattern => new RegExp(pattern, "u")) ?? [], @@ -84,7 +88,9 @@ function normalizeOptions(options: Options) { } function validate(name: string, options: ReturnType) { - if (options.excepts.some((regex) => regex.test(name))) return true; + if (options.excepts.some((regex) => regex.test(name))) { + return true; + } let normalized = name .normalize("NFKD") .replace(/[\u0300-\u036F]/g, ""); @@ -99,7 +105,9 @@ function validate(name: string, options: ReturnType) { .with("CONSTANT_CASE", () => RE_CONSTANT_CASE.test(normalized)) .with("PascalCase", () => { // Allow all caps if the string is shorter than 4 characters. e.g. UI, CSS, SVG, etc. - if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) return options.allowAllCaps; + if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) { + return options.allowAllCaps; + } return RE_PASCAL_CASE.test(normalized); }) .otherwise(F.constFalse); @@ -129,8 +137,12 @@ export default createRule({ ...collectorLegacy.listeners, JSXOpeningElement(node) { const name = JSX.getElementName(node); - if (/^[a-z]/u.test(name)) return; - if (validate(name, options)) return; + if (/^[a-z]/u.test(name)) { + return; + } + if (validate(name, options)) { + return; + } context.report({ messageId: "componentName", node, @@ -144,9 +156,13 @@ export default createRule({ const classComponents = collectorLegacy.ctx.getAllComponents(node); for (const { node: component } of functionComponents.values()) { const mbId = AST.getFunctionIdentifier(component); - if (O.isNone(mbId)) continue; + if (O.isNone(mbId)) { + continue; + } const id = mbId.value; - if (validate(id.name, options)) continue; + if (validate(id.name, options)) { + continue; + } context.report({ messageId: "componentName", node: id, diff --git a/packages/plugins/eslint-plugin-react-naming-convention/src/rules/filename-extension.ts b/packages/plugins/eslint-plugin-react-naming-convention/src/rules/filename-extension.ts index 0d14f05762..af55817dfb 100644 --- a/packages/plugins/eslint-plugin-react-naming-convention/src/rules/filename-extension.ts +++ b/packages/plugins/eslint-plugin-react-naming-convention/src/rules/filename-extension.ts @@ -110,7 +110,9 @@ export default createRule({ const hasCode = node.body.length > 0; const ignoreFilesWithoutCode = isObject(options) && options.ignoreFilesWithoutCode; - if (!hasCode && ignoreFilesWithoutCode) return; + if (!hasCode && ignoreFilesWithoutCode) { + return; + } if ( !hasJSXNode && isJSXExt diff --git a/packages/plugins/eslint-plugin-react-naming-convention/src/rules/filename.ts b/packages/plugins/eslint-plugin-react-naming-convention/src/rules/filename.ts index ff85932890..94cf08846f 100644 --- a/packages/plugins/eslint-plugin-react-naming-convention/src/rules/filename.ts +++ b/packages/plugins/eslint-plugin-react-naming-convention/src/rules/filename.ts @@ -139,7 +139,9 @@ export default createRule({ context.report({ messageId: "filenameEmpty", node }); return; } - if (validate(basename)) return; + if (validate(basename)) { + return; + } context.report({ messageId: "filenameCaseMismatchSuggestion", node, diff --git a/packages/plugins/eslint-plugin-react-naming-convention/src/rules/use-state.ts b/packages/plugins/eslint-plugin-react-naming-convention/src/rules/use-state.ts index edb26608f9..d6598c8a91 100644 --- a/packages/plugins/eslint-plugin-react-naming-convention/src/rules/use-state.ts +++ b/packages/plugins/eslint-plugin-react-naming-convention/src/rules/use-state.ts @@ -47,10 +47,16 @@ export default createRule<[], MessageID>({ "Program:exit"(node) { const components = ctx.getAllComponents(node); for (const { hookCalls } of components.values()) { - if (hookCalls.length === 0) continue; + if (hookCalls.length === 0) { + continue; + } for (const hookCall of hookCalls) { - if (!isUseStateCall(hookCall, context) && !alias.some(isReactHookCallWithNameLoose(hookCall))) continue; - if (hookCall.parent.type !== T.VariableDeclarator) continue; + if (!isUseStateCall(hookCall, context) && !alias.some(isReactHookCallWithNameLoose(hookCall))) { + continue; + } + if (hookCall.parent.type !== T.VariableDeclarator) { + continue; + } const { id } = hookCall.parent; const descriptor = O.some({ messageId: "useState", node: id } as const); F.pipe( @@ -68,7 +74,9 @@ export default createRule<[], MessageID>({ } const [stateName, setStateName] = [state.name, setState.name]; const expectedSetterName = `set${capitalize(stateName)}`; - if (setStateName === expectedSetterName) return O.none(); + if (setStateName === expectedSetterName) { + return O.none(); + } return descriptor; }) .otherwise(O.none), diff --git a/packages/plugins/eslint-plugin-react-web-api/package.json b/packages/plugins/eslint-plugin-react-web-api/package.json index 34c5bd475a..dc9af0e5b2 100644 --- a/packages/plugins/eslint-plugin-react-web-api/package.json +++ b/packages/plugins/eslint-plugin-react-web-api/package.json @@ -21,6 +21,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -35,6 +36,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -84,7 +86,5 @@ }, "publishConfig": { "access": "public" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-event-listener.ts b/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-event-listener.ts index 5f3e24ac19..cc4045f930 100644 --- a/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-event-listener.ts +++ b/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-event-listener.ts @@ -89,7 +89,9 @@ function getOptions(node: TSESTree.CallExpressionArgument, initialScope: Scope): return JSX.findPropInProperties(properties, initialScope)(propName); }; const getPropValue = (prop: TSESTree.Property | TSESTree.RestElement | TSESTree.SpreadElement) => { - if (prop.type !== T.Property) return O.none(); + if (prop.type !== T.Property) { + return O.none(); + } const { value } = prop; switch (value.type) { case T.Literal: { @@ -122,7 +124,9 @@ function getOptions(node: TSESTree.CallExpressionArgument, initialScope: Scope): const vCapture = O.flatMap(pCapture, getPropValue).pipe(O.filter(isBoolean)); const pSignal = findProp(node.properties, "signal"); const vSignal = O.flatMap(pSignal, prop => { - if (prop.type !== T.Property) return O.none(); + if (prop.type !== T.Property) { + return O.none(); + } const { value } = prop; return getSignalValueExpression(value, initialScope); }); @@ -159,8 +163,12 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("addEventListener")) return {}; - if (!/use\w*Effect|componentDidMount|componentWillUnmount/u.test(context.sourceCode.text)) return {}; + if (!context.sourceCode.text.includes("addEventListener")) { + return {}; + } + if (!/use\w*Effect|componentDidMount|componentWillUnmount/u.test(context.sourceCode.text)) { + return {}; + } const fStack: [node: AST.TSESTreeFunction, kind: FunctionKind][] = []; const aEntries: AEntry[] = []; const rEntries: REntry[] = []; @@ -178,7 +186,9 @@ export default createRule<[], MessageID>({ function isInverseEntry(aEntry: AEntry, rEntry: REntry) { const { type: aType, callee: aCallee, capture: aCapture, listener: aListener, phase: aPhase } = aEntry; const { type: rType, callee: rCallee, capture: rCapture, listener: rListener, phase: rPhase } = rEntry; - if (!isInversePhase(aPhase, rPhase)) return false; + if (!isInversePhase(aPhase, rPhase)) { + return false; + } return isSameObject(aCallee, rCallee) && AST.isNodeEqual(aListener, rListener) && VAR.isNodeValueEqual(aType, rType, [ @@ -193,8 +203,12 @@ export default createRule<[], MessageID>({ options: typeof defaultOptions, ): O.Option> { const [_, listener] = node.arguments; - if (!AST.isFunction(listener)) return O.none(); - if (O.isSome(options.signal)) return O.none(); + if (!AST.isFunction(listener)) { + return O.none(); + } + if (O.isSome(options.signal)) { + return O.none(); + } return O.some({ messageId: "noLeakedEventListenerOfInlineFunction", node: listener, @@ -211,12 +225,18 @@ export default createRule<[], MessageID>({ }, ["CallExpression"](node) { const [fNode, fKind] = fStack.findLast(f => f.at(1) !== "other") ?? []; - if (!fNode || !fKind) return; - if (!ERPhaseRelevance.has(fKind)) return; + if (!fNode || !fKind) { + return; + } + if (!ERPhaseRelevance.has(fKind)) { + return; + } match(getCallKind(node)) .with("addEventListener", (callKind) => { const [type, listener, options] = node.arguments; - if (!type || !listener) return; + if (!type || !listener) { + return; + } const opts = options ? getOptions(options, context.sourceCode.getScope(options)) : defaultOptions; const { callee } = node; O.map(checkInlineFunction(node, callKind, opts), context.report); @@ -232,7 +252,9 @@ export default createRule<[], MessageID>({ }) .with("removeEventListener", (callKind) => { const [type, listener, options] = node.arguments; - if (!type || !listener) return; + if (!type || !listener) { + return; + } const opts = options ? getOptions(options, context.sourceCode.getScope(options)) : defaultOptions; const { callee } = node; O.map(checkInlineFunction(node, callKind, opts), context.report); @@ -253,8 +275,12 @@ export default createRule<[], MessageID>({ }, ["Program:exit"]() { for (const aEntry of aEntries) { - if (O.exists(aEntry.signal, signal => abortedSignals.some(as => isSameObject(as, signal)))) continue; - if (rEntries.some(rEntry => isInverseEntry(aEntry, rEntry))) continue; + if (O.exists(aEntry.signal, signal => abortedSignals.some(as => isSameObject(as, signal)))) { + continue; + } + if (rEntries.some(rEntry => isInverseEntry(aEntry, rEntry))) { + continue; + } switch (aEntry.phase) { case "setup": case "cleanup": diff --git a/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-interval.ts b/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-interval.ts index 23fcbf2461..04169bfa9d 100644 --- a/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-interval.ts +++ b/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-interval.ts @@ -75,7 +75,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("setInterval")) return {}; + if (!context.sourceCode.text.includes("setInterval")) { + return {}; + } const fStack: [node: AST.TSESTreeFunction, kind: FunctionKind][] = []; const sEntries: TimerEntry[] = []; const cEntries: TimerEntry[] = []; @@ -94,8 +96,12 @@ export default createRule<[], MessageID>({ switch (getCallKind(node)) { case "setInterval": { const [fNode, fKind] = fStack.findLast(f => f.at(1) !== "other") ?? []; - if (!fNode || !fKind) break; - if (!ERPhaseRelevance.has(fKind)) break; + if (!fNode || !fKind) { + break; + } + if (!ERPhaseRelevance.has(fKind)) { + break; + } const intervalIdNode = O.getOrNull(VAR.getVariableDeclaratorID(node)); if (!intervalIdNode) { context.report({ @@ -115,10 +121,16 @@ export default createRule<[], MessageID>({ } case "clearInterval": { const [fNode, fKind] = fStack.findLast(f => f.at(1) !== "other") ?? []; - if (!fNode || !fKind) break; - if (!ERPhaseRelevance.has(fKind)) break; + if (!fNode || !fKind) { + break; + } + if (!ERPhaseRelevance.has(fKind)) { + break; + } const [intervalIdNode] = node.arguments; - if (!intervalIdNode) break; + if (!intervalIdNode) { + break; + } cEntries.push({ kind: "interval", node, @@ -132,7 +144,9 @@ export default createRule<[], MessageID>({ }, ["Program:exit"]() { for (const sEntry of sEntries) { - if (cEntries.some(cEntry => isInverseEntry(sEntry, cEntry))) continue; + if (cEntries.some(cEntry => isInverseEntry(sEntry, cEntry))) { + continue; + } switch (sEntry.phase) { case "setup": case "cleanup": diff --git a/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-resize-observer.ts b/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-resize-observer.ts index d54b998852..ce818afe09 100644 --- a/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-resize-observer.ts +++ b/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-resize-observer.ts @@ -105,7 +105,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("ResizeObserver")) return {}; + if (!context.sourceCode.text.includes("ResizeObserver")) { + return {}; + } const fStack: [node: AST.TSESTreeFunction, kind: FunctionKind][] = []; const observers: [ node: TSESTree.NewExpression, @@ -126,8 +128,12 @@ export default createRule<[], MessageID>({ }, ["CallExpression"](node) { const [_, fKind] = fStack.findLast(f => f.at(1) !== "other") ?? []; - if (node.callee.type !== T.MemberExpression) return; - if (!ERPhaseRelevance.has(fKind)) return; + if (node.callee.type !== T.MemberExpression) { + return; + } + if (!ERPhaseRelevance.has(fKind)) { + return; + } const { object } = node.callee; match(getCallKind(node, context)) .with("disconnect", () => { @@ -142,7 +148,9 @@ export default createRule<[], MessageID>({ }) .with("observe", () => { const [element] = node.arguments; - if (!element) return; + if (!element) { + return; + } oEntries.push({ kind: "observe", node, @@ -155,7 +163,9 @@ export default createRule<[], MessageID>({ }) .with("unobserve", () => { const [element] = node.arguments; - if (!element) return; + if (!element) { + return; + } uEntries.push({ kind: "unobserve", node, @@ -170,8 +180,12 @@ export default createRule<[], MessageID>({ }, ["NewExpression"](node) { const [fNode, fKind] = fStack.findLast(f => f.at(1) !== "other") ?? []; - if (!fNode || !ERPhaseRelevance.has(fKind)) return; - if (!isNewResizeObserver(node)) return; + if (!fNode || !ERPhaseRelevance.has(fKind)) { + return; + } + if (!isNewResizeObserver(node)) { + return; + } const id = getInstanceID(node); if (O.isNone(id)) { context.report({ @@ -184,7 +198,9 @@ export default createRule<[], MessageID>({ }, ["Program:exit"]() { for (const [node, id, _, phaseNode] of observers) { - if (dEntries.some(e => isInstanceIDEqual(e.observer, id, context))) continue; + if (dEntries.some(e => isInstanceIDEqual(e.observer, id, context))) { + continue; + } const oentries = oEntries.filter(e => isInstanceIDEqual(e.observer, id, context)); const uentries = uEntries.filter(e => isInstanceIDEqual(e.observer, id, context)); const isDynamic = or(AST.isConditional, AST.is(T.CallExpression)); @@ -196,7 +212,9 @@ export default createRule<[], MessageID>({ continue; } for (const oEntry of oentries) { - if (uentries.some(uEntry => isInstanceIDEqual(uEntry.element, oEntry.element, context))) continue; + if (uentries.some(uEntry => isInstanceIDEqual(uEntry.element, oEntry.element, context))) { + continue; + } context.report({ messageId: "noLeakedResizeObserver", node: oEntry.node }); } } diff --git a/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-timeout.ts b/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-timeout.ts index e112425f78..0ec7795d4f 100644 --- a/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-timeout.ts +++ b/packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-timeout.ts @@ -74,7 +74,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("setTimeout")) return {}; + if (!context.sourceCode.text.includes("setTimeout")) { + return {}; + } const fStack: [node: AST.TSESTreeFunction, kind: FunctionKind][] = []; const sEntries: TimerEntry[] = []; const rEntries: TimerEntry[] = []; @@ -91,8 +93,12 @@ export default createRule<[], MessageID>({ }, ["CallExpression"](node) { const [fNode, fKind] = fStack.findLast(f => f.at(1) !== "other") ?? []; - if (!fNode || !fKind) return; - if (!ERPhaseRelevance.has(fKind)) return; + if (!fNode || !fKind) { + return; + } + if (!ERPhaseRelevance.has(fKind)) { + return; + } switch (getCallKind(node)) { case "setTimeout": { const timeoutIdNode = O.getOrNull(VAR.getVariableDeclaratorID(node)); @@ -114,7 +120,9 @@ export default createRule<[], MessageID>({ } case "clearTimeout": { const [timeoutIdNode] = node.arguments; - if (!timeoutIdNode) break; + if (!timeoutIdNode) { + break; + } rEntries.push({ kind: "timeout", node, @@ -128,7 +136,9 @@ export default createRule<[], MessageID>({ }, ["Program:exit"]() { for (const sEntry of sEntries) { - if (rEntries.some(rEntry => isInverseEntry(sEntry, rEntry))) continue; + if (rEntries.some(rEntry => isInverseEntry(sEntry, rEntry))) { + continue; + } switch (sEntry.phase) { case "setup": case "cleanup": diff --git a/packages/plugins/eslint-plugin-react-x/package.json b/packages/plugins/eslint-plugin-react-x/package.json index 5ce744205d..743239afa0 100644 --- a/packages/plugins/eslint-plugin-react-x/package.json +++ b/packages/plugins/eslint-plugin-react-x/package.json @@ -20,6 +20,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -34,6 +35,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -87,7 +89,5 @@ }, "publishConfig": { "access": "public" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/ensure-forward-ref-using-ref.ts b/packages/plugins/eslint-plugin-react-x/src/rules/ensure-forward-ref-using-ref.ts index 7bbec77410..351f7f900f 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/ensure-forward-ref-using-ref.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/ensure-forward-ref-using-ref.ts @@ -30,11 +30,17 @@ export default createRule<[], MessageID>({ create(context) { return { CallExpression(node) { - if (!isForwardRefCall(node, context)) return; + if (!isForwardRefCall(node, context)) { + return; + } const [component] = node.arguments; - if (!component || !AST.isFunction(component)) return; + if (!component || !AST.isFunction(component)) { + return; + } const [_, ref] = component.params; - if (ref) return; + if (ref) { + return; + } context.report({ messageId: "ensureForwardRefUsingRef", node: component, diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-access-state-in-setstate.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-access-state-in-setstate.ts index 78ef7f210b..0a6bdfdfba 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-access-state-in-setstate.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-access-state-in-setstate.ts @@ -47,7 +47,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("setState")) return {}; + if (!context.sourceCode.text.includes("setState")) { + return {}; + } const classStack: [ node: TSESTree.ClassDeclaration | TSESTree.ClassExpression, isComponent: boolean, @@ -62,11 +64,15 @@ export default createRule<[], MessageID>({ ][] = []; return { CallExpression(node) { - if (!isThisSetState(node)) return; + if (!isThisSetState(node)) { + return; + } setStateStack.push([node, false]); }, "CallExpression:exit"(node) { - if (!isThisSetState(node)) return; + if (!isThisSetState(node)) { + return; + } setStateStack.pop(); }, ClassDeclaration(node) { @@ -82,14 +88,24 @@ export default createRule<[], MessageID>({ classStack.pop(); }, MemberExpression(node) { - if (!AST.isThisExpression(node.object)) return; + if (!AST.isThisExpression(node.object)) { + return; + } const [currClass, isComponent] = classStack.at(-1) ?? []; - if (!currClass || !isComponent) return; + if (!currClass || !isComponent) { + return; + } const [currMethod, isStatic] = methodStack.at(-1) ?? []; - if (!currMethod || isStatic) return; + if (!currMethod || isStatic) { + return; + } const [setState, hasThisState] = setStateStack.at(-1) ?? []; - if (!setState || hasThisState) return; - if (!O.exists(getName(node.property), name => name === "state")) return; + if (!setState || hasThisState) { + return; + } + if (!O.exists(getName(node.property), name => name === "state")) { + return; + } context.report({ messageId: "noAccessStateInSetstate", node }); }, MethodDefinition(node) { @@ -106,20 +122,30 @@ export default createRule<[], MessageID>({ }, VariableDeclarator(node) { const [currClass, isComponent] = classStack.at(-1) ?? []; - if (!currClass || !isComponent) return; + if (!currClass || !isComponent) { + return; + } const [currMethod, isStatic] = methodStack.at(-1) ?? []; - if (!currMethod || isStatic) return; + if (!currMethod || isStatic) { + return; + } const [setState, hasThisState] = setStateStack.at(-1) ?? []; - if (!setState || hasThisState) return; + if (!setState || hasThisState) { + return; + } // detect `{ foo, state: baz } = this` - if (!(node.init && AST.isThisExpression(node.init) && node.id.type === T.ObjectPattern)) return; + if (!(node.init && AST.isThisExpression(node.init) && node.id.type === T.ObjectPattern)) { + return; + } const hasState = node.id.properties.some(prop => { if (prop.type === T.Property && AST.isKeyLiteralLike(prop, prop.key)) { return O.exists(getName(prop.key), name => name === "state"); } return false; }); - if (!hasState) return; + if (!hasState) { + return; + } context.report({ messageId: "noAccessStateInSetstate", node }); }, }; diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-array-index-key.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-array-index-key.ts index bf5e0e513b..09625922b9 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-array-index-key.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-array-index-key.ts @@ -67,9 +67,13 @@ function isUsingReactChildren(node: TSESTree.CallExpression, context: RuleContex if (!("property" in callee) || !("object" in callee) || !("name" in callee.property)) { return false; } - if (!isReactChildrenMethod(callee.property.name)) return false; + if (!isReactChildrenMethod(callee.property.name)) { + return false; + } const initialScope = context.sourceCode.getScope(node); - if (callee.object.type === T.Identifier && callee.object.name === "Children") return true; + if (callee.object.type === T.Identifier && callee.object.name === "Children") { + return true; + } if (callee.object.type === T.MemberExpression && "name" in callee.object.object) { return isInitializedFromReact(callee.object.object.name, initialScope, settings.importSource); } @@ -78,19 +82,31 @@ function isUsingReactChildren(node: TSESTree.CallExpression, context: RuleContex function getMapIndexParamName(node: TSESTree.CallExpression, context: RuleContext) { const { callee } = node; - if (callee.type !== T.MemberExpression) return O.none(); - if (callee.property.type !== T.Identifier) return O.none(); + if (callee.type !== T.MemberExpression) { + return O.none(); + } + if (callee.property.type !== T.Identifier) { + return O.none(); + } const { name } = callee.property; - if (!iteratorFunctionIndexParamPosition.has(name)) return O.none(); + if (!iteratorFunctionIndexParamPosition.has(name)) { + return O.none(); + } const callbackArg = node.arguments[isUsingReactChildren(node, context) ? 1 : 0]; - if (!callbackArg) return O.none(); + if (!callbackArg) { + return O.none(); + } if (!AST.isOneOf([T.ArrowFunctionExpression, T.FunctionExpression])(callbackArg)) { return O.none(); } const { params } = callbackArg; const indexParamPosition = iteratorFunctionIndexParamPosition.get(name); - if (isNullable(indexParamPosition)) return O.none(); - if (params.length < indexParamPosition + 1) return O.none(); + if (isNullable(indexParamPosition)) { + return O.none(); + } + if (params.length < indexParamPosition + 1) { + return O.none(); + } const param = params.at(indexParamPosition); return param && "name" in param ? O.some(param.name) : O.none(); @@ -124,21 +140,27 @@ export default createRule<[], MessageID>({ function getReportDescriptor(node: TSESTree.Node): ReportDescriptor[] { // key={bar} - if (isArrayIndex(node)) return [{ messageId: "noArrayIndexKey", node }]; + if (isArrayIndex(node)) { + return [{ messageId: "noArrayIndexKey", node }]; + } // key={`foo-${bar}`} or key={'foo' + bar} if (AST.isOneOf([T.TemplateLiteral, T.BinaryExpression])(node)) { const exps = T.TemplateLiteral === node.type ? node.expressions : AST.getIdentifiersFromBinaryExpression(node); return exps.reduce[]>((acc, exp) => { - if (isArrayIndex(exp)) return [...acc, { messageId: "noArrayIndexKey", node: exp }]; + if (isArrayIndex(exp)) { + return [...acc, { messageId: "noArrayIndexKey", node: exp }]; + } return acc; }, []); } // key={bar.toString()} if (isToStringCall(node)) { - if (!("object" in node.callee && isArrayIndex(node.callee.object))) return []; + if (!("object" in node.callee && isArrayIndex(node.callee.object))) { + return []; + } return [{ messageId: "noArrayIndexKey", node: node.callee.object }]; } @@ -152,7 +174,9 @@ export default createRule<[], MessageID>({ }, node); if (isStringCall) { const [arg] = node.arguments; - if (arg && isArrayIndex(arg)) return [{ messageId: "noArrayIndexKey", node: arg }]; + if (arg && isArrayIndex(arg)) { + return [{ messageId: "noArrayIndexKey", node: arg }]; + } } return []; @@ -161,13 +185,23 @@ export default createRule<[], MessageID>({ return { CallExpression(node) { indexParamNames.push(getMapIndexParamName(node, context)); - if (node.arguments.length === 0) return; - if (!isCreateOrCloneElementCall(node)) return; + if (node.arguments.length === 0) { + return; + } + if (!isCreateOrCloneElementCall(node)) { + return; + } const [_, props] = node.arguments; - if (props?.type !== T.ObjectExpression) return; + if (props?.type !== T.ObjectExpression) { + return; + } for (const prop of props.properties) { - if (!isMatching({ key: { name: "key" } })(prop)) continue; - if (!("value" in prop)) continue; + if (!isMatching({ key: { name: "key" } })(prop)) { + continue; + } + if (!("value" in prop)) { + continue; + } const descriptors = getReportDescriptor(prop.value); for (const descriptor of descriptors) { context.report(descriptor); @@ -178,10 +212,16 @@ export default createRule<[], MessageID>({ indexParamNames.pop(); }, JSXAttribute(node) { - if (node.name.name !== "key") return; - if (indexParamNames.length === 0) return; + if (node.name.name !== "key") { + return; + } + if (indexParamNames.length === 0) { + return; + } const { value } = node; - if (value?.type !== T.JSXExpressionContainer) return; + if (value?.type !== T.JSXExpressionContainer) { + return; + } const descriptors = getReportDescriptor(value.expression); for (const descriptor of descriptors) { context.report(descriptor); diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-class-component.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-class-component.ts index 3cd9ed825f..bb50d54657 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-class-component.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-class-component.ts @@ -47,7 +47,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("Component")) return {}; + if (!context.sourceCode.text.includes("Component")) { + return {}; + } const { ctx, listeners } = useComponentCollectorLegacy(); return { @@ -56,7 +58,9 @@ export default createRule<[], MessageID>({ const components = ctx.getAllComponents(node); for (const { name, node: component } of components.values()) { - if (component.body.body.some(m => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) continue; + if (component.body.body.some(m => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) { + continue; + } context.report({ messageId: "noClassComponent", node: component, diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-clone-element.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-clone-element.ts index 8c1810f6a4..2ce6a1be81 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-clone-element.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-clone-element.ts @@ -28,7 +28,9 @@ export default createRule<[], MessageID>({ create(context) { return { CallExpression(node) { - if (!isCloneElementCall(node, context)) return; + if (!isCloneElementCall(node, context)) { + return; + } context.report({ messageId: "noCloneElement", node, diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-comment-textnodes.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-comment-textnodes.ts index 4fa716fb97..4d6d6eb996 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-comment-textnodes.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-comment-textnodes.ts @@ -32,14 +32,22 @@ export default createRule<[], MessageID>({ name: RULE_NAME, create(context) { function hasCommentLike(node: TSESTree.JSXText | TSESTree.Literal) { - if (AST.isOneOf([T.JSXAttribute, T.JSXExpressionContainer])(node.parent)) return false; + if (AST.isOneOf([T.JSXAttribute, T.JSXExpressionContainer])(node.parent)) { + return false; + } const rawValue = context.sourceCode.getText(node); return /^\s*\/(?:\/|\*)/mu.test(rawValue); } const getReportDescriptor = (node: TSESTree.JSXText | TSESTree.Literal): O.Option> => { - if (!AST.isOneOf([T.JSXElement, T.JSXFragment])(node.parent)) return O.none(); - if (!hasCommentLike(node)) return O.none(); - if (!node.parent.type.includes("JSX")) return O.none(); + if (!AST.isOneOf([T.JSXElement, T.JSXFragment])(node.parent)) { + return O.none(); + } + if (!hasCommentLike(node)) { + return O.none(); + } + if (!node.parent.type.includes("JSX")) { + return O.none(); + } return O.some({ messageId: "noCommentTextnodes", node, diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-complex-conditional-rendering.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-complex-conditional-rendering.ts index 335578ff90..879e3fc171 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-complex-conditional-rendering.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-complex-conditional-rendering.ts @@ -33,11 +33,15 @@ export default createRule<[], MessageID>({ create(context) { function getReportDescriptor(node: TSESTree.Node): O.Option> { const jsxExpContainer = node.parent?.parent; - if (!AST.is(T.JSXExpressionContainer)(jsxExpContainer)) return O.none(); + if (!AST.is(T.JSXExpressionContainer)(jsxExpContainer)) { + return O.none(); + } if (!AST.isOneOf([T.JSXElement, T.JSXFragment])(jsxExpContainer.parent)) { return O.none(); } - if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) return O.none(); + if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) { + return O.none(); + } return O.some({ messageId: "noComplexConditionalRendering", node: jsxExpContainer }); } const visitorFunction = F.flow(getReportDescriptor, O.map(context.report), F.constVoid); diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-mount.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-mount.ts index 31cf9c9964..097032d83b 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-mount.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-mount.ts @@ -37,7 +37,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("componentWillMount")) return {}; + if (!context.sourceCode.text.includes("componentWillMount")) { + return {}; + } const { ctx, listeners } = useComponentCollectorLegacy(); return { @@ -52,7 +54,9 @@ export default createRule<[], MessageID>({ messageId: "noComponentWillMount", node: member, fix(fixer) { - if (!("key" in member)) return null; + if (!("key" in member)) { + return null; + } return fixer.replaceText(member.key, "UNSAFE_componentWillMount"); }, }); diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-receive-props.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-receive-props.ts index 62caf11db4..fa64a5d4d9 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-receive-props.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-receive-props.ts @@ -37,7 +37,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {}; + if (!context.sourceCode.text.includes("componentWillReceiveProps")) { + return {}; + } const { ctx, listeners } = useComponentCollectorLegacy(); return { @@ -52,7 +54,9 @@ export default createRule<[], MessageID>({ messageId: "noComponentWillReceiveProps", node: member, fix(fixer) { - if (!("key" in member)) return null; + if (!("key" in member)) { + return null; + } return fixer.replaceText(member.key, "UNSAFE_componentWillReceiveProps"); }, }); diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-update.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-update.ts index 31aa175102..0b4d37e4be 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-update.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-update.ts @@ -37,7 +37,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("componentWillUpdate")) return {}; + if (!context.sourceCode.text.includes("componentWillUpdate")) { + return {}; + } const { ctx, listeners } = useComponentCollectorLegacy(); return { @@ -52,7 +54,9 @@ export default createRule<[], MessageID>({ messageId: "noComponentWillUpdate", node: member, fix(fixer) { - if (!("key" in member)) return null; + if (!("key" in member)) { + return null; + } return fixer.replaceText(member.key, "UNSAFE_componentWillUpdate"); }, }); diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-context-provider.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-context-provider.ts index 11846792b9..f17ce70e4a 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-context-provider.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-context-provider.ts @@ -30,13 +30,19 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes(".Provider")) return {}; + if (!context.sourceCode.text.includes(".Provider")) { + return {}; + } const { version } = getSettingsFromContext(context); - if (compare(version, "19.0.0", "<")) return {}; + if (compare(version, "19.0.0", "<")) { + return {}; + } return { JSXElement(node) { const elementName = JSX.getElementName(node.openingElement); - if (!elementName.endsWith(".Provider")) return; + if (!elementName.endsWith(".Provider")) { + return; + } context.report({ messageId: "noContextProvider", node, @@ -44,7 +50,9 @@ export default createRule<[], MessageID>({ const providerName = elementName.replace(/\.Provider$/, ""); const openingElement = node.openingElement; const closingElement = node.closingElement; - if (!closingElement) return fixer.replaceText(openingElement.name, providerName); + if (!closingElement) { + return fixer.replaceText(openingElement.name, providerName); + } return [ fixer.replaceText(openingElement.name, providerName), fixer.replaceText(closingElement.name, providerName), diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-create-ref.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-create-ref.ts index 6de384e977..c797c693c0 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-create-ref.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-create-ref.ts @@ -30,8 +30,12 @@ export default createRule<[], MessageID>({ create(context) { return { CallExpression(node) { - if (!isCreateRefCall(node, context)) return; - if (O.isSome(AST.findParentNode(node, isClassComponent))) return; + if (!isCreateRefCall(node, context)) { + return; + } + if (O.isSome(AST.findParentNode(node, isClassComponent))) { + return; + } context.report({ messageId: "noCreateRef", node }); }, }; diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-default-props.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-default-props.ts index 67b99931e6..a22b24a0fe 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-default-props.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-default-props.ts @@ -30,25 +30,41 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("defaultProps")) return {}; + if (!context.sourceCode.text.includes("defaultProps")) { + return {}; + } return { AssignmentExpression(node) { - if (node.operator !== "=" || node.left.type !== T.MemberExpression) return; + if (node.operator !== "=" || node.left.type !== T.MemberExpression) { + return; + } const { object, property } = node.left; - if (object.type !== T.Identifier) return; - if (property.type !== T.Identifier || property.name !== "defaultProps") return; - if (!isComponentName(object.name)) return; + if (object.type !== T.Identifier) { + return; + } + if (property.type !== T.Identifier || property.name !== "defaultProps") { + return; + } + if (!isComponentName(object.name)) { + return; + } const isComponent = F.pipe( VAR.findVariable(object.name, context.sourceCode.getScope(node)), O.flatMap(VAR.getVariableNode(0)), O.exists(n => AST.isFunction(n) || isClassComponent(n)), ); - if (!isComponent) return; + if (!isComponent) { + return; + } context.report({ messageId: "noDefaultProps", node: property }); }, PropertyDefinition(node) { - if (!isClassComponent(node.parent.parent)) return; - if (!node.static || node.key.type !== T.Identifier || node.key.name !== "defaultProps") return; + if (!isClassComponent(node.parent.parent)) { + return; + } + if (!node.static || node.key.type !== T.Identifier || node.key.name !== "defaultProps") { + return; + } context.report({ messageId: "noDefaultProps", node }); }, }; diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-direct-mutation-state.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-direct-mutation-state.ts index b6190bb8a8..25a6eafbf1 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-direct-mutation-state.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-direct-mutation-state.ts @@ -68,7 +68,9 @@ export default createRule<[], MessageID>({ name: RULE_NAME, create(context) { function getReportDescriptor(node: TSESTree.AssignmentExpression): O.Option> { - if (!isAssignmentToThisState(node)) return O.none(); + if (!isAssignmentToThisState(node)) { + return O.none(); + } return F.pipe( O.Do, O.bind("parentClass", () => diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-jsx-props.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-jsx-props.ts index a8b488a201..8f877bae03 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-jsx-props.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-jsx-props.ts @@ -31,9 +31,13 @@ export default createRule<[], MessageID>({ JSXOpeningElement(node) { const props: string[] = []; for (const attr of node.attributes) { - if (attr.type === T.JSXSpreadAttribute) continue; + if (attr.type === T.JSXSpreadAttribute) { + continue; + } const name = attr.name.name; - if (!isString(name)) continue; + if (!isString(name)) { + continue; + } if (!props.includes(name)) { props.push(name); continue; diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-key.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-key.ts index b088770b0f..d26954faf5 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-key.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-key.ts @@ -35,7 +35,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.getText().includes("key=")) return {}; + if (!context.sourceCode.getText().includes("key=")) { + return {}; + } const keyedEntries: Map = new Map(); function isKeyValueEqual( a: TSESTree.JSXAttribute, @@ -43,7 +45,9 @@ export default createRule<[], MessageID>({ ): boolean { const aValue = a.value; const bValue = b.value; - if (aValue === null || bValue === null) return false; + if (aValue === null || bValue === null) { + return false; + } return AST.isNodeEqual(aValue, bValue); } return { @@ -69,9 +73,13 @@ export default createRule<[], MessageID>({ O.bind("iter", ({ call }) => AST.findParentNodeStop(jsxElement, call, AST.isFunction)), O.bind("arg0", ({ call }) => O.fromNullable(call.arguments[0])), ); - if (O.isNone(mbEntry)) return; + if (O.isNone(mbEntry)) { + return; + } const { arg0, call, iter } = mbEntry.value; - if (AST.unwrapTypeExpression(arg0) !== iter) return; + if (AST.unwrapTypeExpression(arg0) !== iter) { + return; + } keyedEntries.set(call, { hasDuplicate: node.value?.type === T.Literal, keys: [node], @@ -82,7 +90,9 @@ export default createRule<[], MessageID>({ }, "Program:exit"() { for (const { hasDuplicate, keys } of keyedEntries.values()) { - if (!hasDuplicate) continue; + if (!hasDuplicate) { + continue; + } for (const key of keys) { context.report({ messageId: "noDuplicateKey", diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-forward-ref.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-forward-ref.ts index 55e20fe3af..6bb777da3d 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-forward-ref.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-forward-ref.ts @@ -36,12 +36,18 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("forwardRef")) return {}; + if (!context.sourceCode.text.includes("forwardRef")) { + return {}; + } const { version } = getSettingsFromContext(context); - if (compare(version, "19.0.0", "<")) return {}; + if (compare(version, "19.0.0", "<")) { + return {}; + } return { CallExpression(node) { - if (!isForwardRefCall(node, context)) return; + if (!isForwardRefCall(node, context)) { + return; + } context.report({ messageId: "noForwardRef", node, @@ -56,7 +62,9 @@ export default createRule<[], MessageID>({ function getFix(node: TSESTree.CallExpression, context: RuleContext): (fixer: RuleFixer) => RuleFix[] { return (fixer) => { const [componentNode] = node.arguments; - if (!componentNode || !AST.isFunction(componentNode)) return []; + if (!componentNode || !AST.isFunction(componentNode)) { + return []; + } return [ // unwrap component from forwardRef call fixer.removeRange([node.range[0], componentNode.range[0]]), @@ -81,7 +89,9 @@ function getComponentPropsFixes( const getText = (node: TSESTree.Node) => context.sourceCode.getText(node); const [arg0, arg1] = node.params; const [typeArg0, typeArg1] = typeArguments; - if (!arg0) return []; + if (!arg0) { + return []; + } const fixedArg0Text = match(arg0) .with({ type: T.Identifier }, (n) => O.some(`...${n.name}`)) .with({ type: T.ObjectPattern }, (n) => O.some(n.properties.map(getText).join(", "))) @@ -91,7 +101,9 @@ function getComponentPropsFixes( .with({ type: T.Identifier, name: "ref" }, () => O.some("ref")) .with({ type: T.Identifier, name: P.not("ref") }, (n) => O.some(`ref: ${n.name}`)) .otherwise(O.none); - if (O.isNone(fixedArg0Text) || O.isNone(fixedArg1Text)) return []; + if (O.isNone(fixedArg0Text) || O.isNone(fixedArg1Text)) { + return []; + } const fixedPropsText = fixedArg0Text.value; const fixedRefText = fixedArg1Text.value; if (!typeArg0 || !typeArg1) { diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-leaked-conditional-rendering.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-leaked-conditional-rendering.ts index 2faf8232be..9e6d12a1b7 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-leaked-conditional-rendering.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-leaked-conditional-rendering.ts @@ -216,7 +216,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {}; + if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) { + return {}; + } const { version } = getSettingsFromContext(context); @@ -242,7 +244,9 @@ export default createRule<[], MessageID>({ .when(AST.isJSX, O.none) .with({ type: T.LogicalExpression, operator: "&&" }, ({ left, right }) => { const isLeftUnaryNot = isMatching({ type: T.UnaryExpression, operator: "!" }, left); - if (isLeftUnaryNot) return getReportDescriptor(right); + if (isLeftUnaryNot) { + return getReportDescriptor(right); + } const initialScope = context.sourceCode.getScope(left); const isLeftNan = isMatching({ type: T.Identifier, name: "NaN" }, left) || O.exists(VAR.getStaticValue(left, initialScope), v => v === "NaN"); @@ -258,7 +262,9 @@ export default createRule<[], MessageID>({ const isLeftValid = Array .from(leftTypeVariants.values()) .every(type => allowedVariants.some(allowed => allowed === type)); - if (isLeftValid) return getReportDescriptor(right); + if (isLeftValid) { + return getReportDescriptor(right); + } return O.some({ messageId: "noLeakedConditionalRendering", node: left, diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-missing-component-display-name.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-missing-component-display-name.ts index 9b24cf23c7..97941e2a04 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-missing-component-display-name.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-missing-component-display-name.ts @@ -28,7 +28,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {}; + if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) { + return {}; + } const { ctx, listeners } = useComponentCollector(context); return { @@ -38,8 +40,12 @@ export default createRule<[], MessageID>({ for (const { node, displayName, flag } of components.values()) { const isMemoOrForwardRef = Boolean(flag & ERFunctionComponentFlag.ForwardRef) || Boolean(flag & ERFunctionComponentFlag.Memo); - if (O.isSome(AST.getFunctionIdentifier(node))) continue; - if (!isMemoOrForwardRef) continue; + if (O.isSome(AST.getFunctionIdentifier(node))) { + continue; + } + if (!isMemoOrForwardRef) { + continue; + } if (O.isNone(displayName)) { context.report({ messageId: "noMissingComponentDisplayName", diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-missing-key.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-missing-key.ts index 209fbc1c2e..98af02d4e5 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-missing-key.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-missing-key.ts @@ -62,13 +62,17 @@ export default createRule<[], MessageID>({ function checkExpression(node: TSESTree.Expression): O.Option> { switch (node.type) { case T.ConditionalExpression: - if (!("consequent" in node)) return O.none(); + if (!("consequent" in node)) { + return O.none(); + } return O.orElse(checkIteratorElement(node.consequent), () => checkIteratorElement(node.alternate)); case T.JSXElement: case T.JSXFragment: return checkIteratorElement(node); case T.LogicalExpression: - if (!("left" in node)) return O.none(); + if (!("left" in node)) { + return O.none(); + } return O.orElse(checkIteratorElement(node.left), () => checkIteratorElement(node.right)); default: return O.none(); @@ -78,7 +82,9 @@ export default createRule<[], MessageID>({ function checkBlockStatement(node: TSESTree.BlockStatement) { return AST.getNestedReturnStatements(node) .reduce[]>((acc, statement) => { - if (!statement.argument) return acc; + if (!statement.argument) { + return acc; + } const mbDescriptor = checkIteratorElement(statement.argument); return O.isNone(mbDescriptor) ? acc @@ -88,9 +94,13 @@ export default createRule<[], MessageID>({ return { ArrayExpression(node) { - if (state.isWithinChildrenToArray) return; + if (state.isWithinChildrenToArray) { + return; + } const elements = node.elements.filter(AST.is(T.JSXElement)); - if (elements.length === 0) return; + if (elements.length === 0) { + return; + } const initialScope = context.sourceCode.getScope(node); for (const element of elements) { if (!JSX.hasProp(element.openingElement.attributes, "key", initialScope)) { @@ -103,7 +113,9 @@ export default createRule<[], MessageID>({ }, CallExpression(node) { state.isWithinChildrenToArray ||= isChildrenToArrayCall(node, context); - if (state.isWithinChildrenToArray) return; + if (state.isWithinChildrenToArray) { + return; + } const isMapCall = AST.isMapCallLoose(node); const isArrayFromCall = isMatching({ type: T.CallExpression, @@ -114,9 +126,13 @@ export default createRule<[], MessageID>({ }, }, }, node); - if (!isMapCall && !isArrayFromCall) return; + if (!isMapCall && !isArrayFromCall) { + return; + } const fn = node.arguments[isMapCall ? 0 : 1]; - if (!AST.isOneOf([T.ArrowFunctionExpression, T.FunctionExpression])(fn)) return; + if (!AST.isOneOf([T.ArrowFunctionExpression, T.FunctionExpression])(fn)) { + return; + } if (fn.body.type === T.BlockStatement) { for (const descriptor of checkBlockStatement(fn.body)) { context.report(descriptor); @@ -126,11 +142,15 @@ export default createRule<[], MessageID>({ O.map(checkExpression(fn.body), context.report); }, "CallExpression:exit"(node) { - if (!isChildrenToArrayCall(node, context)) return; + if (!isChildrenToArrayCall(node, context)) { + return; + } state.isWithinChildrenToArray = false; }, JSXFragment(node) { - if (state.isWithinChildrenToArray) return; + if (state.isWithinChildrenToArray) { + return; + } if (node.parent.type === T.ArrayExpression) { context.report({ messageId: "noMissingKeyWithFragment", diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-nested-components.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-nested-components.ts index 71843f731b..3a91b8d9f5 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-nested-components.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-nested-components.ts @@ -68,9 +68,13 @@ export default createRule<[], MessageID>({ }; for (const { name: componentName, node: component } of functionComponents) { // Do not mark objects containing render methods - if (isDirectValueOfRenderPropertyLoose(component)) continue; + if (isDirectValueOfRenderPropertyLoose(component)) { + continue; + } // Do not mark anonymous function components to reduce false positives - if (O.isNone(componentName)) continue; + if (O.isNone(componentName)) { + continue; + } const name = componentName.value; const isInsideProperty = component.parent.type === T.Property; const isInsideJSXPropValue = component.parent.type === T.JSXAttribute diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-prop-types.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-prop-types.ts index 40588f2473..c5efba6fe6 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-prop-types.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-prop-types.ts @@ -30,25 +30,41 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("propTypes")) return {}; + if (!context.sourceCode.text.includes("propTypes")) { + return {}; + } return { AssignmentExpression(node) { - if (node.operator !== "=" || node.left.type !== T.MemberExpression) return; + if (node.operator !== "=" || node.left.type !== T.MemberExpression) { + return; + } const { object, property } = node.left; - if (object.type !== T.Identifier) return; - if (property.type !== T.Identifier || property.name !== "propTypes") return; - if (!isComponentName(object.name)) return; + if (object.type !== T.Identifier) { + return; + } + if (property.type !== T.Identifier || property.name !== "propTypes") { + return; + } + if (!isComponentName(object.name)) { + return; + } const isComponent = F.pipe( VAR.findVariable(object.name, context.sourceCode.getScope(node)), O.flatMap(VAR.getVariableNode(0)), O.exists(n => AST.isFunction(n) || isClassComponent(n)), ); - if (!isComponent) return; + if (!isComponent) { + return; + } context.report({ messageId: "noPropTypes", node: property }); }, PropertyDefinition(node) { - if (!isClassComponent(node.parent.parent)) return; - if (!node.static || node.key.type !== T.Identifier || node.key.name !== "propTypes") return; + if (!isClassComponent(node.parent.parent)) { + return; + } + if (!node.static || node.key.type !== T.Identifier || node.key.name !== "propTypes") { + return; + } context.report({ messageId: "noPropTypes", node }); }, }; diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-redundant-should-component-update.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-redundant-should-component-update.ts index 16eb74262c..0128451ab9 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-redundant-should-component-update.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-redundant-should-component-update.ts @@ -37,7 +37,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {}; + if (!context.sourceCode.text.includes("shouldComponentUpdate")) { + return {}; + } const { ctx, listeners } = useComponentCollectorLegacy(); return { @@ -46,7 +48,9 @@ export default createRule<[], MessageID>({ const components = ctx.getAllComponents(node); for (const { name, node: component, flag } of components.values()) { - if (!(flag & ERClassComponentFlag.PureComponent)) continue; + if (!(flag & ERClassComponentFlag.PureComponent)) { + continue; + } const { body } = component.body; for (const member of body) { if (isShouldComponentUpdate(member)) { diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-did-mount.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-did-mount.ts index 5ce2af4d4e..6b5482b218 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-did-mount.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-did-mount.ts @@ -38,9 +38,13 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("componentDidMount")) return {}; + if (!context.sourceCode.text.includes("componentDidMount")) { + return {}; + } function getReportDescriptor(node: TSESTree.CallExpression): O.Option> { - if (!isThisSetState(node)) return O.none(); + if (!isThisSetState(node)) { + return O.none(); + } return F.pipe( O.Do, O.bind("clazz", () => AST.findParentNodeGuard(node, isClassComponent)), diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-did-update.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-did-update.ts index c35cccc256..bcb8993f7d 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-did-update.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-did-update.ts @@ -38,9 +38,13 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("componentDidUpdate")) return {}; + if (!context.sourceCode.text.includes("componentDidUpdate")) { + return {}; + } function getReportDescriptor(node: TSESTree.CallExpression): O.Option> { - if (!isThisSetState(node)) return O.none(); + if (!isThisSetState(node)) { + return O.none(); + } return F.pipe( O.Do, O.bind("clazz", () => AST.findParentNodeGuard(node, isClassComponent)), diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-will-update.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-will-update.ts index 1e1deef156..773a6073e5 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-will-update.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-will-update.ts @@ -38,9 +38,13 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("componentWillUpdate")) return {}; + if (!context.sourceCode.text.includes("componentWillUpdate")) { + return {}; + } function getReportDescriptor(node: TSESTree.CallExpression): O.Option> { - if (!isThisSetState(node)) return O.none(); + if (!isThisSetState(node)) { + return O.none(); + } return F.pipe( O.Do, O.bind("clazz", () => AST.findParentNodeGuard(node, isClassComponent)), diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-string-refs.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-string-refs.ts index 470af171eb..ac32767343 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-string-refs.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-string-refs.ts @@ -19,8 +19,12 @@ function containsStringLiteral({ value }: TSESTree.JSXAttribute) { } function containsStringExpressionContainer({ value }: TSESTree.JSXAttribute) { - if (value?.type !== T.JSXExpressionContainer) return false; - if (value.expression.type === T.Literal) return isString(value.expression.value); + if (value?.type !== T.JSXExpressionContainer) { + return false; + } + if (value.expression.type === T.Literal) { + return isString(value.expression.value); + } return value.expression.type === T.TemplateLiteral; } @@ -41,7 +45,9 @@ export default createRule<[], MessageID>({ create(context) { return { JSXAttribute(node) { - if (node.name.name !== "ref") return; + if (node.name.name !== "ref") { + return; + } if (containsStringLiteral(node) || containsStringExpressionContainer(node)) { context.report({ messageId: "noStringRefs", diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-unsafe-component-will-mount.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-unsafe-component-will-mount.ts index 63eab565e3..79e42ff719 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-unsafe-component-will-mount.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-unsafe-component-will-mount.ts @@ -35,7 +35,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {}; + if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) { + return {}; + } const { ctx, listeners } = useComponentCollectorLegacy(); return { diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-unsafe-component-will-receive-props.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-unsafe-component-will-receive-props.ts index 8a3a24c43e..5e525f5283 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-unsafe-component-will-receive-props.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-unsafe-component-will-receive-props.ts @@ -35,7 +35,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) return {}; + if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) { + return {}; + } const { ctx, listeners } = useComponentCollectorLegacy(); return { diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-unsafe-component-will-update.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-unsafe-component-will-update.ts index d54c7652f8..ce3ad1d81b 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-unsafe-component-will-update.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-unsafe-component-will-update.ts @@ -35,7 +35,9 @@ export default createRule<[], MessageID>({ }, name: RULE_NAME, create(context) { - if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {}; + if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) { + return {}; + } const { ctx, listeners } = useComponentCollectorLegacy(); return { diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-unstable-context-value.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-unstable-context-value.ts index 9b00ce19a0..8fd2d3f901 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-unstable-context-value.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-unstable-context-value.ts @@ -44,8 +44,12 @@ export default createRule<[], MessageID>({ ...listeners, JSXOpeningElement(node) { const openingElementName = node.name; - if (openingElementName.type !== T.JSXMemberExpression) return; - if (openingElementName.property.name !== "Provider") return; + if (openingElementName.type !== T.JSXMemberExpression) { + return; + } + if (openingElementName.property.name !== "Provider") { + return; + } F.pipe( O.Do, O.bind("function", ctx.getCurrentFunction), @@ -66,8 +70,12 @@ export default createRule<[], MessageID>({ return O.some(VAR.getValueConstruction(valueExpression, initialScope)); }), O.map((vc) => { - if (vc.construction.kind === "None") return; - if (isReactHookCall(vc.construction.node)) return; + if (vc.construction.kind === "None") { + return; + } + if (isReactHookCall(vc.construction.node)) { + return; + } const prevs = constructions.get(vc.function.node) ?? []; constructions.set(vc.function.node, [...prevs, vc.construction]); }), @@ -77,7 +85,9 @@ export default createRule<[], MessageID>({ const components = ctx.getAllComponents(node).values(); for (const { node: component } of components) { for (const construction of constructions.get(component) ?? []) { - if (construction.kind === "None") continue; + if (construction.kind === "None") { + continue; + } const { kind, node: constructionNode } = construction; const messageId = kind.startsWith("Function") ? "noUnstableContextValueWithFunction" diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-unstable-default-props.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-unstable-default-props.ts index 7e31464fbe..e1af9cb74c 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-unstable-default-props.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-unstable-default-props.ts @@ -51,7 +51,9 @@ export default createRule<[], MessageID>({ for (const { node: component } of components.values()) { const { params } = component; const [props] = params; - if (!props) continue; + if (!props) { + continue; + } const properties = match(props) .with({ type: T.ObjectPattern }, ({ properties }) => properties) .with({ type: T.Identifier }, ({ name }) => { @@ -61,7 +63,9 @@ export default createRule<[], MessageID>({ }) .otherwise(() => []); for (const prop of properties) { - if (prop.type !== T.Property || prop.value.type !== T.AssignmentPattern) continue; + if (prop.type !== T.Property || prop.value.type !== T.AssignmentPattern) { + continue; + } const { value } = prop; const { right } = value; const initialScope = context.sourceCode.getScope(value); @@ -70,8 +74,12 @@ export default createRule<[], MessageID>({ initialScope, VAR.ValueConstructionHint.StrictCallExpression, ); - if (construction.kind === "None") continue; - if (isReactHookCall(construction.node)) continue; + if (construction.kind === "None") { + continue; + } + if (isReactHookCall(construction.node)) { + continue; + } const forbiddenType = AST.toReadableNodeType(right); context.report({ messageId: "noUnstableDefaultProps", @@ -85,7 +93,9 @@ export default createRule<[], MessageID>({ }, "VariableDeclarator[id.type='ObjectPattern'][init.type='Identifier']"(node: ObjectDestructuringDeclarator) { const mbEntry = ctx.getCurrentFunction(); - if (O.isNone(mbEntry)) return; + if (O.isNone(mbEntry)) { + return; + } const entry = mbEntry.value; const prevs = declarators.get(entry.node) ?? []; declarators.set(entry.node, [...prevs, node]); diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-unused-class-component-members.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-unused-class-component-members.ts index b2725060dd..2dcc6fa6e0 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-unused-class-component-members.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-unused-class-component-members.ts @@ -78,21 +78,31 @@ export default createRule<[], MessageID>({ const propertyUsages = new WeakMap>(); function classEnter(node: AST.TSESTreeClass) { classStack.push(node); - if (!isClassComponent(node)) return; + if (!isClassComponent(node)) { + return; + } propertyDefs.set(node, new Set()); propertyUsages.set(node, new Set()); } function classExit() { const currentClass = classStack.pop(); - if (!currentClass || !isClassComponent(currentClass)) return; + if (!currentClass || !isClassComponent(currentClass)) { + return; + } const className = O.map(AST.getClassIdentifier(currentClass), id => id.name); const defs = propertyDefs.get(currentClass); const usages = propertyUsages.get(currentClass); - if (!defs) return; + if (!defs) { + return; + } for (const def of defs) { const name = getName(def); - if (O.isNone(name)) continue; - if (usages?.has(name.value) || LIFECYCLE_METHODS.has(name.value)) continue; + if (O.isNone(name)) { + continue; + } + if (usages?.has(name.value) || LIFECYCLE_METHODS.has(name.value)) { + continue; + } context.report({ messageId: "noUnusedClassComponentMembers", node: def, @@ -106,8 +116,12 @@ export default createRule<[], MessageID>({ function methodEnter(node: TSESTree.MethodDefinition | TSESTree.PropertyDefinition) { methodStack.push(node); const currentClass = classStack.at(-1); - if (!currentClass || !isClassComponent(currentClass)) return; - if (node.static) return; + if (!currentClass || !isClassComponent(currentClass)) { + return; + } + if (node.static) { + return; + } if (AST.isKeyLiteralLike(node, node.key)) { propertyDefs.get(currentClass)?.add(node.key); } @@ -124,9 +138,15 @@ export default createRule<[], MessageID>({ MemberExpression(node) { const currentClass = classStack.at(-1); const currentMethod = methodStack.at(-1); - if (!currentClass || !currentMethod) return; - if (!isClassComponent(currentClass) || currentMethod.static) return; - if (!AST.isThisExpression(node.object) || !AST.isKeyLiteralLike(node, node.property)) return; + if (!currentClass || !currentMethod) { + return; + } + if (!isClassComponent(currentClass) || currentMethod.static) { + return; + } + if (!AST.isThisExpression(node.object) || !AST.isKeyLiteralLike(node, node.property)) { + return; + } if (node.parent.type === T.AssignmentExpression && node.parent.left === node) { // detect `this.property = xxx` propertyDefs.get(currentClass)?.add(node.property); @@ -142,8 +162,12 @@ export default createRule<[], MessageID>({ VariableDeclarator(node) { const currentClass = classStack.at(-1); const currentMethod = methodStack.at(-1); - if (!currentClass || !currentMethod) return; - if (!isClassComponent(currentClass) || currentMethod.static) return; + if (!currentClass || !currentMethod) { + return; + } + if (!isClassComponent(currentClass) || currentMethod.static) { + return; + } // detect `{ foo, bar: baz } = this` if (node.init && AST.isThisExpression(node.init) && node.id.type === T.ObjectPattern) { for (const prop of node.id.properties) { diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-unused-state.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-unused-state.ts index 6c98b5ff8b..6770ad4839 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-unused-state.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-unused-state.ts @@ -77,10 +77,14 @@ export default createRule<[], MessageID>({ } function classExit() { const currentClass = classStack.pop(); - if (!currentClass || !isClassComponent(currentClass)) return; + if (!currentClass || !isClassComponent(currentClass)) { + return; + } const className = O.map(AST.getClassIdentifier(currentClass), id => id.name); const [def, isUsed] = stateDefs.get(currentClass) ?? [O.none(), false]; - if (O.isNone(def) || isUsed) return; + if (O.isNone(def) || isUsed) { + return; + } context.report({ messageId: "noUnusedState", node: def.value, @@ -92,7 +96,9 @@ export default createRule<[], MessageID>({ function methodEnter(node: TSESTree.MethodDefinition | TSESTree.PropertyDefinition) { methodStack.push(node); const currentClass = classStack.at(-1); - if (!currentClass || !isClassComponent(currentClass)) return; + if (!currentClass || !isClassComponent(currentClass)) { + return; + } if (node.static) { if (isGetDerivedStateFromProps(node) && node.value.params.length > 1) { const [def] = stateDefs.get(currentClass) ?? [O.none()]; @@ -116,11 +122,17 @@ export default createRule<[], MessageID>({ return { AssignmentExpression(node) { - if (!isAssignmentToThisState(node)) return; + if (!isAssignmentToThisState(node)) { + return; + } const currentClass = classStack.at(-1); - if (!currentClass || !isClassComponent(currentClass)) return; + if (!currentClass || !isClassComponent(currentClass)) { + return; + } const currentConstructor = constructorStack.at(-1); - if (!currentConstructor || !currentClass.body.body.includes(currentConstructor)) return; + if (!currentConstructor || !currentClass.body.body.includes(currentConstructor)) { + return; + } const [_, isUsed] = stateDefs.get(currentClass) ?? [O.none(), false]; stateDefs.set(currentClass, [O.some(node.left), isUsed]); }, @@ -129,15 +141,27 @@ export default createRule<[], MessageID>({ ClassExpression: classEnter, "ClassExpression:exit": classExit, MemberExpression(node) { - if (!AST.isThisExpression(node.object)) return; + if (!AST.isThisExpression(node.object)) { + return; + } // detect `this.state` - if (!O.exists(getName(node.property), name => name === "state")) return; + if (!O.exists(getName(node.property), name => name === "state")) { + return; + } const currentClass = classStack.at(-1); - if (!currentClass || !isClassComponent(currentClass)) return; + if (!currentClass || !isClassComponent(currentClass)) { + return; + } const currentMethod = methodStack.at(-1); - if (!currentMethod || currentMethod.static) return; - if (currentMethod === constructorStack.at(-1)) return; - if (!currentClass.body.body.includes(currentMethod)) return; + if (!currentMethod || currentMethod.static) { + return; + } + if (currentMethod === constructorStack.at(-1)) { + return; + } + if (!currentClass.body.body.includes(currentMethod)) { + return; + } const [def] = stateDefs.get(currentClass) ?? [O.none(), false]; stateDefs.set(currentClass, [def, true]); }, @@ -149,20 +173,32 @@ export default createRule<[], MessageID>({ "PropertyDefinition:exit": methodExit, VariableDeclarator(node) { const currentClass = classStack.at(-1); - if (!currentClass || !isClassComponent(currentClass)) return; + if (!currentClass || !isClassComponent(currentClass)) { + return; + } const currentMethod = methodStack.at(-1); - if (!currentMethod || currentMethod.static) return; - if (currentMethod === constructorStack.at(-1)) return; - if (!currentClass.body.body.includes(currentMethod)) return; + if (!currentMethod || currentMethod.static) { + return; + } + if (currentMethod === constructorStack.at(-1)) { + return; + } + if (!currentClass.body.body.includes(currentMethod)) { + return; + } // detect `{ foo, state: baz } = this` - if (!(node.init && AST.isThisExpression(node.init) && node.id.type === T.ObjectPattern)) return; + if (!(node.init && AST.isThisExpression(node.init) && node.id.type === T.ObjectPattern)) { + return; + } const hasState = node.id.properties.some(prop => { if (prop.type === T.Property && AST.isKeyLiteralLike(prop, prop.key)) { return O.exists(getName(prop.key), name => name === "state"); } return false; }); - if (!hasState) return; + if (!hasState) { + return; + } const [def] = stateDefs.get(currentClass) ?? [O.none(), false]; stateDefs.set(currentClass, [def, true]); }, diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.ts index 526befe73a..4a010bf6c8 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.ts @@ -34,9 +34,13 @@ function checkAndReport( ) { const initialScope = context.sourceCode.getScope(node); // return if the fragment is keyed (e.g. ) - if (JSX.isKeyedElement(node, initialScope)) return; + if (JSX.isKeyedElement(node, initialScope)) { + return; + } // report if the fragment is placed inside a built-in component (e.g.
<>
) - if (JSX.isBuiltInElement(node.parent)) context.report({ messageId: "noUselessFragmentInBuiltIn", node }); + if (JSX.isBuiltInElement(node.parent)) { + context.report({ messageId: "noUselessFragmentInBuiltIn", node }); + } // report and return if the fragment has no children (e.g. <>) if (node.children.length === 0) { context.report({ messageId: "noUselessFragment", node }); @@ -106,7 +110,9 @@ export default createRule({ const { allowExpressions = true } = option; return { JSXElement(node) { - if (JSX.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") return; + if (JSX.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") { + return; + } checkAndReport(node, context, allowExpressions); }, JSXFragment(node) { diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/prefer-destructuring-assignment.ts b/packages/plugins/eslint-plugin-react-x/src/rules/prefer-destructuring-assignment.ts index fd0323d8b6..67ec57836c 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/prefer-destructuring-assignment.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/prefer-destructuring-assignment.ts @@ -54,7 +54,9 @@ export default createRule<[], MessageID>({ "Program:exit"(node) { const components = Array.from(ctx.getAllComponents(node).values()); function isFunctionComponent(block: TSESTree.Node): block is AST.TSESTreeFunction { - if (!AST.isFunction(block)) return false; + if (!AST.isFunction(block)) { + return false; + } return O.exists( AST.getFunctionIdentifier(block), id => @@ -75,9 +77,13 @@ export default createRule<[], MessageID>({ scope = scope.upper; isComponent = isFunctionComponent(scope.block); } - if (!isComponent) continue; + if (!isComponent) { + continue; + } const component = scope.block; - if (!("params" in component)) continue; + if (!("params" in component)) { + continue; + } const [props, ctx] = component.params; const isMatch = isMatching({ name: memberExpression.object.name }); if (isMatch(props)) { diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/prefer-read-only-props.ts b/packages/plugins/eslint-plugin-react-x/src/rules/prefer-read-only-props.ts index 0e3d4b9a02..4bd4455164 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/prefer-read-only-props.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/prefer-read-only-props.ts @@ -49,9 +49,13 @@ export default createRule<[], MessageID>({ const components = ctx.getAllComponents(node); for (const [_, component] of components) { const [props] = component.node.params; - if (!props) continue; + if (!props) { + continue; + } const propsType = getConstrainedTypeAtLocation(services, props); - if (isTypeReadonly(services.program, propsType) || isReadonlyType(propsType, services)) continue; + if (isTypeReadonly(services.program, propsType) || isReadonlyType(propsType, services)) { + continue; + } context.report({ messageId: "preferReadOnlyProps", node: props }); } }, diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-boolean.ts b/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-boolean.ts index f5e58739c6..a70398cd3c 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-boolean.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-boolean.ts @@ -38,7 +38,9 @@ export default createRule<[], MessageID>({ const hasValueTrue = value?.type === T.JSXExpressionContainer && value.expression.type === T.Literal && value.expression.value === true; - if (!hasValueTrue) return O.none(); + if (!hasValueTrue) { + return O.none(); + } return O.some({ messageId: "preferShorthandBoolean", node, diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-fragment.ts b/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-fragment.ts index 840c16c88b..ec563ad76d 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-fragment.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/prefer-shorthand-fragment.ts @@ -32,15 +32,21 @@ export default createRule<[], MessageID>({ name: RULE_NAME, create(context) { function getReportDescriptor(node: TSESTree.JSXElement): O.Option> { - if (JSX.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") return O.none(); + if (JSX.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") { + return O.none(); + } const hasAttributes = node.openingElement.attributes.length > 0; - if (hasAttributes) return O.none(); + if (hasAttributes) { + return O.none(); + } return O.some({ messageId: "preferShorthandFragment", node, fix: (fixer) => { const { closingElement, openingElement } = node; - if (!closingElement) return []; + if (!closingElement) { + return []; + } return [ fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"), fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], ""), diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/use-jsx-vars.ts b/packages/plugins/eslint-plugin-react-x/src/rules/use-jsx-vars.ts index 96469b3f69..8112206355 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/use-jsx-vars.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/use-jsx-vars.ts @@ -39,7 +39,9 @@ export default createRule<[], MessageID>({ } return { JSXOpeningElement(node) { - if (node.name.type === T.JSXIdentifier && /^[a-z]/u.test(node.name.name)) return; + if (node.name.type === T.JSXIdentifier && /^[a-z]/u.test(node.name.name)) { + return; + } for (const name of O.toArray(getName(node.name))) { context.sourceCode.markVariableAsUsed(name, node); } diff --git a/packages/plugins/eslint-plugin/package.json b/packages/plugins/eslint-plugin/package.json index 017ee76308..c8fbe5a350 100644 --- a/packages/plugins/eslint-plugin/package.json +++ b/packages/plugins/eslint-plugin/package.json @@ -24,6 +24,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -38,6 +39,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -86,7 +88,5 @@ }, "publishConfig": { "access": "public" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/plugins/eslint-plugin/src/utils/transform-keys.ts b/packages/plugins/eslint-plugin/src/utils/transform-keys.ts index 9960b39ffa..c687cfbdca 100644 --- a/packages/plugins/eslint-plugin/src/utils/transform-keys.ts +++ b/packages/plugins/eslint-plugin/src/utils/transform-keys.ts @@ -13,7 +13,9 @@ import { typeOf } from "@eslint-react/types"; * // { fooBar: { 'fizz-buzz': true } } */ export function transformKeys(obj: T, transform: (s: string) => string): T { - if (typeOf(obj) !== "object") return obj; + if (typeOf(obj) !== "object") { + return obj; + } const res = {} as T; for (const key in obj) { diff --git a/packages/shared/package.json b/packages/shared/package.json index 8c18196ee9..cdb86e6ce4 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -13,6 +13,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -27,6 +28,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -48,16 +50,14 @@ "devDependencies": { "@types/picomatch": "^3.0.1", "@workspace/configs": "workspace:*", - "fast-equals": "^5.2.0", + "fast-equals": "^5.2.1", "micro-memoize": "^4.1.3", "tsup": "^8.3.5", "type-fest": "^4.31.0", - "valibot": "^1.0.0-beta.10" + "valibot": "^1.0.0-beta.11" }, "engines": { "bun": ">=1.0.15", "node": ">=18.18.0" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/shared/src/create-rule.ts b/packages/shared/src/create-rule.ts index b4cfb134de..c329f356d7 100644 --- a/packages/shared/src/create-rule.ts +++ b/packages/shared/src/create-rule.ts @@ -9,7 +9,9 @@ import { WEBSITE_URL } from "./constants"; * @returns The URL for the documentation of a rule. */ const getDocsUrl = (pluginName: string) => (ruleName: string) => { - if (pluginName === "x") return `${WEBSITE_URL}/docs/rules/${ruleName}`; + if (pluginName === "x") { + return `${WEBSITE_URL}/docs/rules/${ruleName}`; + } return `${WEBSITE_URL}/docs/rules/${pluginName}-${ruleName}`; }; diff --git a/packages/shared/src/settings.ts b/packages/shared/src/settings.ts index 99e5494d0e..51f26fb951 100644 --- a/packages/shared/src/settings.ts +++ b/packages/shared/src/settings.ts @@ -77,8 +77,12 @@ export const normalizeSettings = memoize((settings: ESLintReactSettings): ESLint })), components: additionalComponents.reduce((acc, component) => { const { name, as, attributes = [], selector } = component; - if (!name || !as || selector || attributes.length > 0) return acc; - if (!/^[\w-]+$/u.test(name)) return acc; + if (!name || !as || selector || attributes.length > 0) { + return acc; + } + if (!/^[\w-]+$/u.test(name)) { + return acc; + } return acc.set(name, as); }, new Map()), version: match(settings.version) diff --git a/packages/types/package.json b/packages/types/package.json index c86de44aaf..25978953cc 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -13,6 +13,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -27,6 +28,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -51,7 +53,5 @@ "engines": { "bun": ">=1.0.15", "node": ">=18.18.0" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/types/src/helpers.ts b/packages/types/src/helpers.ts index 3adb9a429c..68e444ddb2 100644 --- a/packages/types/src/helpers.ts +++ b/packages/types/src/helpers.ts @@ -197,7 +197,8 @@ export function birecord>( } export class BiRecord> { - constructor(public original: T, public reversed = reverse(original)) {} + constructor(public original: T, public reversed = reverse(original)) { + } get( key: U, ): U extends keyof T ? T[U] : U extends T[keyof T] ? Reverse[U] : unknown { diff --git a/packages/utilities/ast/package.json b/packages/utilities/ast/package.json index c1221b048f..035c4bc6c4 100644 --- a/packages/utilities/ast/package.json +++ b/packages/utilities/ast/package.json @@ -13,6 +13,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -27,6 +28,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -54,7 +56,5 @@ "engines": { "bun": ">=1.0.15", "node": ">=18.18.0" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/utilities/ast/src/function-init-path.ts b/packages/utilities/ast/src/function-init-path.ts index 0aa985ee93..5e5951e846 100644 --- a/packages/utilities/ast/src/function-init-path.ts +++ b/packages/utilities/ast/src/function-init-path.ts @@ -106,7 +106,9 @@ export type FunctionInitPath = export function getFunctionInitPath(node: TSESTreeFunction): O.Option { const { parent } = node; - if (node.type === T.FunctionDeclaration) return O.some([node]); + if (node.type === T.FunctionDeclaration) { + return O.some([node]); + } if (parent.type === T.VariableDeclarator) { return O.some([ parent.parent, @@ -184,8 +186,12 @@ export function hasCallInFunctionInitPath(callName: string) { O.exists(nodes => { return nodes.some( n => { - if (n.type !== T.CallExpression) return false; - if (n.callee.type === T.Identifier) return n.callee.name === callName; + if (n.type !== T.CallExpression) { + return false; + } + if (n.callee.type === T.Identifier) { + return n.callee.name === callName; + } return "property" in n.callee && "name" in n.callee.property && n.callee.property.name === callName; diff --git a/packages/utilities/ast/src/get-class-identifier.spec.ts b/packages/utilities/ast/src/get-class-identifier.spec.ts index 9bcbad701e..51dbdca0f4 100644 --- a/packages/utilities/ast/src/get-class-identifier.spec.ts +++ b/packages/utilities/ast/src/get-class-identifier.spec.ts @@ -27,7 +27,9 @@ describe("get class identifier from class declaration", () => { let n = O.none(); simpleTraverse(parse(code).ast, { enter(node) { - if (node.type !== T.ClassDeclaration) return; + if (node.type !== T.ClassDeclaration) { + return; + } const id = O.getOrThrow(getClassIdentifier(node)); expect(id).include({ type: T.Identifier, name: expected }); n = O.fromNullable(node); @@ -47,7 +49,9 @@ describe("get class identifier from class expression", () => { let n = O.none(); simpleTraverse(parse(code).ast, { enter(node) { - if (node.type !== T.ClassExpression) return; + if (node.type !== T.ClassExpression) { + return; + } const id = O.getOrThrow(getClassIdentifier(node)); expect(id).include({ type: T.Identifier, name: expected }); n = O.fromNullable(node); diff --git a/packages/utilities/ast/src/get-class-identifier.ts b/packages/utilities/ast/src/get-class-identifier.ts index efe722ef5e..591530441d 100644 --- a/packages/utilities/ast/src/get-class-identifier.ts +++ b/packages/utilities/ast/src/get-class-identifier.ts @@ -10,7 +10,9 @@ import type { TSESTreeClass } from "./types"; * @returns class identifier or null */ export function getClassIdentifier(node: TSESTreeClass): O.Option { - if (node.id) return O.fromNullable(node.id); + if (node.id) { + return O.fromNullable(node.id); + } if (node.parent.type === T.VariableDeclarator && node.parent.id.type === T.Identifier) { return O.fromNullable(node.parent.id); } diff --git a/packages/utilities/ast/src/get-function-identifier.spec.ts b/packages/utilities/ast/src/get-function-identifier.spec.ts index ffd7a44b4b..0ccf3589d5 100644 --- a/packages/utilities/ast/src/get-function-identifier.spec.ts +++ b/packages/utilities/ast/src/get-function-identifier.spec.ts @@ -27,7 +27,9 @@ describe("get function identifier from function declaration", () => { let n = O.none(); simpleTraverse(parse(code).ast, { enter(node) { - if (!isFunction(node)) return; + if (!isFunction(node)) { + return; + } const id = O.getOrThrow(getFunctionIdentifier(node)); expect(id).include({ type: T.Identifier, name: expected }); n = O.fromNullable(node); @@ -61,7 +63,9 @@ describe("get function identifier from function expression", () => { let n = O.none(); simpleTraverse(parse(code).ast, { enter(node) { - if (!isFunction(node)) return; + if (!isFunction(node)) { + return; + } const id = O.getOrThrow(getFunctionIdentifier(node)); expect(id).include({ type: T.Identifier, name: expected }); n = O.fromNullable(node); diff --git a/packages/utilities/ast/src/get-identifiers-from-binary-expression.ts b/packages/utilities/ast/src/get-identifiers-from-binary-expression.ts index b6530ce4ce..97fcd7fb76 100644 --- a/packages/utilities/ast/src/get-identifiers-from-binary-expression.ts +++ b/packages/utilities/ast/src/get-identifiers-from-binary-expression.ts @@ -7,7 +7,9 @@ export function getIdentifiersFromBinaryExpression( | TSESTree.BinaryExpression["left"] | TSESTree.BinaryExpression["right"], ): TSESTree.Identifier[] { - if (side.type === T.Identifier) return [side]; + if (side.type === T.Identifier) { + return [side]; + } if (side.type === T.BinaryExpression) { return [ ...getIdentifiersFromBinaryExpression(side.left), diff --git a/packages/utilities/ast/src/get-nested-return-statements.spec.ts b/packages/utilities/ast/src/get-nested-return-statements.spec.ts index 22ef0ceac6..c4f70146d0 100644 --- a/packages/utilities/ast/src/get-nested-return-statements.spec.ts +++ b/packages/utilities/ast/src/get-nested-return-statements.spec.ts @@ -95,8 +95,12 @@ describe("get nested return statements from function", () => { const { ast } = parse(code); simpleTraverse(ast, { enter(node) { - if (O.isSome(n)) return; - if (!isFunction(node)) return; + if (O.isSome(n)) { + return; + } + if (!isFunction(node)) { + return; + } const returnStatements = getNestedReturnStatements(node); for (const [index, statement] of returnStatements.entries()) { expect(statement).include(expected[index]); diff --git a/packages/utilities/ast/src/get-nested-return-statements.ts b/packages/utilities/ast/src/get-nested-return-statements.ts index 7cfc40b9ec..118002ced2 100644 --- a/packages/utilities/ast/src/get-nested-return-statements.ts +++ b/packages/utilities/ast/src/get-nested-return-statements.ts @@ -16,9 +16,13 @@ export function getNestedReturnStatements(node: TSESTree.Node): readonly TSESTre const functionNode = isFunction(node) ? node : O.getOrNull(findParentNodeGuard(node, isFunction)); simpleTraverse(node, { enter(node) { - if (node.type !== T.ReturnStatement) return; + if (node.type !== T.ReturnStatement) { + return; + } const parentFunction = O.getOrNull(findParentNodeGuard(node, isFunction)); - if (parentFunction !== functionNode) return; + if (parentFunction !== functionNode) { + return; + } returnStatements.push(node); }, }); diff --git a/packages/utilities/ast/src/is-map-call.ts b/packages/utilities/ast/src/is-map-call.ts index 9dbfb64b6d..f9ccdd2cfe 100644 --- a/packages/utilities/ast/src/is-map-call.ts +++ b/packages/utilities/ast/src/is-map-call.ts @@ -2,9 +2,15 @@ import type { TSESTree } from "@typescript-eslint/types"; import { AST_NODE_TYPES as T } from "@typescript-eslint/types"; export function isMapCallLoose(node: TSESTree.Node): node is TSESTree.CallExpression { - if (node.type !== T.CallExpression) return false; - if (node.callee.type !== T.MemberExpression) return false; - if (node.callee.property.type !== T.Identifier) return false; + if (node.type !== T.CallExpression) { + return false; + } + if (node.callee.type !== T.MemberExpression) { + return false; + } + if (node.callee.property.type !== T.Identifier) { + return false; + } const { name } = node.callee.property; return name === "map" || name.endsWith("Map"); } diff --git a/packages/utilities/ast/src/is-node-equal.ts b/packages/utilities/ast/src/is-node-equal.ts index 49d1059623..37063954b9 100644 --- a/packages/utilities/ast/src/is-node-equal.ts +++ b/packages/utilities/ast/src/is-node-equal.ts @@ -27,9 +27,15 @@ export const isNodeEqual: { return a.value.raw === b.value.raw; case a.type === T.TemplateLiteral && b.type === T.TemplateLiteral: - if (a.quasis.length !== b.quasis.length || a.expressions.length !== b.expressions.length) return false; - if (!zip(a.quasis, b.quasis).every(([a, b]) => isNodeEqual(a, b))) return false; - if (!zip(a.expressions, b.expressions).every(([a, b]) => isNodeEqual(a, b))) return false; + if (a.quasis.length !== b.quasis.length || a.expressions.length !== b.expressions.length) { + return false; + } + if (!zip(a.quasis, b.quasis).every(([a, b]) => isNodeEqual(a, b))) { + return false; + } + if (!zip(a.expressions, b.expressions).every(([a, b]) => isNodeEqual(a, b))) { + return false; + } return true; case a.type === T.Identifier && b.type === T.Identifier: @@ -42,8 +48,12 @@ export const isNodeEqual: { return isNodeEqual(a.property, b.property) && isNodeEqual(a.object, b.object); case a.type === T.JSXAttribute && b.type === T.JSXAttribute: { - if (a.name.name !== b.name.name) return false; - if (a.value === null || b.value === null) return a.value === b.value; + if (a.name.name !== b.name.name) { + return false; + } + if (a.value === null || b.value === null) { + return a.value === b.value; + } return isNodeEqual(a.value, b.value); } case a.type === T.ThisExpression diff --git a/packages/utilities/ast/src/to-readable-node-type.ts b/packages/utilities/ast/src/to-readable-node-type.ts index f025b64a23..011707f5f4 100644 --- a/packages/utilities/ast/src/to-readable-node-type.ts +++ b/packages/utilities/ast/src/to-readable-node-type.ts @@ -12,10 +12,14 @@ import { isJSX } from "./is"; */ export function toReadableNodeType(node: TSESTree.Node) { if (node.type === T.Literal) { - if ("regex" in node) return "RegExp literal"; + if ("regex" in node) { + return "RegExp literal"; + } return `${getLiteralValueType(node.value)} literal` as const; } - if (isJSX(node)) return `JSX ${toLowerCase(delimiterCase(replace(node.type, "JSX", ""), " "))}` as const; + if (isJSX(node)) { + return `JSX ${toLowerCase(delimiterCase(replace(node.type, "JSX", ""), " "))}` as const; + } return toLowerCase(delimiterCase(node.type, " ")); } diff --git a/packages/utilities/ast/src/unwrap-type-expression.ts b/packages/utilities/ast/src/unwrap-type-expression.ts index 9547a77991..b3e64f8745 100644 --- a/packages/utilities/ast/src/unwrap-type-expression.ts +++ b/packages/utilities/ast/src/unwrap-type-expression.ts @@ -3,6 +3,8 @@ import type { TSESTree } from "@typescript-eslint/types"; import { isTypeExpression } from "./is"; export function unwrapTypeExpression(node: TSESTree.Node): TSESTree.Node { - if (isTypeExpression(node)) return unwrapTypeExpression(node.expression); + if (isTypeExpression(node)) { + return unwrapTypeExpression(node.expression); + } return node; } diff --git a/packages/utilities/eff/package.json b/packages/utilities/eff/package.json index 75b320a965..2306c04043 100644 --- a/packages/utilities/eff/package.json +++ b/packages/utilities/eff/package.json @@ -13,6 +13,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -27,6 +28,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -47,7 +49,5 @@ "engines": { "bun": ">=1.0.15", "node": ">=18.18.0" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/utilities/jsx/package.json b/packages/utilities/jsx/package.json index 0bbe2576af..16fbe6d615 100644 --- a/packages/utilities/jsx/package.json +++ b/packages/utilities/jsx/package.json @@ -13,6 +13,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -27,6 +28,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -55,7 +57,5 @@ "engines": { "bun": ">=1.0.15", "node": ">=18.18.0" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/utilities/jsx/src/get-prop.ts b/packages/utilities/jsx/src/get-prop.ts index 36260f9164..5e139c1191 100644 --- a/packages/utilities/jsx/src/get-prop.ts +++ b/packages/utilities/jsx/src/get-prop.ts @@ -39,8 +39,12 @@ export function getPropValue( ) { if (attribute.type === T.JSXAttribute && "value" in attribute) { const { value } = attribute; - if (value === null) return O.none(); - if (value.type === T.Literal) return VAR.getStaticValue(value, initialScope); + if (value === null) { + return O.none(); + } + if (value.type === T.Literal) { + return VAR.getStaticValue(value, initialScope); + } if (value.type === T.JSXExpressionContainer) { return VAR.getStaticValue(value.expression, initialScope); } @@ -78,7 +82,9 @@ export function findPropInProperties( switch (true) { case prop.argument.type === T.Identifier: { const { name } = prop.argument; - if (seenProps.includes(name)) return false; + if (seenProps.includes(name)) { + return false; + } return F.pipe( VAR.findVariable(name, initialScope), O.flatMap(VAR.getVariableNode(0)), diff --git a/packages/utilities/jsx/src/is-jsx-value.ts b/packages/utilities/jsx/src/is-jsx-value.ts index cdf5b2b4ce..b2b42fb227 100644 --- a/packages/utilities/jsx/src/is-jsx-value.ts +++ b/packages/utilities/jsx/src/is-jsx-value.ts @@ -52,7 +52,9 @@ export function isJSXValue( jsxCtx: { getScope: (node: TSESTree.Node) => Scope }, hint: bigint = DEFAULT_JSX_VALUE_HINT, ): boolean { - if (!node) return false; + if (!node) { + return false; + } return match(node) .with({ type: T.JSXElement }, F.constTrue) .with({ type: T.JSXFragment }, F.constTrue) @@ -68,13 +70,17 @@ export function isJSXValue( }) .with({ type: T.TemplateLiteral }, () => !(hint & JSXValueHint.SkipStringLiteral)) .with({ type: T.ArrayExpression }, (node) => { - if (hint & JSXValueHint.StrictArray) return node.elements.every((n) => isJSXValue(n, jsxCtx, hint)); + if (hint & JSXValueHint.StrictArray) { + return node.elements.every((n) => isJSXValue(n, jsxCtx, hint)); + } return node.elements.some((n) => isJSXValue(n, jsxCtx, hint)); }) .with({ type: T.ConditionalExpression }, (node) => { function leftHasJSX(node: TSESTree.ConditionalExpression) { if (Array.isArray(node.consequent)) { - if (node.consequent.length === 0) return !(hint & JSXValueHint.SkipEmptyArray); + if (node.consequent.length === 0) { + return !(hint & JSXValueHint.SkipEmptyArray); + } if (hint & JSXValueHint.StrictArray) { return node.consequent.every((n: TSESTree.Expression) => isJSXValue(n, jsxCtx, hint)); } @@ -101,7 +107,9 @@ export function isJSXValue( return isJSXValue(exp, jsxCtx, hint); }) .with({ type: T.CallExpression }, (node) => { - if (hint & JSXValueHint.SkipCreateElement) return false; + if (hint & JSXValueHint.SkipCreateElement) { + return false; + } return match(node.callee) .with({ type: T.Identifier, name: "createElement" }, F.constTrue) .with({ type: T.MemberExpression, property: { name: "createElement" } }, F.constTrue) @@ -109,8 +117,12 @@ export function isJSXValue( }) .with({ type: T.Identifier }, (node) => { const { name } = node; - if (name === "undefined") return !(hint & JSXValueHint.SkipUndefinedLiteral); - if (AST.isJSXTagNameExpression(node)) return true; + if (name === "undefined") { + return !(hint & JSXValueHint.SkipUndefinedLiteral); + } + if (AST.isJSXTagNameExpression(node)) { + return true; + } const initialScope = jsxCtx.getScope(node); return F.pipe( VAR.findVariable(name, initialScope), diff --git a/packages/utilities/var/package.json b/packages/utilities/var/package.json index d7c903735d..29964799e5 100644 --- a/packages/utilities/var/package.json +++ b/packages/utilities/var/package.json @@ -13,6 +13,7 @@ }, "license": "MIT", "author": "Eva1ent", + "sideEffects": false, "exports": { ".": { "import": { @@ -27,6 +28,7 @@ "./package.json": "./package.json" }, "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -55,7 +57,5 @@ "engines": { "bun": ">=1.0.15", "node": ">=18.18.0" - }, - "sideEffects": false, - "module": "dist/index.mjs" + } } diff --git a/packages/utilities/var/src/get-scope.ts b/packages/utilities/var/src/get-scope.ts index 4f896db4b8..27490f43f5 100644 --- a/packages/utilities/var/src/get-scope.ts +++ b/packages/utilities/var/src/get-scope.ts @@ -6,7 +6,11 @@ export function getScope(node: TSESTree.Node, scopeManager: ScopeManager) { const { type, parent } = node; const inner = type !== T.Program; const scope = scopeManager.acquire(node, inner); - if (scope) return scope; - if (parent) return getScope(parent, scopeManager); + if (scope) { + return scope; + } + if (parent) { + return getScope(parent, scopeManager); + } return null; } diff --git a/packages/utilities/var/src/is-initialized-from-source.ts b/packages/utilities/var/src/is-initialized-from-source.ts index ffc3079e61..bd8f41046b 100644 --- a/packages/utilities/var/src/is-initialized-from-source.ts +++ b/packages/utilities/var/src/is-initialized-from-source.ts @@ -20,7 +20,9 @@ export function isInitializedFromSource( initialScope: Scope, ): boolean { const latestDef = O.flatMapNullable(findVariable(name, initialScope), (v) => v.defs.at(-1)); - if (O.isNone(latestDef)) return false; + if (O.isNone(latestDef)) { + return false; + } const { node, parent } = latestDef.value; if (node.type === T.VariableDeclarator && node.init) { const { init } = node; diff --git a/packages/utilities/var/src/is-node-value-equal.ts b/packages/utilities/var/src/is-node-value-equal.ts index 511cb3b9b6..8e9d47c96d 100644 --- a/packages/utilities/var/src/is-node-value-equal.ts +++ b/packages/utilities/var/src/is-node-value-equal.ts @@ -66,7 +66,9 @@ export function isNodeValueEqual( O.bind("bCallee", () => O.map(bVarNodeParent, (n) => n.callee)), O.exists(({ aCallee, bCallee }) => AST.isNodeEqual(aCallee, bCallee)), ); - if (!hasSameCallee) return false; + if (!hasSameCallee) { + return false; + } return F.pipe( O.Do, O.bind("aParams", () => O.map(aVarNode, (n) => n.params)), @@ -101,7 +103,9 @@ export function isNodeValueEqual( } case a.type === T.ThisExpression && b.type === T.ThisExpression: { - if (aScope.block === bScope.block) return true; + if (aScope.block === bScope.block) { + return true; + } return F.pipe( O.Do, O.bind("aFunction", () => AST.findParentNode(a, AST.isOneOf(thisBlockTypes))), diff --git a/packages/utilities/var/src/value-construction.ts b/packages/utilities/var/src/value-construction.ts index 2118a85c18..b3edd6bf8e 100644 --- a/packages/utilities/var/src/value-construction.ts +++ b/packages/utilities/var/src/value-construction.ts @@ -64,33 +64,45 @@ export function getValueConstruction( return { kind: "None", node } as const; } case T.MemberExpression: { - if (!("object" in node)) return { kind: "None", node } as const; + if (!("object" in node)) { + return { kind: "None", node } as const; + } return getValueConstruction(node.object, initialScope, hint); } case T.AssignmentExpression: case T.AssignmentPattern: { - if (!("right" in node)) return { kind: "None", node } as const; + if (!("right" in node)) { + return { kind: "None", node } as const; + } return getValueConstruction(node.right, initialScope, hint); } case T.LogicalExpression: { const lvc = getValueConstruction(node.left, initialScope, hint); - if (lvc.kind !== "None") return lvc; + if (lvc.kind !== "None") { + return lvc; + } return getValueConstruction(node.right, initialScope, hint); } case T.ConditionalExpression: { const cvc = getValueConstruction(node.consequent, initialScope, hint); - if (cvc.kind !== "None") return cvc; + if (cvc.kind !== "None") { + return cvc; + } return getValueConstruction(node.alternate, initialScope, hint); } case T.Identifier: { - if (!("name" in node && isString(node.name))) return { kind: "None", node } as const; + if (!("name" in node && isString(node.name))) { + return { kind: "None", node } as const; + } const construction = F.pipe( O.fromNullable(initialScope.set.get(node.name)), O.flatMap(getVariableNode(-1)), O.map((node) => getValueConstruction(node, initialScope, hint)), O.filter((vc) => vc.kind !== "None"), ); - if (O.isNone(construction)) return { kind: "None", node } as const; + if (O.isNone(construction)) { + return { kind: "None", node } as const; + } return { ...construction.value, } as const; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e8fa6ab747..8d7a0c9bcf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -173,8 +173,8 @@ importers: examples/dual-react-dom-lib: devDependencies: '@eslint-react/eslint-plugin': - specifier: ^1.23.1 - version: 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + specifier: ^1.23.2 + version: 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@eslint/js': specifier: ^9.17.0 version: 9.17.0 @@ -231,8 +231,8 @@ importers: version: 19.0.0(react@19.0.0) devDependencies: '@eslint-react/eslint-plugin': - specifier: ^1.23.1 - version: 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + specifier: ^1.23.2 + version: 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@eslint/config-inspector': specifier: ^0.7.0 version: 0.7.0(eslint@9.17.0(jiti@2.4.2)) @@ -292,8 +292,8 @@ importers: version: 19.0.0(react@19.0.0) devDependencies: '@eslint-react/eslint-plugin': - specifier: ^1.23.1 - version: 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + specifier: ^1.23.2 + version: 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@eslint/config-inspector': specifier: ^0.7.0 version: 0.7.0(eslint@9.17.0(jiti@2.4.2)) @@ -344,8 +344,8 @@ importers: version: 19.0.0(react@19.0.0) devDependencies: '@eslint-react/eslint-plugin': - specifier: ^1.23.1 - version: 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + specifier: ^1.23.2 + version: 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@eslint/config-inspector': specifier: ^0.7.0 version: 0.7.0(eslint@9.17.0(jiti@2.4.2)) @@ -399,8 +399,8 @@ importers: specifier: ^7.26.3 version: 7.26.3(@babel/core@7.26.0) '@eslint-react/eslint-plugin': - specifier: ^1.23.1 - version: 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + specifier: ^1.23.2 + version: 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@eslint/config-inspector': specifier: ^0.7.0 version: 0.7.0(eslint@9.17.0(jiti@2.4.2)) @@ -927,8 +927,8 @@ importers: specifier: workspace:* version: link:../../workspace/configs fast-equals: - specifier: ^5.2.0 - version: 5.2.0 + specifier: ^5.2.1 + version: 5.2.1 micro-memoize: specifier: ^4.1.3 version: 4.1.3 @@ -939,8 +939,8 @@ importers: specifier: ^4.31.0 version: 4.31.0 valibot: - specifier: ^1.0.0-beta.10 - version: 1.0.0-beta.10(typescript@5.7.2) + specifier: ^1.0.0-beta.11 + version: 1.0.0-beta.11(typescript@5.7.2) packages/types: dependencies: @@ -1117,6 +1117,9 @@ importers: '@next/eslint-plugin-next': specifier: ^15.1.3 version: 15.1.3 + '@stylistic/eslint-plugin': + specifier: ^2.12.1 + version: 2.12.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@tailwindcss/postcss': specifier: ^4.0.0-beta.8 version: 4.0.0-beta.8 @@ -2655,20 +2658,20 @@ packages: resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - '@eslint-react/ast@1.23.1': - resolution: {integrity: sha512-nOFvXkeVj5sWxe79TfVQFz3+4MCwfDK8AAdmo/oUasJOcmFeqNVi0/pIVi9LqmZ7+9bZ/9UykleXUQ4Wv5fDog==} + '@eslint-react/ast@1.23.2': + resolution: {integrity: sha512-+D9dUcex2qXhqhIlE06Y2G6g9IMBFiEFtyAH76anUkhsJmH3llfsOzLUVeugex8wJjjkxHOYfZCj4yJgH+bB6w==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} - '@eslint-react/core@1.23.1': - resolution: {integrity: sha512-YkJBLQL3DxsYhJ6GFZ2UWbUQUv5V57J3nbwqWJXS9kT9fATb2cfM7vEMyxdNKjIZHngin+TfxMmVIX1R2ujEKQ==} + '@eslint-react/core@1.23.2': + resolution: {integrity: sha512-pm3H/4v+7X3UJ8mnJEz7QseZR/B94xC0Yd8Z/IJXAT6cN9nDCrCysENd1xLm0iOipAnCPCmsqO3RndGTwM7Oxw==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} - '@eslint-react/eff@1.23.1': - resolution: {integrity: sha512-1livj6Gj7d5qIOjwWlt86KTvhxNhRowAMSMY3aooZkQF9Pzl0jS/OYGxUNPTfBpdtksXOumNyvzVlVx9OQmt1w==} + '@eslint-react/eff@1.23.2': + resolution: {integrity: sha512-pLinl51denc906C8E/IYYSCxIY0o/OmNBLz5cJHt4Gr/spzmGv4myu/SOZWO/2YQGMg5TwOh5hLWNZ76Z6zDJA==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} - '@eslint-react/eslint-plugin@1.23.1': - resolution: {integrity: sha512-2FV5zxHGcIX6RmRtBcHDiBXNJ5Un47SF7Uh3OyypZY3hURSvDjVcPPSJCgD1elZV3UdW4Lc8kHb8K4Du59XGSA==} + '@eslint-react/eslint-plugin@1.23.2': + resolution: {integrity: sha512-M2T/ij/UTnrydFihI2eC1rqSTjlLK0MwTavrc7MxB2Bi6CxNdr4FrTrnEPpWjeECZHVEQQq8bmjwi7IUiQck8w==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -2677,20 +2680,20 @@ packages: typescript: optional: true - '@eslint-react/jsx@1.23.1': - resolution: {integrity: sha512-JCHz+T20E4voLPfMH5oDnDiXE31/4ZBR7OeOeVGEDS/kSiMHW1qrzrHUF3jZ+7ksHj4hKHlgRbib+aYmihuPFw==} + '@eslint-react/jsx@1.23.2': + resolution: {integrity: sha512-7z4otNmQ2t5D1Nbv0PXlPLGVmR7+qrwiAG41RJg2lPIVh30Kt6/4PnVWeWGFeveaCMjUfMqo0Qmkx/KIJPN9lw==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} - '@eslint-react/shared@1.23.1': - resolution: {integrity: sha512-LgpdVG94ln/KbPDOsYE7HiKWnq32E/orR0sQBVogHOJv3etWzTpEmLVRgWzbHy1yX/3TnrwcfDBQBXkZq8IcRA==} + '@eslint-react/shared@1.23.2': + resolution: {integrity: sha512-I45dowpR5n4iv6MfHmRpNPdBcRoET7XdTbFavZWGh5Kaux04xiJNTQ31C3bqv83gHX6QkTZofFeohVd2pa4T2w==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} - '@eslint-react/types@1.23.1': - resolution: {integrity: sha512-lEa8rHulduDlYcac1wU0muQveACwoidSIBbKn37A1NeBUjAj/OiU0YrfdStdYtiATGiuzW/EDD3MTw4NSltGtQ==} + '@eslint-react/types@1.23.2': + resolution: {integrity: sha512-dZvn40sk+IqaCRWUlZRdDKxLsNaZBlpdX0cWo6IiHMFZ2dliovV88haMvqXtSatpAZc0CzSkC7BC8bJeqAmrWg==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} - '@eslint-react/var@1.23.1': - resolution: {integrity: sha512-8jQ2JTZ8f8Jz2F1e1/lrUGQ0QbuRCG7bwHWUbm3EBa0DmCWRRzl5piCsJy2t3NjC57y71XY4A/TTtfEsIB2FLw==} + '@eslint-react/var@1.23.2': + resolution: {integrity: sha512-1XFmstpqpIwnZ6H/Xhm+QgYCPLlevZ33HjMEC1lNhv/+1xjGjutQfiavx91n68+HJ+lyk6mBV46+73wZi0dclw==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} '@eslint/compat@1.2.4': @@ -3735,6 +3738,12 @@ packages: '@shikijs/vscode-textmate@10.0.1': resolution: {integrity: sha512-fTIQwLF+Qhuws31iw7Ncl1R3HUDtGwIipiJ9iU+UsDUwMhegFcQKQHd51nZjb7CArq0MvON8rbgCGQYWHUKAdg==} + '@stylistic/eslint-plugin@2.12.1': + resolution: {integrity: sha512-fubZKIHSPuo07FgRTn6S4Nl0uXPRPYVNpyZzIDGfp7Fny6JjNus6kReLD7NI380JXi4HtUTSOZ34LBuNPO1XLQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: '>=8.40.0' + '@susisu/eslint-plugin-safe-typescript@0.9.2': resolution: {integrity: sha512-AKCf8wNO7mrfgTRGnZCpvchzZ7CqfMEXy2lJouRVbatQPSt53LBCgNmK0GxuRihbhCqqDKsUAYFG6n8akVEZ/Q==} peerDependencies: @@ -5209,8 +5218,8 @@ packages: peerDependencies: eslint: '>=8.0.0' - eslint-plugin-react-debug@1.23.1: - resolution: {integrity: sha512-vGtRVvmjj64W0IRTxKw1gku03SZ2yjJ3syPn0jQJwGUljFIwPGvPthz8vBoPuHYCjgsrmKmhsB0JAb0Tpc654w==} + eslint-plugin-react-debug@1.23.2: + resolution: {integrity: sha512-euDhBS9jsG13HfPAWNnKxgSHZHXdhP4IBGLwgH7y4fUjsalxdWohy0hADr8odE/G0+FUkTeYZAJ6PZikisI25g==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -5219,8 +5228,8 @@ packages: typescript: optional: true - eslint-plugin-react-dom@1.23.1: - resolution: {integrity: sha512-rED2tEbGC8S3izAy5N/O9twd9P2yBs4nqugWcDu0UBQmTPj4lM33RLqbQk+4iymOkuNJa//xQ8n2H/JqN+u/wQ==} + eslint-plugin-react-dom@1.23.2: + resolution: {integrity: sha512-uT+qAkeKiryD+gqKOBNbtX6QwG+bXvPLUwAGHS1cYoFQSR4OL75nsDvfNs6qOPOuElRsm/Blnaml34U6nylm/A==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -5229,8 +5238,8 @@ packages: typescript: optional: true - eslint-plugin-react-hooks-extra@1.23.1: - resolution: {integrity: sha512-a35+zboeKy5InFqz6Xe02v9qK+7cqump9zSQyD22JD24wJfWDNlGZAWr7seY8RvPLdDSI/YSNLWiIkcmMO01IQ==} + eslint-plugin-react-hooks-extra@1.23.2: + resolution: {integrity: sha512-FeLfexk9NHga6YMmEMaXMUC8irnEvr+RGtqF51l2XwvXNgerzmAzaUKq3qctKCtXIzTWglc+rnivQ9yl7SvxAg==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -5245,8 +5254,8 @@ packages: peerDependencies: eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 - eslint-plugin-react-naming-convention@1.23.1: - resolution: {integrity: sha512-VQ3g2NrflKj6kub8YeYjcDfbFhX0nXoIw3jvLm9jGG9H5JSlPDCI1h5igp3waDG0BejyM36TxuFK3mVWG539/w==} + eslint-plugin-react-naming-convention@1.23.2: + resolution: {integrity: sha512-Bdw0zrF92msJob/0nKAfTh/8Maj8MkG5L2/iqdGI5YwqXF0fS6aP8ZhDh1RtMKp9U6+4KW3btEpWsZwXjyat1g==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -5260,8 +5269,8 @@ packages: peerDependencies: eslint: '>=8.40' - eslint-plugin-react-web-api@1.23.1: - resolution: {integrity: sha512-8IpQCE2Nlp2p7z4Qp6WKM+eMjg1kmbkkkxWvZ1m+cuMvRb/77J/rXb55aqFTkIlF6j6Iop/nywV0MUt2yd8Fpw==} + eslint-plugin-react-web-api@1.23.2: + resolution: {integrity: sha512-7Uy0RBw1prEoy74S4/zdFKerNdpxQGxQ8XJl9V+JU1GULODpCBAgPKjv99pyhRo89wBP9LBJxoCZUCRt6b08NQ==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -5270,8 +5279,8 @@ packages: typescript: optional: true - eslint-plugin-react-x@1.23.1: - resolution: {integrity: sha512-XbtIPn1jay1F+oKj7O+oD399RpyfAiR+FCA72v0f+JWeBrhWj6Zzs277sOYHL7mN0d7KIaD5bqdxEtvqz7XCiA==} + eslint-plugin-react-x@1.23.2: + resolution: {integrity: sha512-RHfOtUvLGUVOE4D4PgmQYzxCVnJUeaXIYWyS01ixDOy5y0JwCZ+VAHHj1ArqefUbbu5Zen+aQmsKCYXQ4xaO/Q==} engines: {bun: '>=1.0.15', node: '>=18.18.0'} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -5444,8 +5453,8 @@ packages: fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} - fast-equals@5.2.0: - resolution: {integrity: sha512-3VpaQYf+CDFdRQfgsb+3vY7XaKjM35WCMoQTTE8h4S/eUkHzyJFOOA/gATYgoLejy4FBrEQD/sXe5Auk4cW/AQ==} + fast-equals@5.2.1: + resolution: {integrity: sha512-4DpZF7SS4GQO08ScYvTMuZSRik6Y+46ByOJOZR3yKjE69rooHcHB/UsO89qJyIlyvlya38296vypgnInFhRePA==} engines: {node: '>=6.0.0'} fast-glob@3.3.1: @@ -7962,8 +7971,8 @@ packages: engines: {node: '>=8'} hasBin: true - valibot@1.0.0-beta.10: - resolution: {integrity: sha512-nmo3nxvXRrxwDYZznK3aTgYv7ZA/SUZJ/s+pLY4Tqsex/fgwZ9XrrQ14jjozjUaeduQ9PhXHE2Xx1uMb0HePYw==} + valibot@1.0.0-beta.11: + resolution: {integrity: sha512-Ztl5Iks1Ql7Z6CwkS5oyqguN3G8tmUiNlsHpqbDt6DLMpm+eu+n8Q7f921gI3uHvNZ8xDVkd4cEJP5t+lELOfw==} peerDependencies: typescript: ^5.7.2 peerDependenciesMeta: @@ -9668,10 +9677,10 @@ snapshots: '@eslint-community/regexpp@4.12.1': {} - '@eslint-react/ast@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': + '@eslint-react/ast@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': dependencies: - '@eslint-react/eff': 1.23.1 - '@eslint-react/types': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/eff': 1.23.2 + '@eslint-react/types': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/types': 8.19.1 '@typescript-eslint/typescript-estree': 8.19.1(typescript@5.7.2) '@typescript-eslint/utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) @@ -9682,14 +9691,14 @@ snapshots: - supports-color - typescript - '@eslint-react/core@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': + '@eslint-react/core@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': dependencies: - '@eslint-react/ast': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/eff': 1.23.1 - '@eslint-react/jsx': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/shared': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/types': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/var': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/ast': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/eff': 1.23.2 + '@eslint-react/jsx': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/shared': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/types': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/var': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/scope-manager': 8.19.1 '@typescript-eslint/type-utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/types': 8.19.1 @@ -9700,35 +9709,35 @@ snapshots: - supports-color - typescript - '@eslint-react/eff@1.23.1': {} + '@eslint-react/eff@1.23.2': {} - '@eslint-react/eslint-plugin@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': + '@eslint-react/eslint-plugin@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': dependencies: - '@eslint-react/eff': 1.23.1 - '@eslint-react/shared': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/types': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/eff': 1.23.2 + '@eslint-react/shared': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/types': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/scope-manager': 8.19.1 '@typescript-eslint/type-utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/types': 8.19.1 '@typescript-eslint/utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) eslint: 9.17.0(jiti@2.4.2) - eslint-plugin-react-debug: 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - eslint-plugin-react-dom: 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - eslint-plugin-react-hooks-extra: 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - eslint-plugin-react-naming-convention: 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - eslint-plugin-react-web-api: 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - eslint-plugin-react-x: 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + eslint-plugin-react-debug: 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + eslint-plugin-react-dom: 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + eslint-plugin-react-hooks-extra: 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + eslint-plugin-react-naming-convention: 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + eslint-plugin-react-web-api: 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + eslint-plugin-react-x: 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) optionalDependencies: typescript: 5.7.2 transitivePeerDependencies: - supports-color - '@eslint-react/jsx@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': + '@eslint-react/jsx@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': dependencies: - '@eslint-react/ast': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/eff': 1.23.1 - '@eslint-react/types': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/var': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/ast': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/eff': 1.23.2 + '@eslint-react/types': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/var': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/scope-manager': 8.19.1 '@typescript-eslint/types': 8.19.1 '@typescript-eslint/utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) @@ -9738,23 +9747,20 @@ snapshots: - supports-color - typescript - '@eslint-react/shared@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': + '@eslint-react/shared@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': dependencies: - '@eslint-react/eff': 1.23.1 + '@eslint-react/eff': 1.23.2 '@typescript-eslint/utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - fast-equals: 5.2.0 - micro-memoize: 4.1.3 picomatch: 4.0.2 ts-pattern: 5.6.0 - valibot: 1.0.0-beta.10(typescript@5.7.2) transitivePeerDependencies: - eslint - supports-color - typescript - '@eslint-react/types@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': + '@eslint-react/types@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': dependencies: - '@eslint-react/eff': 1.23.1 + '@eslint-react/eff': 1.23.2 '@typescript-eslint/types': 8.19.1 '@typescript-eslint/utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) transitivePeerDependencies: @@ -9762,11 +9768,11 @@ snapshots: - supports-color - typescript - '@eslint-react/var@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': + '@eslint-react/var@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': dependencies: - '@eslint-react/ast': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/eff': 1.23.1 - '@eslint-react/types': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/ast': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/eff': 1.23.2 + '@eslint-react/types': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/scope-manager': 8.19.1 '@typescript-eslint/types': 8.19.1 '@typescript-eslint/utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) @@ -10780,6 +10786,18 @@ snapshots: '@shikijs/vscode-textmate@10.0.1': {} + '@stylistic/eslint-plugin@2.12.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2)': + dependencies: + '@typescript-eslint/utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + eslint: 9.17.0(jiti@2.4.2) + eslint-visitor-keys: 4.2.0 + espree: 10.3.0 + estraverse: 5.3.0 + picomatch: 4.0.2 + transitivePeerDependencies: + - supports-color + - typescript + '@susisu/eslint-plugin-safe-typescript@0.9.2(@typescript-eslint/parser@8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2))(eslint@9.17.0(jiti@2.4.2))(typescript-eslint@8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2))(typescript@5.7.2)': dependencies: '@types/eslint': 9.6.1 @@ -11847,7 +11865,7 @@ snapshots: '@cspell/cspell-pipe': 8.17.1 '@cspell/cspell-types': 8.17.1 cspell-trie-lib: 8.17.1 - fast-equals: 5.2.0 + fast-equals: 5.2.1 cspell-gitignore@8.17.1: dependencies: @@ -11890,7 +11908,7 @@ snapshots: cspell-io: 8.17.1 cspell-trie-lib: 8.17.1 env-paths: 3.0.0 - fast-equals: 5.2.0 + fast-equals: 5.2.1 gensequence: 7.0.0 import-fresh: 3.3.0 resolve-from: 5.0.0 @@ -12504,15 +12522,15 @@ snapshots: - supports-color - typescript - eslint-plugin-react-debug@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2): + eslint-plugin-react-debug@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2): dependencies: - '@eslint-react/ast': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/core': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/eff': 1.23.1 - '@eslint-react/jsx': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/shared': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/types': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/var': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/ast': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/core': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/eff': 1.23.2 + '@eslint-react/jsx': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/shared': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/types': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/var': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/scope-manager': 8.19.1 '@typescript-eslint/type-utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/types': 8.19.1 @@ -12525,15 +12543,15 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-react-dom@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2): + eslint-plugin-react-dom@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2): dependencies: - '@eslint-react/ast': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/core': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/eff': 1.23.1 - '@eslint-react/jsx': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/shared': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/types': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/var': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/ast': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/core': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/eff': 1.23.2 + '@eslint-react/jsx': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/shared': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/types': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/var': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/scope-manager': 8.19.1 '@typescript-eslint/types': 8.19.1 '@typescript-eslint/utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) @@ -12546,15 +12564,15 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-react-hooks-extra@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2): + eslint-plugin-react-hooks-extra@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2): dependencies: - '@eslint-react/ast': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/core': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/eff': 1.23.1 - '@eslint-react/jsx': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/shared': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/types': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/var': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/ast': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/core': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/eff': 1.23.2 + '@eslint-react/jsx': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/shared': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/types': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/var': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/scope-manager': 8.19.1 '@typescript-eslint/type-utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/types': 8.19.1 @@ -12571,14 +12589,14 @@ snapshots: dependencies: eslint: 9.17.0(jiti@2.4.2) - eslint-plugin-react-naming-convention@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2): + eslint-plugin-react-naming-convention@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2): dependencies: - '@eslint-react/ast': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/core': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/eff': 1.23.1 - '@eslint-react/jsx': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/shared': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/types': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/ast': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/core': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/eff': 1.23.2 + '@eslint-react/jsx': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/shared': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/types': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/scope-manager': 8.19.1 '@typescript-eslint/type-utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/types': 8.19.1 @@ -12595,15 +12613,15 @@ snapshots: dependencies: eslint: 9.17.0(jiti@2.4.2) - eslint-plugin-react-web-api@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2): + eslint-plugin-react-web-api@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2): dependencies: - '@eslint-react/ast': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/core': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/eff': 1.23.1 - '@eslint-react/jsx': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/shared': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/types': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/var': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/ast': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/core': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/eff': 1.23.2 + '@eslint-react/jsx': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/shared': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/types': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/var': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/scope-manager': 8.19.1 '@typescript-eslint/types': 8.19.1 '@typescript-eslint/utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) @@ -12615,15 +12633,15 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-react-x@1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2): + eslint-plugin-react-x@1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2): dependencies: - '@eslint-react/ast': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/core': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/eff': 1.23.1 - '@eslint-react/jsx': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/shared': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/types': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) - '@eslint-react/var': 1.23.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/ast': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/core': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/eff': 1.23.2 + '@eslint-react/jsx': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/shared': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/types': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) + '@eslint-react/var': 1.23.2(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/scope-manager': 8.19.1 '@typescript-eslint/type-utils': 8.19.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.7.2) '@typescript-eslint/types': 8.19.1 @@ -12854,7 +12872,7 @@ snapshots: fast-deep-equal@3.1.3: {} - fast-equals@5.2.0: {} + fast-equals@5.2.1: {} fast-glob@3.3.1: dependencies: @@ -15939,7 +15957,7 @@ snapshots: kleur: 4.1.5 sade: 1.8.1 - valibot@1.0.0-beta.10(typescript@5.7.2): + valibot@1.0.0-beta.11(typescript@5.7.2): optionalDependencies: typescript: 5.7.2 diff --git a/scripts/verify-lockfile.ts b/scripts/verify-lockfile.ts index 7701e10ccb..9fbf0e2d82 100644 --- a/scripts/verify-lockfile.ts +++ b/scripts/verify-lockfile.ts @@ -6,7 +6,9 @@ const command = Command.make("git", "diff", "HEAD@{1}", "--stat", "--", "./pnpm- const program = Effect.gen(function*() { const executor = yield* CommandExecutor.CommandExecutor; const output = yield* executor.lines(command); - if (output.length === 0) return; + if (output.length === 0) { + return; + } yield* Effect.logWarning("Detected changes in pnpm-lock.yaml!"); yield* Effect.logWarning("Please run `pnpm install` to update local dependencies."); }); diff --git a/website/package.json b/website/package.json index 07d61e5f4b..3106b912b6 100644 --- a/website/package.json +++ b/website/package.json @@ -27,6 +27,7 @@ "@mdx-js/mdx": "^3.1.0", "@next/bundle-analyzer": "^15.1.3", "@next/eslint-plugin-next": "^15.1.3", + "@stylistic/eslint-plugin": "^2.12.1", "@tailwindcss/postcss": "^4.0.0-beta.8", "@tsconfig/node22": "^22.0.0", "@tsconfig/strictest": "^2.0.5", diff --git a/workspace/configs/package.json b/workspace/configs/package.json index d901d889f1..242f1fa622 100644 --- a/workspace/configs/package.json +++ b/workspace/configs/package.json @@ -3,9 +3,9 @@ "version": "0.0.0", "private": true, "description": "Local configuration files", + "sideEffects": false, "exports": { "./tsconfig.base.json": "./tsconfig.base.json", "./typedoc.base.json": "./typedoc.base.json" - }, - "sideEffects": false + } } diff --git a/workspace/eslint-plugin-deps/package.json b/workspace/eslint-plugin-deps/package.json index eb5c43b381..abf8a620a5 100644 --- a/workspace/eslint-plugin-deps/package.json +++ b/workspace/eslint-plugin-deps/package.json @@ -3,6 +3,7 @@ "version": "0.0.0", "private": true, "description": "Local ESLint dependencies", + "sideEffects": false, "dependencies": { "@eslint/markdown": "^6.2.1", "@susisu/eslint-plugin-safe-typescript": "^0.9.2", @@ -14,6 +15,5 @@ "eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-unicorn": "^56.0.1", "eslint-plugin-vitest": "^0.5.4" - }, - "sideEffects": false + } } diff --git a/workspace/eslint-plugin-local/package.json b/workspace/eslint-plugin-local/package.json index 14cf769272..78c7bc1d73 100644 --- a/workspace/eslint-plugin-local/package.json +++ b/workspace/eslint-plugin-local/package.json @@ -3,6 +3,7 @@ "version": "0.0.0", "private": true, "description": "Local ESLint pluginf for use in the workspace", + "sideEffects": false, "type": "module", "exports": { ".": { @@ -45,6 +46,5 @@ "engines": { "bun": ">=1.0.15", "node": ">=18.18.0" - }, - "sideEffects": false + } }