diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 98297ff30d..0000000000 --- a/.eslintignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -packages/*/lib -packages/*/dist -jest.config.js -packages/just-stack-monorepo/template/common/scripts -packages/example-lib -packages/documentation/website/build -packages/codemods/src/__testfixtures__ diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index a743144352..0000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "extends": ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended"], - "env": { - "node": true, - "es6": true, - "browser": true - }, - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint", "import"], - "rules": { - "indent": "off", - "no-unused-vars": "off", - "quotes": [ - "error", - "single", - { - "avoidEscape": true, - "allowTemplateLiterals": true - } - ], - "prefer-rest-params": "off", - "no-useless-escape": "off", - "require-atomic-updates": "off", - "@typescript-eslint/indent": "off", - "@typescript-eslint/interface-name-prefix": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/no-use-before-define": "off", - "@typescript-eslint/no-object-literal-type-assertion": "off", - "@typescript-eslint/array-type": "off", - "@typescript-eslint/no-var-requires": "off", - "@typescript-eslint/no-unused-vars": "off", - "import/order": [ - "error", - { - "newlines-between": "always", - "groups": ["builtin", "external", "internal", ["parent", "sibling", "index"]], - "pathGroups": [ - { - "pattern": "react+(|-native)", - "group": "external", - "position": "before" - } - ], - "pathGroupsExcludedImportTypes": ["react"], - "alphabetize": { - "order": "asc", - "caseInsensitive": true - } - } - ] - }, - "overrides": [ - { - "files": "*.js", - "parserOptions": { - "sourceType": "script" - } - }, - { - "files": "*.spec.js", - "env": { - "jest": true - } - }, - { - "files": "*.spec.{ts,js}", - "rules": { - "@typescript-eslint/no-non-null-assertion": "off" - } - } - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json index e763bb6801..ff320b97c0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,7 +9,7 @@ }, "eslint.enable": true, - "eslint.workingDirectories": [{ "mode": "auto" }], // infer working directory based on .eslintrc/package.json location + "eslint.workingDirectories": [{ "pattern": "./packages/framework/eslint-config-rules" }], // use the common eslint config file "explorer.fileNesting.enabled": true, "explorer.fileNesting.patterns": { diff --git a/apps/E2E/eslint.config.js b/apps/E2E/eslint.config.js index c98098e068..5ed9a7bc32 100644 --- a/apps/E2E/eslint.config.js +++ b/apps/E2E/eslint.config.js @@ -1,3 +1,11 @@ const baseConfig = require('@fluentui-react-native/eslint-config-rules'); -module.exports = baseConfig; +module.exports = [ + ...baseConfig, + { + rules: { + '@typescript-eslint/no-duplicate-enum-values': 'off', + '@typescript-eslint/no-invalid-void-type': 'off', + }, + }, +]; diff --git a/apps/fluent-tester/src/TestComponents/Badge/BasicBadgeTest.tsx b/apps/fluent-tester/src/TestComponents/Badge/BasicBadgeTest.tsx index cc5302c4b2..bd9d677529 100644 --- a/apps/fluent-tester/src/TestComponents/Badge/BasicBadgeTest.tsx +++ b/apps/fluent-tester/src/TestComponents/Badge/BasicBadgeTest.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import React, { useState, useCallback, useMemo } from 'react'; import { View, Platform, Image } from 'react-native'; diff --git a/apps/fluent-tester/src/TestComponents/Badge/CounterBadgeTest.tsx b/apps/fluent-tester/src/TestComponents/Badge/CounterBadgeTest.tsx index ac6b8d5264..a4c01fdca7 100644 --- a/apps/fluent-tester/src/TestComponents/Badge/CounterBadgeTest.tsx +++ b/apps/fluent-tester/src/TestComponents/Badge/CounterBadgeTest.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import React from 'react'; import { View, Platform, Text } from 'react-native'; diff --git a/apps/fluent-tester/src/TestComponents/Badge/PresenceBadgeTest.android.tsx b/apps/fluent-tester/src/TestComponents/Badge/PresenceBadgeTest.android.tsx index 5fb358f9c8..d9c3445808 100644 --- a/apps/fluent-tester/src/TestComponents/Badge/PresenceBadgeTest.android.tsx +++ b/apps/fluent-tester/src/TestComponents/Badge/PresenceBadgeTest.android.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import React, { useCallback, useState } from 'react'; import { View, StyleSheet, Text } from 'react-native'; diff --git a/apps/fluent-tester/src/TestComponents/Badge/PresenceBadgeTest.tsx b/apps/fluent-tester/src/TestComponents/Badge/PresenceBadgeTest.tsx index a2671d3d55..cc0ad103cd 100644 --- a/apps/fluent-tester/src/TestComponents/Badge/PresenceBadgeTest.tsx +++ b/apps/fluent-tester/src/TestComponents/Badge/PresenceBadgeTest.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import React, { useState, useCallback } from 'react'; import { View, Platform, Text } from 'react-native'; diff --git a/apps/fluent-tester/src/TestComponents/Button/E2EButtonTest.tsx b/apps/fluent-tester/src/TestComponents/Button/E2EButtonTest.tsx index 6b56795a46..1b305b610c 100644 --- a/apps/fluent-tester/src/TestComponents/Button/E2EButtonTest.tsx +++ b/apps/fluent-tester/src/TestComponents/Button/E2EButtonTest.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import * as React from 'react'; import { View } from 'react-native'; diff --git a/apps/fluent-tester/src/TestComponents/Button/deprecated/ButtonIconTest.tsx b/apps/fluent-tester/src/TestComponents/Button/deprecated/ButtonIconTest.tsx index 3e713557f2..6325df6306 100644 --- a/apps/fluent-tester/src/TestComponents/Button/deprecated/ButtonIconTest.tsx +++ b/apps/fluent-tester/src/TestComponents/Button/deprecated/ButtonIconTest.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import * as React from 'react'; import { Platform, View } from 'react-native'; @@ -14,8 +13,6 @@ const CustomizedIconButton = Button.customize({ }); export const ButtonIconTest_deprecated: React.FunctionComponent = () => { - /* eslint-disable @typescript-eslint/no-var-requires */ - // SVG-based icons are not available on all platforms yet const svgIconsEnabled = ['ios', 'macos', 'win32', 'android'].includes(Platform.OS as string); const iconProps = { svgSource: svgProps, width: 20, height: 20 }; diff --git a/apps/fluent-tester/src/TestComponents/Button/deprecated/E2EButtonTest.tsx b/apps/fluent-tester/src/TestComponents/Button/deprecated/E2EButtonTest.tsx index 7e2e9294c0..8a2998bdc0 100644 --- a/apps/fluent-tester/src/TestComponents/Button/deprecated/E2EButtonTest.tsx +++ b/apps/fluent-tester/src/TestComponents/Button/deprecated/E2EButtonTest.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import * as React from 'react'; import { View } from 'react-native'; diff --git a/apps/fluent-tester/src/TestComponents/Chip/ChipDefault.tsx b/apps/fluent-tester/src/TestComponents/Chip/ChipDefault.tsx index 6d445e4059..fb41be297f 100644 --- a/apps/fluent-tester/src/TestComponents/Chip/ChipDefault.tsx +++ b/apps/fluent-tester/src/TestComponents/Chip/ChipDefault.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import React, { useCallback } from 'react'; import { StyleSheet, View, ToastAndroid } from 'react-native'; diff --git a/apps/fluent-tester/src/TestComponents/ContextualMenu/ContextualMenuTest.tsx b/apps/fluent-tester/src/TestComponents/ContextualMenu/ContextualMenuTest.tsx index beb8a1335a..8c74f69d15 100644 --- a/apps/fluent-tester/src/TestComponents/ContextualMenu/ContextualMenuTest.tsx +++ b/apps/fluent-tester/src/TestComponents/ContextualMenu/ContextualMenuTest.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import * as React from 'react'; import { Text, View, Switch } from 'react-native'; diff --git a/apps/fluent-tester/src/TestComponents/ContextualMenu/E2EContextualMenuTest.tsx b/apps/fluent-tester/src/TestComponents/ContextualMenu/E2EContextualMenuTest.tsx index b1921e4f73..e7859d9f55 100644 --- a/apps/fluent-tester/src/TestComponents/ContextualMenu/E2EContextualMenuTest.tsx +++ b/apps/fluent-tester/src/TestComponents/ContextualMenu/E2EContextualMenuTest.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import * as React from 'react'; import { Text, View, Switch } from 'react-native'; diff --git a/apps/fluent-tester/src/TestComponents/Icon/IconLegacyE2ETest.tsx b/apps/fluent-tester/src/TestComponents/Icon/IconLegacyE2ETest.tsx index c75997ec96..5524adf419 100644 --- a/apps/fluent-tester/src/TestComponents/Icon/IconLegacyE2ETest.tsx +++ b/apps/fluent-tester/src/TestComponents/Icon/IconLegacyE2ETest.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import * as React from 'react'; import { View } from 'react-native'; diff --git a/apps/fluent-tester/src/TestComponents/Icon/IconTest.tsx b/apps/fluent-tester/src/TestComponents/Icon/IconTest.tsx index f13905cea3..2dca34ca79 100644 --- a/apps/fluent-tester/src/TestComponents/Icon/IconTest.tsx +++ b/apps/fluent-tester/src/TestComponents/Icon/IconTest.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import * as React from 'react'; import { Platform, PlatformColor, View } from 'react-native'; diff --git a/apps/fluent-tester/src/TestComponents/Icon/IconV1E2ETest.tsx b/apps/fluent-tester/src/TestComponents/Icon/IconV1E2ETest.tsx index 937ada569b..f31ddbd7e1 100644 --- a/apps/fluent-tester/src/TestComponents/Icon/IconV1E2ETest.tsx +++ b/apps/fluent-tester/src/TestComponents/Icon/IconV1E2ETest.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import * as React from 'react'; import { View } from 'react-native'; diff --git a/apps/fluent-tester/src/TestComponents/MenuButtonLegacy/testData.ts b/apps/fluent-tester/src/TestComponents/MenuButtonLegacy/testData.ts index ccd690872b..31ddda93e6 100644 --- a/apps/fluent-tester/src/TestComponents/MenuButtonLegacy/testData.ts +++ b/apps/fluent-tester/src/TestComponents/MenuButtonLegacy/testData.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import type { MenuButtonItemProps } from '@fluentui/react-native'; import { MENU_ITEM_1_COMPONENT } from '@fluentui-react-native/e2e-testing'; diff --git a/apps/fluent-tester/src/TestComponents/MenuButtonV1/testData.ts b/apps/fluent-tester/src/TestComponents/MenuButtonV1/testData.ts index b977ef4064..84b90227af 100644 --- a/apps/fluent-tester/src/TestComponents/MenuButtonV1/testData.ts +++ b/apps/fluent-tester/src/TestComponents/MenuButtonV1/testData.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ import type { MenuButtonItemProps } from '@fluentui/react-native'; import { testImage, svgProps } from '../Common/iconExamples'; diff --git a/apps/fluent-tester/src/TestComponents/Svg/SvgTest.tsx b/apps/fluent-tester/src/TestComponents/Svg/SvgTest.tsx index 282737d680..7745266c51 100644 --- a/apps/fluent-tester/src/TestComponents/Svg/SvgTest.tsx +++ b/apps/fluent-tester/src/TestComponents/Svg/SvgTest.tsx @@ -225,9 +225,6 @@ const BundledSvgTest: React.FunctionComponent = () => { }; const RemoteSvgTest: React.FunctionComponent = () => { - // GH#1596: Temporarily stop testing this case until it can be either more robust or removed - const shouldShowLocalNetwork = false; - return ( { accessibilityLabel="SVG Uri Test" accessibilityRole="image" /> - {shouldShowLocalNetwork && ( - - )} ); }; diff --git a/change/@fluentui-react-native-adapters-3e6769fd-4d09-4122-8581-9db381a4bf1d.json b/change/@fluentui-react-native-adapters-3e6769fd-4d09-4122-8581-9db381a4bf1d.json new file mode 100644 index 0000000000..578787ecec --- /dev/null +++ b/change/@fluentui-react-native-adapters-3e6769fd-4d09-4122-8581-9db381a4bf1d.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/adapters", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-android-theme-98515c50-65ab-457e-b5e3-f74360d299a1.json b/change/@fluentui-react-native-android-theme-98515c50-65ab-457e-b5e3-f74360d299a1.json new file mode 100644 index 0000000000..1c1fac107c --- /dev/null +++ b/change/@fluentui-react-native-android-theme-98515c50-65ab-457e-b5e3-f74360d299a1.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/android-theme", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-apple-theme-8718ada1-1b3d-4271-98fd-95a8eb900fdc.json b/change/@fluentui-react-native-apple-theme-8718ada1-1b3d-4271-98fd-95a8eb900fdc.json new file mode 100644 index 0000000000..f5bf680b31 --- /dev/null +++ b/change/@fluentui-react-native-apple-theme-8718ada1-1b3d-4271-98fd-95a8eb900fdc.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/apple-theme", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-badge-9e71f599-3e29-44a7-b2fc-b510b0d0f601.json b/change/@fluentui-react-native-badge-9e71f599-3e29-44a7-b2fc-b510b0d0f601.json new file mode 100644 index 0000000000..e803b1b5f4 --- /dev/null +++ b/change/@fluentui-react-native-badge-9e71f599-3e29-44a7-b2fc-b510b0d0f601.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/badge", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-button-c1ad771e-45ff-46d8-83b5-0fdccb118fd8.json b/change/@fluentui-react-native-button-c1ad771e-45ff-46d8-83b5-0fdccb118fd8.json new file mode 100644 index 0000000000..f839cf96e9 --- /dev/null +++ b/change/@fluentui-react-native-button-c1ad771e-45ff-46d8-83b5-0fdccb118fd8.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/button", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-chip-832280b9-5bed-4cb7-8e4d-fed76cb126a5.json b/change/@fluentui-react-native-chip-832280b9-5bed-4cb7-8e4d-fed76cb126a5.json new file mode 100644 index 0000000000..e1be9fbadc --- /dev/null +++ b/change/@fluentui-react-native-chip-832280b9-5bed-4cb7-8e4d-fed76cb126a5.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/chip", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-codemods-8d308b4b-cfb2-4f1f-9346-1ff072fed447.json b/change/@fluentui-react-native-codemods-8d308b4b-cfb2-4f1f-9346-1ff072fed447.json new file mode 100644 index 0000000000..f6d0114867 --- /dev/null +++ b/change/@fluentui-react-native-codemods-8d308b4b-cfb2-4f1f-9346-1ff072fed447.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/codemods", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-default-theme-29a0f266-77d4-42f9-8c88-205cd32341ec.json b/change/@fluentui-react-native-default-theme-29a0f266-77d4-42f9-8c88-205cd32341ec.json new file mode 100644 index 0000000000..2f8c52751c --- /dev/null +++ b/change/@fluentui-react-native-default-theme-29a0f266-77d4-42f9-8c88-205cd32341ec.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/default-theme", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-dropdown-27d9b943-560c-4dbf-849d-e967cb0fca57.json b/change/@fluentui-react-native-dropdown-27d9b943-560c-4dbf-849d-e967cb0fca57.json new file mode 100644 index 0000000000..a6aa84454d --- /dev/null +++ b/change/@fluentui-react-native-dropdown-27d9b943-560c-4dbf-849d-e967cb0fca57.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/dropdown", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-e2e-testing-37de513c-aca4-42e1-a268-d107e2b55d81.json b/change/@fluentui-react-native-e2e-testing-37de513c-aca4-42e1-a268-d107e2b55d81.json new file mode 100644 index 0000000000..1e675dff79 --- /dev/null +++ b/change/@fluentui-react-native-e2e-testing-37de513c-aca4-42e1-a268-d107e2b55d81.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/e2e-testing", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-experimental-appearance-additions-cf6a2762-71cd-4094-8117-404c7a16e5ba.json b/change/@fluentui-react-native-experimental-appearance-additions-cf6a2762-71cd-4094-8117-404c7a16e5ba.json new file mode 100644 index 0000000000..f8fe8a9a9b --- /dev/null +++ b/change/@fluentui-react-native-experimental-appearance-additions-cf6a2762-71cd-4094-8117-404c7a16e5ba.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/experimental-appearance-additions", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-focus-zone-768810b8-9093-4939-a910-cab9fd6d8dcf.json b/change/@fluentui-react-native-focus-zone-768810b8-9093-4939-a910-cab9fd6d8dcf.json new file mode 100644 index 0000000000..947a6da63b --- /dev/null +++ b/change/@fluentui-react-native-focus-zone-768810b8-9093-4939-a910-cab9fd6d8dcf.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/focus-zone", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-framework-a52d2934-bf00-442c-b88b-d196b4f103e0.json b/change/@fluentui-react-native-framework-a52d2934-bf00-442c-b88b-d196b4f103e0.json new file mode 100644 index 0000000000..413a3e525a --- /dev/null +++ b/change/@fluentui-react-native-framework-a52d2934-bf00-442c-b88b-d196b4f103e0.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/framework", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-immutable-merge-c2268509-58df-4bc3-9d22-373050f9ab8d.json b/change/@fluentui-react-native-immutable-merge-c2268509-58df-4bc3-9d22-373050f9ab8d.json new file mode 100644 index 0000000000..faa34b48c2 --- /dev/null +++ b/change/@fluentui-react-native-immutable-merge-c2268509-58df-4bc3-9d22-373050f9ab8d.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/immutable-merge", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-interactive-hooks-ae27cfa5-bf28-4a25-a0fd-431e62b90884.json b/change/@fluentui-react-native-interactive-hooks-ae27cfa5-bf28-4a25-a0fd-431e62b90884.json new file mode 100644 index 0000000000..bcbb71d529 --- /dev/null +++ b/change/@fluentui-react-native-interactive-hooks-ae27cfa5-bf28-4a25-a0fd-431e62b90884.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/interactive-hooks", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-link-60d1ec07-cc43-4c24-a83d-16b05544e9ab.json b/change/@fluentui-react-native-link-60d1ec07-cc43-4c24-a83d-16b05544e9ab.json new file mode 100644 index 0000000000..4bd935bfdb --- /dev/null +++ b/change/@fluentui-react-native-link-60d1ec07-cc43-4c24-a83d-16b05544e9ab.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/link", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-memo-cache-a7d6b9d9-7a56-402d-b67b-d73f0c3ae745.json b/change/@fluentui-react-native-memo-cache-a7d6b9d9-7a56-402d-b67b-d73f0c3ae745.json new file mode 100644 index 0000000000..25be062faa --- /dev/null +++ b/change/@fluentui-react-native-memo-cache-a7d6b9d9-7a56-402d-b67b-d73f0c3ae745.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/memo-cache", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-menu-a1c6c0a4-95bb-4486-bbcf-a53e92ad6bb7.json b/change/@fluentui-react-native-menu-a1c6c0a4-95bb-4486-bbcf-a53e92ad6bb7.json new file mode 100644 index 0000000000..9d4280970f --- /dev/null +++ b/change/@fluentui-react-native-menu-a1c6c0a4-95bb-4486-bbcf-a53e92ad6bb7.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/menu", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-merge-props-7d1376dc-5b1e-4cb5-b8ba-5b34ed880632.json b/change/@fluentui-react-native-merge-props-7d1376dc-5b1e-4cb5-b8ba-5b34ed880632.json new file mode 100644 index 0000000000..19f2883705 --- /dev/null +++ b/change/@fluentui-react-native-merge-props-7d1376dc-5b1e-4cb5-b8ba-5b34ed880632.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/merge-props", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-popover-0c8d05cb-5282-419d-a50d-4795a0a864f0.json b/change/@fluentui-react-native-popover-0c8d05cb-5282-419d-a50d-4795a0a864f0.json new file mode 100644 index 0000000000..ac65bfa40a --- /dev/null +++ b/change/@fluentui-react-native-popover-0c8d05cb-5282-419d-a50d-4795a0a864f0.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/popover", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-pressable-a4120a74-65da-47fc-a4f1-209de9dcfd2a.json b/change/@fluentui-react-native-pressable-a4120a74-65da-47fc-a4f1-209de9dcfd2a.json new file mode 100644 index 0000000000..fe2f85ee77 --- /dev/null +++ b/change/@fluentui-react-native-pressable-a4120a74-65da-47fc-a4f1-209de9dcfd2a.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/pressable", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-radio-group-11894281-4261-4f73-9294-e2010a724af3.json b/change/@fluentui-react-native-radio-group-11894281-4261-4f73-9294-e2010a724af3.json new file mode 100644 index 0000000000..08d015e509 --- /dev/null +++ b/change/@fluentui-react-native-radio-group-11894281-4261-4f73-9294-e2010a724af3.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/radio-group", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-stack-89710f69-d4b7-4289-a6a8-db8535bfafcc.json b/change/@fluentui-react-native-stack-89710f69-d4b7-4289-a6a8-db8535bfafcc.json new file mode 100644 index 0000000000..5fddb4d722 --- /dev/null +++ b/change/@fluentui-react-native-stack-89710f69-d4b7-4289-a6a8-db8535bfafcc.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/stack", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-tablist-0a87735d-4501-49a2-bdee-4f89cfeeeab2.json b/change/@fluentui-react-native-tablist-0a87735d-4501-49a2-bdee-4f89cfeeeab2.json new file mode 100644 index 0000000000..505f24bbc5 --- /dev/null +++ b/change/@fluentui-react-native-tablist-0a87735d-4501-49a2-bdee-4f89cfeeeab2.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/tablist", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-tester-0e76f426-0103-4261-8d07-d8510997e418.json b/change/@fluentui-react-native-tester-0e76f426-0103-4261-8d07-d8510997e418.json new file mode 100644 index 0000000000..3dd0c50b7d --- /dev/null +++ b/change/@fluentui-react-native-tester-0e76f426-0103-4261-8d07-d8510997e418.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/tester", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-theme-tokens-1f9944bb-4a08-484d-9a01-1dcc5b55d3e8.json b/change/@fluentui-react-native-theme-tokens-1f9944bb-4a08-484d-9a01-1dcc5b55d3e8.json new file mode 100644 index 0000000000..a1953eb940 --- /dev/null +++ b/change/@fluentui-react-native-theme-tokens-1f9944bb-4a08-484d-9a01-1dcc5b55d3e8.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/theme-tokens", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-theme-types-492f6917-4850-46d2-bca8-e1553c1fbbf4.json b/change/@fluentui-react-native-theme-types-492f6917-4850-46d2-bca8-e1553c1fbbf4.json new file mode 100644 index 0000000000..b3755aee9b --- /dev/null +++ b/change/@fluentui-react-native-theme-types-492f6917-4850-46d2-bca8-e1553c1fbbf4.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/theme-types", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-themed-stylesheet-2aca423d-cf34-471b-82b4-8da39e0345f8.json b/change/@fluentui-react-native-themed-stylesheet-2aca423d-cf34-471b-82b4-8da39e0345f8.json new file mode 100644 index 0000000000..36d0dc66d7 --- /dev/null +++ b/change/@fluentui-react-native-themed-stylesheet-2aca423d-cf34-471b-82b4-8da39e0345f8.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/themed-stylesheet", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-use-slot-d2bac431-2c6d-41ee-a592-8cf7d0739c22.json b/change/@fluentui-react-native-use-slot-d2bac431-2c6d-41ee-a592-8cf7d0739c22.json new file mode 100644 index 0000000000..8f21dc1b49 --- /dev/null +++ b/change/@fluentui-react-native-use-slot-d2bac431-2c6d-41ee-a592-8cf7d0739c22.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/use-slot", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-use-slots-4cb3c6d6-74bc-4635-a41a-3991f941e8e7.json b/change/@fluentui-react-native-use-slots-4cb3c6d6-74bc-4635-a41a-3991f941e8e7.json new file mode 100644 index 0000000000..477cf77fed --- /dev/null +++ b/change/@fluentui-react-native-use-slots-4cb3c6d6-74bc-4635-a41a-3991f941e8e7.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/use-slots", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-native-win32-theme-d5521e8a-e17d-4615-87aa-8a09099460bd.json b/change/@fluentui-react-native-win32-theme-d5521e8a-e17d-4615-87aa-8a09099460bd.json new file mode 100644 index 0000000000..30305f7254 --- /dev/null +++ b/change/@fluentui-react-native-win32-theme-d5521e8a-e17d-4615-87aa-8a09099460bd.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@fluentui-react-native/win32-theme", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@uifabricshared-foundation-composable-4db5720e-eb0c-4a9b-be71-1eb8c388ed78.json b/change/@uifabricshared-foundation-composable-4db5720e-eb0c-4a9b-be71-1eb8c388ed78.json new file mode 100644 index 0000000000..47008140b4 --- /dev/null +++ b/change/@uifabricshared-foundation-composable-4db5720e-eb0c-4a9b-be71-1eb8c388ed78.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@uifabricshared/foundation-composable", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@uifabricshared-foundation-compose-baed93dc-60c9-4600-bf50-7d5521df6461.json b/change/@uifabricshared-foundation-compose-baed93dc-60c9-4600-bf50-7d5521df6461.json new file mode 100644 index 0000000000..63b75d71ed --- /dev/null +++ b/change/@uifabricshared-foundation-compose-baed93dc-60c9-4600-bf50-7d5521df6461.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@uifabricshared/foundation-compose", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@uifabricshared-foundation-settings-f67a238a-9678-4a3b-8282-4292f87f0240.json b/change/@uifabricshared-foundation-settings-f67a238a-9678-4a3b-8282-4292f87f0240.json new file mode 100644 index 0000000000..b8bb6ee410 --- /dev/null +++ b/change/@uifabricshared-foundation-settings-f67a238a-9678-4a3b-8282-4292f87f0240.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@uifabricshared/foundation-settings", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@uifabricshared-theme-registry-2af1a8e1-c4b7-4ea7-8a1d-06cd134dfb09.json b/change/@uifabricshared-theme-registry-2af1a8e1-c4b7-4ea7-8a1d-06cd134dfb09.json new file mode 100644 index 0000000000..b9bdae7828 --- /dev/null +++ b/change/@uifabricshared-theme-registry-2af1a8e1-c4b7-4ea7-8a1d-06cd134dfb09.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@uifabricshared/theme-registry", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@uifabricshared-themed-settings-dc337503-b188-467d-8958-53fd625d4912.json b/change/@uifabricshared-themed-settings-dc337503-b188-467d-8958-53fd625d4912.json new file mode 100644 index 0000000000..bab073fe28 --- /dev/null +++ b/change/@uifabricshared-themed-settings-dc337503-b188-467d-8958-53fd625d4912.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@uifabricshared/themed-settings", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@uifabricshared-theming-ramp-2ac6b5e8-9d82-4a74-822c-81c13db40000.json b/change/@uifabricshared-theming-ramp-2ac6b5e8-9d82-4a74-822c-81c13db40000.json new file mode 100644 index 0000000000..6e1349ccfa --- /dev/null +++ b/change/@uifabricshared-theming-ramp-2ac6b5e8-9d82-4a74-822c-81c13db40000.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@uifabricshared/theming-ramp", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@uifabricshared-theming-react-native-c3080f78-ff2f-48a4-a2df-477e8d421329.json b/change/@uifabricshared-theming-react-native-c3080f78-ff2f-48a4-a2df-477e8d421329.json new file mode 100644 index 0000000000..ad59efe9c3 --- /dev/null +++ b/change/@uifabricshared-theming-react-native-c3080f78-ff2f-48a4-a2df-477e8d421329.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix repo linting with new configs and version, fixing linting errors as well", + "packageName": "@uifabricshared/theming-react-native", + "email": "jasonmo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/codemods/.eslintignore b/packages/codemods/.eslintignore deleted file mode 100644 index 2d619cafe3..0000000000 --- a/packages/codemods/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -src/transforms/__testfixtures__ diff --git a/packages/codemods/eslint.config.js b/packages/codemods/eslint.config.js index c98098e068..50bbe55be7 100644 --- a/packages/codemods/eslint.config.js +++ b/packages/codemods/eslint.config.js @@ -1,3 +1,8 @@ const baseConfig = require('@fluentui-react-native/eslint-config-rules'); -module.exports = baseConfig; +module.exports = [ + ...baseConfig, + { + ignores: ['src/transforms/__testfixtures__/**/*'], + }, +]; diff --git a/packages/components/Badge/src/CounterBadge/CounterBadge.types.ts b/packages/components/Badge/src/CounterBadge/CounterBadge.types.ts index 8e20bb9ca3..3cdb3d5222 100644 --- a/packages/components/Badge/src/CounterBadge/CounterBadge.types.ts +++ b/packages/components/Badge/src/CounterBadge/CounterBadge.types.ts @@ -63,7 +63,7 @@ export interface CounterBadgeTokens extends BadgeTokens { list?: CounterBadgeTokens; // Android only } -export interface CounterBadgeSlotProps extends BadgeSlotProps {} +export type CounterBadgeSlotProps = BadgeSlotProps; export interface CounterBadgeState { showBadge?: boolean; diff --git a/packages/components/Button/src/ToggleButton/ToggleButton.types.ts b/packages/components/Button/src/ToggleButton/ToggleButton.types.ts index 56c6a2dc8c..aed4ade14b 100644 --- a/packages/components/Button/src/ToggleButton/ToggleButton.types.ts +++ b/packages/components/Button/src/ToggleButton/ToggleButton.types.ts @@ -31,7 +31,7 @@ export interface ToggleButtonInfo extends ButtonInfo { }; } -export interface ToggleButtonSlotProps extends ButtonSlotProps {} +export type ToggleButtonSlotProps = ButtonSlotProps; export interface ToggleButtonType { props: ToggleButtonProps; diff --git a/packages/components/Chip/eslint.config.js b/packages/components/Chip/eslint.config.js new file mode 100644 index 0000000000..c98098e068 --- /dev/null +++ b/packages/components/Chip/eslint.config.js @@ -0,0 +1,3 @@ +const baseConfig = require('@fluentui-react-native/eslint-config-rules'); + +module.exports = baseConfig; diff --git a/packages/components/FocusZone/src/FocusZone.types.ts b/packages/components/FocusZone/src/FocusZone.types.ts index 70b3f5e480..55557ee46c 100644 --- a/packages/components/FocusZone/src/FocusZone.types.ts +++ b/packages/components/FocusZone/src/FocusZone.types.ts @@ -6,7 +6,9 @@ import type { IRenderData } from '@uifabricshared/foundation-composable'; export const focusZoneName = 'FocusZone'; -export interface FocusZoneState {} +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type EmptyInterface = {}; +export type FocusZoneState = EmptyInterface; export type FocusZoneProps = IViewProps & { /** @@ -105,7 +107,7 @@ export type FocusZoneTabNavigation = | 'NavigateStopAtEnds' /* Navigate the FZ with Tab. Stop navigation at ends */ | 'Normal'; /* Navigate the FZ with Tab. Don't trap focus, tabbing at ends moves you out */ -export interface FocusZoneTokens {} +export type FocusZoneTokens = EmptyInterface; export interface FocusZoneSlotProps { root: NativeProps; diff --git a/packages/components/Link/src/legacy/Link.types.ts b/packages/components/Link/src/legacy/Link.types.ts index 2e5de9c415..e63bfb0008 100644 --- a/packages/components/Link/src/legacy/Link.types.ts +++ b/packages/components/Link/src/legacy/Link.types.ts @@ -6,6 +6,9 @@ import type { ITextProps } from '@fluentui-react-native/text'; import type { IForegroundColorTokens, FontTokens, IBorderTokens } from '@fluentui-react-native/tokens'; import type { IRenderData } from '@uifabricshared/foundation-composable'; +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type ObjectBase = {}; + export const linkName = 'RNFLink'; /** @@ -43,8 +46,7 @@ export interface ILinkOptions { url?: string; } -// eslint-disable-next-line @typescript-eslint/ban-types -export type IWithLinkOptions = ILinkOptions & IWithPressableOptions; +export type IWithLinkOptions = ILinkOptions & IWithPressableOptions; export interface ILinkProps extends IWithLinkOptions { /** diff --git a/packages/components/Menu/src/Menu/Menu.tsx b/packages/components/Menu/src/Menu/Menu.tsx index c9f2b595cc..6d28107630 100644 --- a/packages/components/Menu/src/Menu/Menu.tsx +++ b/packages/components/Menu/src/Menu/Menu.tsx @@ -17,7 +17,6 @@ export const Menu = stagedComponent((props: MenuProps) => { if (__DEV__) { if (childrenArray.length !== 2) { - // eslint-disable-next-line no-console console.warn('Menu must contain two children'); } } diff --git a/packages/components/Menu/src/Menu/useMenu.android.ts b/packages/components/Menu/src/Menu/useMenu.android.ts index 9f4eb34fdd..7de1f02fc6 100644 --- a/packages/components/Menu/src/Menu/useMenu.android.ts +++ b/packages/components/Menu/src/Menu/useMenu.android.ts @@ -118,7 +118,7 @@ export const useMenu = (props: MenuProps): MenuState => { if (props.open) { show(); } - }, [props.open]); + }, [props.open, show]); /** * onMenuLayout handles the start of the Animation when anchor is clicked @@ -157,7 +157,8 @@ export const useMenu = (props: MenuProps): MenuState => { setOpen(e, false, false); }; - // Adjust position of menu + // Adjust position of menu - TODO: fix this warning removal, potentially adds extra re-renders + // eslint-disable-next-line react-hooks/exhaustive-deps const transforms = []; useMemo(() => { diff --git a/packages/components/Menu/src/MenuPopover/useMenuPopover.ts b/packages/components/Menu/src/MenuPopover/useMenuPopover.ts index c3a48c1ef4..445f0bd490 100644 --- a/packages/components/Menu/src/MenuPopover/useMenuPopover.ts +++ b/packages/components/Menu/src/MenuPopover/useMenuPopover.ts @@ -29,6 +29,7 @@ export const useMenuPopover = (props: MenuPopoverProps): MenuPopoverState => { const onDismiss = React.useCallback(() => { props.onDismiss?.(); setOpen(undefined, false /* isOpen */), [setOpen]; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [props.onDismiss, setOpen]); const dismissBehaviors = isControlled ? controlledDismissBehaviors : undefined; const directionalHint = props.directionalHint ?? getDirectionalHint(isSubmenu, I18nManager.isRTL); diff --git a/packages/components/Pressable/src/Pressable.props.ts b/packages/components/Pressable/src/Pressable.props.ts index e01a1b4e43..c822618fe3 100644 --- a/packages/components/Pressable/src/Pressable.props.ts +++ b/packages/components/Pressable/src/Pressable.props.ts @@ -4,8 +4,10 @@ import type { ViewStyle, StyleProp } from 'react-native'; import type { IViewProps } from '@fluentui-react-native/adapters'; import type { IWithPressableOptions, IPressableState } from '@fluentui-react-native/interactive-hooks'; -// eslint-disable-next-line @typescript-eslint/ban-types -export type IPressableProps = IWithPressableOptions & { +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type ObjectBase = {}; + +export type IPressableProps = IWithPressableOptions & { children?: IRenderChild; // Typescript will not allow an extension of the IView* interface @@ -41,8 +43,7 @@ export type IRenderChild = IChildAsFunction | React.ReactNode; */ export type IRenderStyle = (state: T) => StyleProp; -// eslint-disable-next-line @typescript-eslint/ban-types -export type IPressableType = { +export type IPressableType = { props: IPressableProps; slotProps: { root: TBase; diff --git a/packages/components/RadioGroup/src/RadioGroup/radioGroupContext.ts b/packages/components/RadioGroup/src/RadioGroup/radioGroupContext.ts index 15f553d8ab..7b9a53a567 100644 --- a/packages/components/RadioGroup/src/RadioGroup/radioGroupContext.ts +++ b/packages/components/RadioGroup/src/RadioGroup/radioGroupContext.ts @@ -5,7 +5,7 @@ import type { RadioGroupState } from './RadioGroup.types'; /** * Context shared between RadioGroup and its children Radio components */ -export interface RadioGroupContextValue extends RadioGroupState {} +export type RadioGroupContextValue = RadioGroupState; export const RadioGroupContext = React.createContext({ value: null, diff --git a/packages/components/Stack/src/Stack.tsx b/packages/components/Stack/src/Stack.tsx index f3b9c9c4a8..eb7459050c 100644 --- a/packages/components/Stack/src/Stack.tsx +++ b/packages/components/Stack/src/Stack.tsx @@ -28,8 +28,10 @@ declare global { } } -// eslint-disable-next-line @typescript-eslint/ban-types -function _mixinStyle(style: StyleProp | undefined, mixin: object): StyleProp { +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type ObjectBase = {}; + +function _mixinStyle(style: StyleProp | undefined, mixin: ObjectBase): StyleProp { return style ? [style, mixin] : mixin; } @@ -44,7 +46,7 @@ const render = (Slots: ISlots, renderData: IStackRenderData, .. // @ts-ignore - TODO, fix typing error children = React.Children.map(children, (child: React.ReactChild, index: number) => { if (React.isValidElement(child) && index > 0) { - const childProps = child.props as object; + const childProps = child.props as ObjectBase; const extraProps = { style: _mixinStyle(childProps[_styleKey], extraStyle) }; return React.cloneElement(child, { ...childProps, @@ -89,4 +91,5 @@ export const Stack = compose({ }, }); +// eslint-disable-next-line no-restricted-exports export default Stack; diff --git a/packages/components/TabList/src/Tab/useTab.ts b/packages/components/TabList/src/Tab/useTab.ts index 56dd05557b..971d06cec4 100644 --- a/packages/components/TabList/src/Tab/useTab.ts +++ b/packages/components/TabList/src/Tab/useTab.ts @@ -102,7 +102,7 @@ export const useTab = (props: TabProps): TabInfo => { accessibilityState: getAccessibilityState(isDisabled, selectedKey === tabKey, accessibilityState), accessibilitySetSize: accessibilitySetSize ?? tabKeys.length, disabled: isDisabled, - focusable: !isDisabled ?? true, + focusable: !isDisabled, icon: icon, onAccessibilityAction: onAccessibilityActionProp, ref: useViewCommandFocus(componentRef), diff --git a/packages/components/TabList/src/Tab/useTab.win32.ts b/packages/components/TabList/src/Tab/useTab.win32.ts index cd07bb1e1b..6004a91dc6 100644 --- a/packages/components/TabList/src/Tab/useTab.win32.ts +++ b/packages/components/TabList/src/Tab/useTab.win32.ts @@ -147,7 +147,7 @@ export const useTab = (props: TabProps): TabInfo => { accessibilityState: getAccessibilityState(isDisabled, selectedKey === tabKey, accessibilityState), accessibilitySetSize: accessibilitySetSize ?? tabKeys.length, disabled: isDisabled, - focusable: !isDisabled ?? true, + focusable: !isDisabled, icon: icon, onAccessibilityAction: onAccessibilityActionProp, ref: useViewCommandFocus(componentRef), diff --git a/packages/deprecated/foundation-composable/.eslintignore b/packages/deprecated/foundation-composable/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/deprecated/foundation-composable/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/deprecated/foundation-compose/.eslintignore b/packages/deprecated/foundation-compose/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/deprecated/foundation-compose/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/deprecated/foundation-settings/.eslintignore b/packages/deprecated/foundation-settings/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/deprecated/foundation-settings/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/deprecated/theme-registry/.eslintignore b/packages/deprecated/theme-registry/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/deprecated/theme-registry/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/deprecated/themed-settings/.eslintignore b/packages/deprecated/themed-settings/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/deprecated/themed-settings/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/deprecated/theming-ramp/.eslintignore b/packages/deprecated/theming-ramp/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/deprecated/theming-ramp/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/deprecated/theming-react-native/.eslintignore b/packages/deprecated/theming-react-native/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/deprecated/theming-react-native/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/deprecated/theming-react-native/src/NativeModule/index.ts b/packages/deprecated/theming-react-native/src/NativeModule/index.ts index 0cbde927db..13ceea17be 100644 --- a/packages/deprecated/theming-react-native/src/NativeModule/index.ts +++ b/packages/deprecated/theming-react-native/src/NativeModule/index.ts @@ -1,3 +1,3 @@ -export * from './ThemingModule'; -export * from './ThemingModule.types'; -export * from './getHostSettings'; +export { ThemingModuleHelper } from './ThemingModule'; +export type { IEventEmitter, IPlatformThemeDefinition, IThemingModuleHelper, IHostSettingsWin32 } from './ThemingModule.types'; +export { getHostSettingsWin32 } from './getHostSettings'; diff --git a/packages/experimental/AppearanceAdditions/src/NativeAppearanceAdditions.ios.ts b/packages/experimental/AppearanceAdditions/src/NativeAppearanceAdditions.ios.ts index 8b27ef8b9c..7280e9cd02 100644 --- a/packages/experimental/AppearanceAdditions/src/NativeAppearanceAdditions.ios.ts +++ b/packages/experimental/AppearanceAdditions/src/NativeAppearanceAdditions.ios.ts @@ -2,7 +2,7 @@ import { NativeModules } from 'react-native'; export const NativeAppearanceAdditions = NativeModules.FRNAppearanceAdditions; -// eslint-disable-next-line @typescript-eslint/no-empty-interface -interface NativeAppearanceAdditionsInterface {} +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type NativeAppearanceAdditionsInterface = {}; export default NativeAppearanceAdditions as NativeAppearanceAdditionsInterface; diff --git a/packages/experimental/Dropdown/src/Dropdown/Dropdown.types.ts b/packages/experimental/Dropdown/src/Dropdown/Dropdown.types.ts index ce0d3810e7..aee5c58a4e 100644 --- a/packages/experimental/Dropdown/src/Dropdown/Dropdown.types.ts +++ b/packages/experimental/Dropdown/src/Dropdown/Dropdown.types.ts @@ -2,9 +2,10 @@ import type { PressablePropsExtended, PressableState } from '@fluentui-react-nat export const dropdownName = 'Dropdown'; -export interface DropdownTokens {} +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export type DropdownTokens = {}; -export interface DropdownProps extends PressablePropsExtended {} +export type DropdownProps = PressablePropsExtended; export type DropdownState = PressableState; diff --git a/packages/experimental/Dropdown/src/Listbox/Listbox.types.ts b/packages/experimental/Dropdown/src/Listbox/Listbox.types.ts index 5ba8ee2b15..8ccd59fd18 100644 --- a/packages/experimental/Dropdown/src/Listbox/Listbox.types.ts +++ b/packages/experimental/Dropdown/src/Listbox/Listbox.types.ts @@ -3,8 +3,9 @@ import type { IPressableHooks } from '@fluentui-react-native/interactive-hooks'; export const listboxName = 'Listbox'; -export interface ListboxTokens {} +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export type ListboxTokens = {}; export type ListboxProps = ICalloutProps; -export interface ListboxState extends IPressableHooks> {} +export type ListboxState = IPressableHooks>; diff --git a/packages/experimental/Popover/src/Popover.types.ts b/packages/experimental/Popover/src/Popover.types.ts index 28a50f5c8e..d1a0c24f37 100644 --- a/packages/experimental/Popover/src/Popover.types.ts +++ b/packages/experimental/Popover/src/Popover.types.ts @@ -1,18 +1,20 @@ import type { IViewProps } from '@fluentui-react-native/adapters'; export const popoverName = 'Popover'; +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type EmptyInterface = {}; -export interface PopoverTokens {} +export type PopoverTokens = EmptyInterface; -export interface PopoverProps extends Omit {} +export type PopoverProps = Omit; -export interface PopoverState {} +export type PopoverState = EmptyInterface; -export interface PopoverSlotProps {} +export type PopoverSlotProps = EmptyInterface; -export interface PopoverType { +export type PopoverType = { props: PopoverProps; tokens: PopoverTokens; slotProps: PopoverSlotProps; state: PopoverState; -} +}; diff --git a/packages/framework/eslint-config-rules/eslint.config.js b/packages/framework/eslint-config-rules/eslint.config.js index bfbf73b45d..e3ada9e0e0 100644 --- a/packages/framework/eslint-config-rules/eslint.config.js +++ b/packages/framework/eslint-config-rules/eslint.config.js @@ -1,26 +1,36 @@ const rnx = require('@rnx-kit/eslint-plugin'); const sdl = require('@microsoft/eslint-plugin-sdl'); +const tsLint = require('typescript-eslint'); module.exports = [ + ...sdl.configs.common, + ...tsLint.configs.strict, + ...rnx.configs.strict, // Base configuration for all files { - ...sdl.configs.common, - ...rnx.configs.recommended, languageOptions: { parserOptions: { project: ['./tsconfig.json', 'apps/*/tsconfig.json', 'packages/*/*/tsconfig.json'], }, }, - plugins: { - '@rnx-kit': rnx, - }, rules: { + indent: 'off', + 'no-unused-vars': 'off', + quotes: [ + 'error', + 'single', + { + avoidEscape: true, + allowTemplateLiterals: true, + }, + ], '@rnx-kit/no-const-enum': 'error', '@rnx-kit/no-export-all': ['error', { expand: 'external-only' }], '@typescript-eslint/consistent-type-assertions': 'off', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/interface-name-prefix': 'off', '@typescript-eslint/no-array-constructor': 'off', + '@typescript-eslint/no-dynamic-delete': 'off', '@typescript-eslint/no-empty-interface': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-inferrable-types': 'off', @@ -29,6 +39,19 @@ module.exports = [ 'no-prototype-builtins': 'off', 'no-undef': 'off', 'react/display-name': 'off', + 'react-hooks/exhaustive-deps': 'off', // This should be fixed in the future but is a big change + 'no-restricted-exports': [ + 'error', + { + restrictDefaultExports: { + direct: false, + named: true, + defaultFrom: true, + namedFrom: true, + namespaceFrom: true, + }, + }, + ], }, }, // Override configuration for index files @@ -38,4 +61,30 @@ module.exports = [ '@rnx-kit/no-export-all': ['error', { expand: 'all' }], }, }, + { + files: ['**/*.test.{js,ts,tsx}', '**/*.spec.{js,ts,tsx}'], + languageOptions: { + globals: { + // These are provided by the jest environment + // https://jestjs.io/docs/using-matchers + expect: 'readonly', + test: 'readonly', + describe: 'readonly', + beforeAll: 'readonly', + afterAll: 'readonly', + beforeEach: 'readonly', + afterEach: 'readonly', + jest: 'readonly', + }, + }, + rules: { + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + }, + }, + // Common ignore patterns + { + ignores: ['node_modules/**', '*.config.js', 'dist/**/*', 'coverage/**/*', 'lib/**/*', 'out/**/*'], + }, ]; diff --git a/packages/framework/eslint-config-rules/package.json b/packages/framework/eslint-config-rules/package.json index 77cbc90ee2..5df03e6697 100644 --- a/packages/framework/eslint-config-rules/package.json +++ b/packages/framework/eslint-config-rules/package.json @@ -15,7 +15,8 @@ "license": "MIT", "dependencies": { "@microsoft/eslint-plugin-sdl": "^1.1.0", - "@rnx-kit/eslint-plugin": "^0.8.6" + "@rnx-kit/eslint-plugin": "^0.8.6", + "typescript-eslint": "^8.36.0" }, "devDependencies": { "@types/eslint": "^9.0.0", diff --git a/packages/framework/eslint-config-rules/tsconfig.json b/packages/framework/eslint-config-rules/tsconfig.json new file mode 100644 index 0000000000..219673e623 --- /dev/null +++ b/packages/framework/eslint-config-rules/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "@fluentui-react-native/scripts/tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true + }, + "include": ["eslint.config.js"] +} diff --git a/packages/framework/framework/src/compose.ts b/packages/framework/framework/src/compose.ts index c67a360207..d578754e73 100644 --- a/packages/framework/framework/src/compose.ts +++ b/packages/framework/framework/src/compose.ts @@ -1,6 +1,7 @@ import type { ComposeFactoryOptions, ComposeFactoryComponent, UseStyledSlots } from '@fluentui-react-native/composition'; import { composeFactory } from '@fluentui-react-native/composition'; import type { Theme } from '@fluentui-react-native/theme-types'; +import type { ObjectBase } from '@fluentui-react-native/immutable-merge'; import { themeHelper } from './themeHelper'; @@ -8,8 +9,7 @@ import { themeHelper } from './themeHelper'; * This is an object used purely for configuring the typings on composable. It is not necessary to define * the type via the IComposableType interface, this is simply the format used to extract the type info. */ -// eslint-disable-next-line @typescript-eslint/ban-types -export interface ComposeType { +export interface ComposeType { props: TProps; slotProps: TSlotProps; tokens: TTokens; @@ -21,21 +21,17 @@ type PropsFragment = { props: TProps }; type SlotPropsFragment = { slotProps: TSlotProps }; type TokensFragment = { tokens: TTokens }; -// eslint-disable-next-line @typescript-eslint/ban-types -type StaticsFragment = { statics: TStatics }; +type StaticsFragment = { statics: TStatics }; /** Extraction types that get the various interface types from IComposableType */ export type ExtractProps = T extends PropsFragment ? U : never; export type ExtractSlotProps = T extends SlotPropsFragment ? U : never; -// eslint-disable-next-line @typescript-eslint/ban-types -export type ExtractTokens = T extends TokensFragment ? U : object; +export type ExtractTokens = T extends TokensFragment ? U : ObjectBase; -// eslint-disable-next-line @typescript-eslint/ban-types -export type ExtractStatics = T extends StaticsFragment ? U : object; +export type ExtractStatics = T extends StaticsFragment ? U : ObjectBase; -// eslint-disable-next-line @typescript-eslint/ban-types -export type ComposeOptions = ComposeFactoryOptions< +export type ComposeOptions = ComposeFactoryOptions< TProps, TSlotProps, TTokens, @@ -43,8 +39,7 @@ export type ComposeOptions TStatics >; -// eslint-disable-next-line @typescript-eslint/ban-types -export type ComposableComponent = ComposeFactoryComponent< +export type ComposableComponent = ComposeFactoryComponent< TProps, TSlotProps, TTokens, diff --git a/packages/framework/immutable-merge/.eslintignore b/packages/framework/immutable-merge/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/framework/immutable-merge/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/framework/immutable-merge/src/Merge.ts b/packages/framework/immutable-merge/src/Merge.ts index c6324d4f7c..a889e0c27e 100644 --- a/packages/framework/immutable-merge/src/Merge.ts +++ b/packages/framework/immutable-merge/src/Merge.ts @@ -28,6 +28,19 @@ export type BuiltinRecursionHandlers = 'appendArray'; */ export type RecursionHandler = BuiltinRecursionHandlers | CustomRecursionHandler; +/** + * Base object type for merges, avoids using object since that is too broad. In particular things like null and arrays + * are not valid object types for the purposes of this library. + */ +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export type ObjectBase = {}; + +/** + * + */ +export type TypeofResult = 'undefined' | 'object' | 'boolean' | 'number' | 'string' | 'symbol' | 'bigint' | 'function'; +export type ExpandedTypeof = TypeofResult | 'array' | 'null'; + /** * configuration object for the merge, key names are matched with a few exceptions: * - object: matches non-array object types @@ -60,11 +73,22 @@ function normalizeOptions(options: RecursionOption | MergeOptions): [MergeOption } /** - * Return the type except return 'array' for objects that are arrays + * Provide a more sensible type result that expands upon the built in typeof operator + * In particular this will differentiate arrays and nulls from standard objects * @param val - value to check type */ -function getEntityType(val: any): 'array' | string { - return typeof val === 'object' ? (Array.isArray(val) ? 'array' : 'object') : typeof val; +function getEntityType(val: unknown): ExpandedTypeof { + switch (typeof val) { + case 'object': + if (val === null) { + return 'null'; + } else if (Array.isArray(val)) { + return 'array'; + } + return 'object'; + default: + return typeof val as TypeofResult; + } } /** resolve custom handlers if they are applicable */ @@ -117,6 +141,24 @@ function getHandlerForPropertyOfType( return result; } +/** + * Assign properties of source objects to a new target object. This is just a type wrapper around Object.assign + * @param objs - array of objects to merge + * @returns the result of object assign on the objects, typed to T + */ +function assignToNewObject(...objs: T[]): T { + return Object.assign({}, ...objs); +} + +/** + * Filter a set of unknown values to only include those that extend ObjectBase + * @param values - array of values to filter + * @returns the filtered set of values + */ +export function filterToObjects(values: unknown[]): T[] { + return values.filter((v) => v && getEntityType(v) === 'object' && Object.getOwnPropertyNames(v).length > 0) as T[]; +} + /** * This will merge two or more objects together using an immutable style merge pattern. If there is only one object or * if there is only one object with values, that object itself will be returned, with two or more objects the keys within will @@ -130,16 +172,15 @@ function getHandlerForPropertyOfType( * is true the routine will progress through all branches of the hierarchy. Useful if using a processor function that needs to be run. * @param objs - an array of objects to merge together */ -// eslint-disable-next-line @typescript-eslint/ban-types -function immutableMergeWorker(mergeOptions: RecursionOption | MergeOptions, singleMode: boolean, ...objs: T[]): T { - const setToMerge = objs.filter((v) => v && getEntityType(v) === 'object' && Object.getOwnPropertyNames(v).length > 0); +function immutableMergeWorker(mergeOptions: RecursionOption | MergeOptions, singleMode: boolean, ...objs: T[]): T { + const setToMerge = filterToObjects(objs); const [options, mightRecurse] = normalizeOptions(mergeOptions); const processSingle = singleMode && setToMerge.length === 1; // there is work to do if there is more than one object to merge or if we are processing single objects if (setToMerge.length > 1 || (processSingle && setToMerge.length === 1)) { // now assign everything to get the normal property precedence (and merge all the keys) - let result = processSingle ? undefined : Object.assign({}, ...setToMerge); + let result = processSingle ? undefined : assignToNewObject(...setToMerge); const processSet = result || setToMerge[0]; for (const key in processSet) { @@ -151,9 +192,12 @@ function immutableMergeWorker(mergeOptions: RecursionOption | const handler = getHandlerForPropertyOfType(options, key, entityType); if (handler !== undefined) { const values = setToMerge.map((set) => set[key]).filter((v) => v !== undefined); - const updatedVal = typeof handler === 'function' ? handler(...values) : immutableMergeWorker(handler, singleMode, ...values); + const updatedVal = + typeof handler === 'function' + ? handler(...values) + : immutableMergeWorker(handler, singleMode, ...filterToObjects(values)); if (updatedVal !== originalVal) { - result = result || Object.assign({}, ...setToMerge); + result = result || assignToNewObject(...setToMerge); result[key] = updatedVal; } } @@ -178,8 +222,7 @@ function immutableMergeWorker(mergeOptions: RecursionOption | * * @param objs - variable input array of typed objects to merge */ -// eslint-disable-next-line @typescript-eslint/ban-types -export function immutableMerge(...objs: (T | undefined)[]): T | undefined { +export function immutableMerge(...objs: (T | undefined)[]): T | undefined { return immutableMergeWorker(true, false, ...objs); } @@ -189,8 +232,10 @@ export function immutableMerge(...objs: (T | undefined)[]): T * @param options - configuration options for the merge, this dictates what keys will be handled in what way * @param objs - set of objects to merge together */ -// eslint-disable-next-line @typescript-eslint/ban-types -export function immutableMergeCore(options: RecursionOption | MergeOptions, ...objs: (T | undefined)[]): T | undefined { +export function immutableMergeCore( + options: RecursionOption | MergeOptions, + ...objs: (T | undefined)[] +): T | undefined { return immutableMergeWorker(options, false, ...objs); } @@ -205,7 +250,6 @@ export function immutableMergeCore(options: RecursionOption | * @param processors - set of processor functions for handling keys * @param objs - one or more objects to process. If multiple objects are passed they will be merged */ -// eslint-disable-next-line @typescript-eslint/ban-types -export function processImmutable(options: MergeOptions, ...objs: (T | undefined)[]): T | undefined { +export function processImmutable(options: MergeOptions, ...objs: (T | undefined)[]): T | undefined { return immutableMergeWorker(options, true, ...objs); } diff --git a/packages/framework/immutable-merge/src/index.ts b/packages/framework/immutable-merge/src/index.ts index 5432682f2f..931406c8fc 100644 --- a/packages/framework/immutable-merge/src/index.ts +++ b/packages/framework/immutable-merge/src/index.ts @@ -1,2 +1,9 @@ -export { immutableMerge, immutableMergeCore, processImmutable } from './Merge'; -export type { BuiltinRecursionHandlers, CustomRecursionHandler, MergeOptions, RecursionHandler, RecursionOption } from './Merge'; +export { immutableMerge, immutableMergeCore, processImmutable, filterToObjects } from './Merge'; +export type { + BuiltinRecursionHandlers, + CustomRecursionHandler, + MergeOptions, + ObjectBase, + RecursionHandler, + RecursionOption, +} from './Merge'; diff --git a/packages/framework/memo-cache/.eslintignore b/packages/framework/memo-cache/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/framework/memo-cache/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/framework/memo-cache/src/getCacheEntry.ts b/packages/framework/memo-cache/src/getCacheEntry.ts index caff5b2341..a90f94eac5 100644 --- a/packages/framework/memo-cache/src/getCacheEntry.ts +++ b/packages/framework/memo-cache/src/getCacheEntry.ts @@ -12,7 +12,6 @@ export type CacheEntry = { str?: { [key: string]: CacheEntry }; /** object types are keyed in a weak map on object identity */ - // eslint-disable-next-line @typescript-eslint/ban-types obj?: WeakMap; }; @@ -43,7 +42,6 @@ function jumpToCacheEntry(entry: CacheEntry, val: any): CacheEntry { } if (typeof val === 'object' || typeof val === 'function') { // objects and functions will be treated as key values in a WeakMap - // eslint-disable-next-line @typescript-eslint/ban-types const byObj = (entry.obj = entry.obj || new WeakMap>()); return byObj.get(val) || byObj.set(val, {}).get(val); } diff --git a/packages/framework/memo-cache/src/getMemoCache.ts b/packages/framework/memo-cache/src/getMemoCache.ts index 53658f0431..1546160657 100644 --- a/packages/framework/memo-cache/src/getMemoCache.ts +++ b/packages/framework/memo-cache/src/getMemoCache.ts @@ -31,7 +31,6 @@ function getMemoValueWorker(entry: CacheEntry, factory: T | * @param globalKey - optional object reference to use as a key for this cache. If specified it can be used * to retrieve the same cache from the global call. If not specified the returned cache will be completely isolated. */ -// eslint-disable-next-line @typescript-eslint/ban-types export function getMemoCache(globalKey?: object): GetMemoValue { const entry = globalKey ? getCacheEntry(_baseEntry, [globalKey]) : {}; return (fact: T | ValueFactory, args: any[]) => getMemoValueWorker(entry, fact, args); diff --git a/packages/framework/memo-cache/src/memoize.ts b/packages/framework/memo-cache/src/memoize.ts index 0ddb10915f..9db3fc3e13 100644 --- a/packages/framework/memo-cache/src/memoize.ts +++ b/packages/framework/memo-cache/src/memoize.ts @@ -4,7 +4,7 @@ import { getMemoCache } from './getMemoCache'; * This wraps a function to memoize the results using the standard javascript memoization pattern * @param fn - function to memoize */ -// eslint-disable-next-line @typescript-eslint/ban-types +// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type export function memoize(fn: T): T { // create a unique cache that will be captured in the closure const cache = getMemoCache(); diff --git a/packages/framework/merge-props/.eslintignore b/packages/framework/merge-props/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/framework/merge-props/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/framework/merge-props/src/mergeProps.ts b/packages/framework/merge-props/src/mergeProps.ts index 46433d1e8b..3596faf2a0 100644 --- a/packages/framework/merge-props/src/mergeProps.ts +++ b/packages/framework/merge-props/src/mergeProps.ts @@ -1,5 +1,5 @@ import type { MergeOptions } from '@fluentui-react-native/immutable-merge'; -import { immutableMergeCore } from '@fluentui-react-native/immutable-merge'; +import { immutableMergeCore, filterToObjects } from '@fluentui-react-native/immutable-merge'; import { mergeStyles } from './mergeStyles'; @@ -11,16 +11,10 @@ const mergePropsOptions: MergeOptions = { style: mergeStyles, }; -/** take an any array and turn it into an array of objects */ -// eslint-disable-next-line @typescript-eslint/ban-types -function filterAsObject(targets: any[]): object[] { - return targets.filter((t) => typeof t === 'object'); -} - /** * Merge props together, flattening and merging styles as appropriate * @param props - props to merge together */ export function mergeProps(...props: (TProps | undefined)[]): TProps { - return immutableMergeCore(mergePropsOptions, ...filterAsObject(props)) as unknown as TProps; + return immutableMergeCore(mergePropsOptions, ...filterToObjects(props)); } diff --git a/packages/framework/merge-props/src/mergeStyles.ts b/packages/framework/merge-props/src/mergeStyles.ts index f1c7578b53..968f864305 100644 --- a/packages/framework/merge-props/src/mergeStyles.ts +++ b/packages/framework/merge-props/src/mergeStyles.ts @@ -9,7 +9,6 @@ import type { StyleProp } from './mergeStyles.types'; * * @param style - StyleProp to flatten, this can be a TStyle or an array */ -// eslint-disable-next-line @typescript-eslint/ban-types export function flattenStyle(style: StyleProp): object { return Array.isArray(style) ? immutableMerge(...style.map((v) => flattenStyle(v))) : style || {}; } @@ -19,11 +18,9 @@ export function flattenStyle(style: StyleProp): object { * * @param styles - array of styles to merge together. The styles will be flattened as part of the process */ -// eslint-disable-next-line @typescript-eslint/ban-types export function mergeAndFlattenStyles(...styles: StyleProp[]): object | undefined { // baseline merge and flatten the objects return immutableMerge( - // eslint-disable-next-line @typescript-eslint/ban-types ...styles.map((styleProp: StyleProp) => { return flattenStyle(styleProp); }), @@ -32,10 +29,8 @@ export function mergeAndFlattenStyles(...styles: StyleProp[]): object | const _styleCache = getMemoCache(); -// eslint-disable-next-line @typescript-eslint/ban-types export function mergeStyles(...styles: StyleProp[]): object | undefined { // filter the style set to just objects (which might be arrays or plain style objects) - // eslint-disable-next-line @typescript-eslint/ban-types const inputs = styles.filter((s) => typeof s === 'object') as object[]; // now memo the results if there is more than one element or if the one element is an array diff --git a/packages/framework/merge-props/src/mergeStyles.types.ts b/packages/framework/merge-props/src/mergeStyles.types.ts index 39d41efe71..8ade77717e 100644 --- a/packages/framework/merge-props/src/mergeStyles.types.ts +++ b/packages/framework/merge-props/src/mergeStyles.types.ts @@ -2,7 +2,7 @@ * This is a copy of the react-native style prop type, copied here to avoid RN dependencies for web clients */ type Falsy = undefined | null | false; -interface RecursiveArray extends Array> {} +type RecursiveArray = (T | RecursiveArray)[]; /** Keep a brand of 'T' so that calls to `StyleSheet.flatten` can take `RegisteredStyle` and return `T`. */ type RegisteredStyle = number & { __registeredStyleBrand: T }; diff --git a/packages/framework/themed-stylesheet/.eslintignore b/packages/framework/themed-stylesheet/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/framework/themed-stylesheet/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/framework/themed-stylesheet/src/themedStyleSheet.ts b/packages/framework/themed-stylesheet/src/themedStyleSheet.ts index 6782a73079..58db89fdaa 100644 --- a/packages/framework/themed-stylesheet/src/themedStyleSheet.ts +++ b/packages/framework/themed-stylesheet/src/themedStyleSheet.ts @@ -3,6 +3,9 @@ import { StyleSheet } from 'react-native'; import { getMemoCache } from '@fluentui-react-native/memo-cache'; +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type ObjectBase = {}; + /** * Signature for inputs and outputs for StyleSheet.create. This is a collection of named styles which can * be used as inputs for the style property on components and matches what StyleSheet.create accepts @@ -38,8 +41,8 @@ export type NamedStyles = { [P in keyof T]: ViewStyle | TextStyle | ImageStyl * @param generator - a function which will get run once per theme to create a cached style sheet. * */ -// eslint-disable-next-line @typescript-eslint/ban-types -export function themedStyleSheet, TTheme extends object>( + +export function themedStyleSheet, TTheme extends ObjectBase>( generator: (theme: TTheme) => NamedStyles, ): (theme: TTheme) => NamedStyles { // create a memo cache for this themed stylesheet diff --git a/packages/framework/use-slot/src/useSlot.ts b/packages/framework/use-slot/src/useSlot.ts index 83432b287d..8e4fc42b50 100644 --- a/packages/framework/use-slot/src/useSlot.ts +++ b/packages/framework/use-slot/src/useSlot.ts @@ -54,8 +54,9 @@ export function useSlot( } // now if result was a function then call it directly, if not go through the standard React.createElement process - // eslint-disable-next-line @typescript-eslint/ban-types - return typeof result === 'function' ? (result as Function)(props, ...children) : React.createElement(component, props, ...children); + return typeof result === 'function' + ? (result as React.FunctionComponent)(props, ...children) + : React.createElement(component, props, ...children); }; // mark the slotFn so that withSlots knows to handle it differently slotFn._canCompose = true; diff --git a/packages/framework/use-slots/src/buildUseSlots.ts b/packages/framework/use-slots/src/buildUseSlots.ts index 66a825337b..ae716fa4fc 100644 --- a/packages/framework/use-slots/src/buildUseSlots.ts +++ b/packages/framework/use-slots/src/buildUseSlots.ts @@ -3,6 +3,11 @@ import { useSlot } from '@fluentui-react-native/use-slot'; // type AsObject = T extends object ? T : never +/** + * Signature for the use styling hook + */ +type UseStyling = (...props: unknown[]) => TSlotProps; + export type Slots = { [K in keyof TSlotProps]: SlotFn }; export type UseSlotOptions = { @@ -19,8 +24,8 @@ export function buildUseSlots(options: UseSlotOptions): const { slots, filters = {}, useStyling } = options; return (...args: any[]) => { // get the baseline slot props to render with the slots - // eslint-disable-next-line @typescript-eslint/ban-types - const slotProps: TSlotProps = typeof useStyling === 'function' ? (useStyling as Function)(...args) : ((useStyling || {}) as TSlotProps); + const slotProps: TSlotProps = + typeof useStyling === 'function' ? (useStyling as UseStyling)(...args) : ((useStyling || {}) as TSlotProps); // build up a set of slots closures and store them in props const builtSlots: Slots = {} as Slots; diff --git a/packages/theming/android-theme/.eslintignore b/packages/theming/android-theme/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/theming/android-theme/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/theming/apple-theme/.eslintignore b/packages/theming/apple-theme/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/theming/apple-theme/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/theming/default-theme/.eslintignore b/packages/theming/default-theme/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/theming/default-theme/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/theming/theme-tokens/.eslintignore b/packages/theming/theme-tokens/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/theming/theme-tokens/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/theming/theme-tokens/src/highContrast/tokens-alias.ts b/packages/theming/theme-tokens/src/highContrast/tokens-alias.ts index 3dbdd8b7ea..adca9a813c 100644 --- a/packages/theming/theme-tokens/src/highContrast/tokens-alias.ts +++ b/packages/theming/theme-tokens/src/highContrast/tokens-alias.ts @@ -10,6 +10,7 @@ function processAliasTokens(aliasTokens: any) { const entry = aliasTokens[key][innerKey]; if (typeof entry === 'string' && entry.includes('PlatformColor')) { const color = 'SystemColor' + entry.substring(14, entry.length - 1) + 'Color'; + // eslint-disable-next-line @react-native/platform-colors aliasTokens[key][innerKey] = PlatformColor(color); } } diff --git a/packages/theming/theme-tokens/src/highContrast/tokens-alias.win32.ts b/packages/theming/theme-tokens/src/highContrast/tokens-alias.win32.ts index c594541981..2004e703e6 100644 --- a/packages/theming/theme-tokens/src/highContrast/tokens-alias.win32.ts +++ b/packages/theming/theme-tokens/src/highContrast/tokens-alias.win32.ts @@ -10,6 +10,7 @@ function processAliasTokens(aliasTokens: any) { const entry = aliasTokens[key][innerKey]; if (typeof entry === 'string' && entry.includes('PlatformColor')) { const color = entry.substring(14, entry.length - 1); + // eslint-disable-next-line @react-native/platform-colors aliasTokens[key][innerKey] = PlatformColor(color); } } diff --git a/packages/theming/theme-types/.eslintignore b/packages/theming/theme-types/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/theming/theme-types/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/theming/theme-types/src/Theme.types.ts b/packages/theming/theme-types/src/Theme.types.ts index 409181f2fa..819844a7f5 100644 --- a/packages/theming/theme-types/src/Theme.types.ts +++ b/packages/theming/theme-types/src/Theme.types.ts @@ -24,7 +24,7 @@ export interface Theme { colors: ThemeColorDefinition; typography: Typography; components: { - [key: string]: object; // eslint-disable-line @typescript-eslint/ban-types + [key: string]: Record; }; shadows: ThemeShadowDefinition; readonly spacing: Spacing; diff --git a/packages/theming/win32-theme/.eslintignore b/packages/theming/win32-theme/.eslintignore deleted file mode 100644 index a9b974ddbb..0000000000 --- a/packages/theming/win32-theme/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -# As this package grows it's likely we'll want to voluntarily ignore some packages \ No newline at end of file diff --git a/packages/theming/win32-theme/src/NativeModule/index.ts b/packages/theming/win32-theme/src/NativeModule/index.ts index 6f8de92f4d..259031f4ac 100644 --- a/packages/theming/win32-theme/src/NativeModule/index.ts +++ b/packages/theming/win32-theme/src/NativeModule/index.ts @@ -1,3 +1,11 @@ -export * from './fallbackOfficeModule'; -export * from './getThemingModule'; -export * from './officeThemingModule'; +export { fallbackOfficeModule, fallbackGetPalette } from './fallbackOfficeModule'; +export { getThemingModule } from './getThemingModule'; +export type { + PlatformDefaultsChangedArgs, + PlatformDefaultsChangedCallback, + CxxException, + NativeColorRamps, + NativeColorNames, + OfficeThemingModule, + IEventEmitter, +} from './officeThemingModule'; diff --git a/packages/theming/win32-theme/src/NativeModule/officeThemingModule.ts b/packages/theming/win32-theme/src/NativeModule/officeThemingModule.ts index 3320fdad68..6c46321da1 100644 --- a/packages/theming/win32-theme/src/NativeModule/officeThemingModule.ts +++ b/packages/theming/win32-theme/src/NativeModule/officeThemingModule.ts @@ -2,6 +2,9 @@ import type { NativeModule, ColorValue } from 'react-native'; import type { OfficePalette, Typography } from '@fluentui-react-native/theme-types'; +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type ObjectBase = {}; + export type PlatformDefaultsChangedArgs = { hostThemeSetting: string }; export type PlatformDefaultsChangedCallback = (args?: PlatformDefaultsChangedArgs) => void; @@ -27,7 +30,7 @@ export interface NativeColorNames { export interface OfficeThemingModule extends NativeModule { getPalette(palette?: string): OfficePalette | CxxException; getConstants(): { - typography: object; // eslint-disable-line @typescript-eslint/ban-types + typography: ObjectBase; // TODO: figure out why this is not a real type fluentTypography: Typography; ramps: NativeColorRamps; rampNames: NativeColorNames; diff --git a/packages/theming/win32-theme/src/highContrast/tokens-alias.ts b/packages/theming/win32-theme/src/highContrast/tokens-alias.ts index c594541981..2004e703e6 100644 --- a/packages/theming/win32-theme/src/highContrast/tokens-alias.ts +++ b/packages/theming/win32-theme/src/highContrast/tokens-alias.ts @@ -10,6 +10,7 @@ function processAliasTokens(aliasTokens: any) { const entry = aliasTokens[key][innerKey]; if (typeof entry === 'string' && entry.includes('PlatformColor')) { const color = entry.substring(14, entry.length - 1); + // eslint-disable-next-line @react-native/platform-colors aliasTokens[key][innerKey] = PlatformColor(color); } } diff --git a/packages/utils/adapters/src/adapter.types.macos.ts b/packages/utils/adapters/src/adapter.types.macos.ts index a0cc6c5a3e..d2d3f9d369 100644 --- a/packages/utils/adapters/src/adapter.types.macos.ts +++ b/packages/utils/adapters/src/adapter.types.macos.ts @@ -84,7 +84,7 @@ export interface NativeMouseEvent extends NativeUIEvent { */ readonly offsetY: number; } -export interface MouseEvent extends NativeSyntheticEvent {} +export type MouseEvent = NativeSyntheticEvent; // [macOS export interface NativeKeyEvent { @@ -105,7 +105,7 @@ export interface NativeKeyEvent { key: string; } -export interface KeyEvent extends NativeSyntheticEvent {} +export type KeyEvent = NativeSyntheticEvent; export type DraggedType = 'fileUrl'; export type DraggedTypesType = DraggedType | DraggedType[]; diff --git a/packages/utils/adapters/src/adapter.types.win32.ts b/packages/utils/adapters/src/adapter.types.win32.ts index d976cc08ec..9b0cc7ba61 100644 --- a/packages/utils/adapters/src/adapter.types.win32.ts +++ b/packages/utils/adapters/src/adapter.types.win32.ts @@ -100,7 +100,10 @@ export interface NativeMouseEvent extends NativeUIEvent { readonly offsetY: number; } -export interface MouseEvent extends NativeSyntheticEvent {} +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type ObjectBase = {}; + +export type MouseEvent = NativeSyntheticEvent; export type Cursor = | 'auto' @@ -167,14 +170,10 @@ export type IAdapterWin32ViewProps = ViewProps & { tooltip?: string; tabIndex?: number; enableFocusRing?: boolean; - // eslint-disable-next-line @typescript-eslint/ban-types - onBlur?: (ev: NativeSyntheticEvent<{}>) => void; - // eslint-disable-next-line @typescript-eslint/ban-types - onBlurCapture?: (ev: NativeSyntheticEvent<{}>) => void; - // eslint-disable-next-line @typescript-eslint/ban-types - onFocus?: (ev: NativeSyntheticEvent<{}>) => void; - // eslint-disable-next-line @typescript-eslint/ban-types - onFocusCapture?: (ev: NativeSyntheticEvent<{}>) => void; + onBlur?: (ev: NativeSyntheticEvent) => void; + onBlurCapture?: (ev: NativeSyntheticEvent) => void; + onFocus?: (ev: NativeSyntheticEvent) => void; + onFocusCapture?: (ev: NativeSyntheticEvent) => void; cursor?: Cursor; animationClass?: string; focusable?: boolean; @@ -285,14 +284,10 @@ export type IAdapterWin32TextProps = TextProps & { 'aria-controls'?: string | undefined; 'aria-describedby'?: string | undefined; - // eslint-disable-next-line @typescript-eslint/ban-types - onBlur?: (ev: NativeSyntheticEvent<{}>) => void; - // eslint-disable-next-line @typescript-eslint/ban-types - onBlurCapture?: (ev: NativeSyntheticEvent<{}>) => void; - // eslint-disable-next-line @typescript-eslint/ban-types - onFocus?: (ev: NativeSyntheticEvent<{}>) => void; - // eslint-disable-next-line @typescript-eslint/ban-types - onFocusCapture?: (ev: NativeSyntheticEvent<{}>) => void; + onBlur?: (ev: NativeSyntheticEvent) => void; + onBlurCapture?: (ev: NativeSyntheticEvent) => void; + onFocus?: (ev: NativeSyntheticEvent) => void; + onFocusCapture?: (ev: NativeSyntheticEvent) => void; focusable?: boolean; textStyle?: TextWin32TextStyle; diff --git a/packages/utils/adapters/src/adapter.types.windows.ts b/packages/utils/adapters/src/adapter.types.windows.ts index 5e5c0319f1..378a9918ad 100644 --- a/packages/utils/adapters/src/adapter.types.windows.ts +++ b/packages/utils/adapters/src/adapter.types.windows.ts @@ -42,7 +42,7 @@ export interface NativeMouseEvent { altKey: boolean; } -export interface MouseEvent extends NativeSyntheticEvent {} +export type MouseEvent = NativeSyntheticEvent; export type Cursor = | 'auto' diff --git a/packages/utils/interactive-hooks/src/Pressability/InternalTypes.ts b/packages/utils/interactive-hooks/src/Pressability/InternalTypes.ts index 016b595a91..b934aff3a6 100644 --- a/packages/utils/interactive-hooks/src/Pressability/InternalTypes.ts +++ b/packages/utils/interactive-hooks/src/Pressability/InternalTypes.ts @@ -4,6 +4,9 @@ import type * as React from 'react'; +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type ObjectBase = {}; + export type Rect = Readonly<{ bottom?: number; left?: number; @@ -41,8 +44,7 @@ export interface ComponentMethods { /** * temporary port of changes that are in flight for the react and react-native types definition */ -// eslint-disable-next-line @typescript-eslint/ban-types -export type AbstractComponent = +export type AbstractComponent = // Either a function component that has a specific return type: | (React.FunctionComponent & ((props: React.PropsWithChildren, context?: any) => Instance)) // ...or a class component that has the required Component methods and the Instance methods @@ -61,8 +63,7 @@ export type NativeMethods = { onSuccess: MeasureLayoutOnSuccessCallback, onFail?: () => void, ): void; - // eslint-disable-next-line @typescript-eslint/ban-types - setNativeProps(nativeProps: object): void; + setNativeProps(nativeProps: ObjectBase): void; }; export type HostComponent = AbstractComponent>; diff --git a/packages/utils/interactive-hooks/src/useAsPressable.ts b/packages/utils/interactive-hooks/src/useAsPressable.ts index 60a6d6960b..a5a01620fb 100644 --- a/packages/utils/interactive-hooks/src/useAsPressable.ts +++ b/packages/utils/interactive-hooks/src/useAsPressable.ts @@ -11,6 +11,9 @@ import type { } from './useAsPressable.types'; import { usePressability } from './usePressability'; +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type ObjectBase = {}; + /** * hover specific state and callback helper */ @@ -100,8 +103,7 @@ function usePressHelper(props: PressablePressProps): [PressablePressProps, IPres * as each of these calls will create a new instance of the Pressability class. * @param props - input props for the component */ -// eslint-disable-next-line @typescript-eslint/ban-types -export function useFocusState(props: IWithPressableOptions): [IWithPressableEvents, IFocusState] { +export function useFocusState(props: IWithPressableOptions): [IWithPressableEvents, IFocusState] { const [focusProps, focusState] = useFocusHelper(props); return [{ ...props, ...usePressability({ ...props, ...focusProps }) }, focusState]; } @@ -111,8 +113,7 @@ export function useFocusState(props: IWithPressableOptions) * as each of these calls will create a new instance of the Pressability class. * @param props - input props for the component */ -// eslint-disable-next-line @typescript-eslint/ban-types -export function usePressState(props: IWithPressableOptions): [IWithPressableEvents, IPressState] { +export function usePressState(props: IWithPressableOptions): [IWithPressableEvents, IPressState] { const [pressProps, pressState] = usePressHelper(props); return [{ ...props, ...usePressability({ ...props, ...pressProps }) }, pressState]; } @@ -122,8 +123,7 @@ export function usePressState(props: IWithPressableOptions) * as each of these calls will create a new instance of the Pressability class. * @param props - input props for the component */ -// eslint-disable-next-line @typescript-eslint/ban-types -export function useHoverState(props: IWithPressableOptions): [IWithPressableEvents, IHoverState] { +export function useHoverState(props: IWithPressableOptions): [IWithPressableEvents, IHoverState] { const [hoverProps, hoverState] = useHoverHelper(props); return [{ ...props, ...usePressability({ ...props, ...hoverProps }) }, hoverState]; } @@ -135,8 +135,7 @@ export function useHoverState(props: IWithPressableOptions) * The useAsPressable hook adds a simple state change function for listening to hover, press, and focus events on the base pressability implementation * @param props - input props for the component, mixed in with pressable and pressability options */ -// eslint-disable-next-line @typescript-eslint/ban-types -export function useAsPressable(props: IWithPressableOptions): IPressableHooks { +export function useAsPressable(props: IWithPressableOptions): IPressableHooks { const [hoverProps, hoverState] = useHoverHelper(props); const [focusProps, focusState] = useFocusHelper(props); const [pressProps, pressState] = usePressHelper(props); diff --git a/packages/utils/interactive-hooks/src/useAsPressable.types.ts b/packages/utils/interactive-hooks/src/useAsPressable.types.ts index d4cbbf2e8c..1147f3d186 100644 --- a/packages/utils/interactive-hooks/src/useAsPressable.types.ts +++ b/packages/utils/interactive-hooks/src/useAsPressable.types.ts @@ -1,5 +1,8 @@ import type { PressabilityConfig, PressabilityEventHandlers } from './Pressability/Pressability.types'; +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type ObjectBase = {}; + export type IPressState = { pressed?: boolean; }; @@ -18,14 +21,11 @@ export type IPressableOptions = PressabilityConfig & { onStateChange?: (state: IPressableState) => void; }; -// eslint-disable-next-line @typescript-eslint/ban-types -export type IWithPressableOptions = T & IPressableOptions; +export type IWithPressableOptions = T & IPressableOptions; -// eslint-disable-next-line @typescript-eslint/ban-types -export type IWithPressableEvents = T & PressabilityEventHandlers; +export type IWithPressableEvents = T & PressabilityEventHandlers; -// eslint-disable-next-line @typescript-eslint/ban-types -export type IPressableHooks = { +export type IPressableHooks = { props: IWithPressableEvents; state: IPressableState; }; diff --git a/packages/utils/interactive-hooks/src/useConst.ts b/packages/utils/interactive-hooks/src/useConst.ts index e54fb3501a..e667b9af0e 100644 --- a/packages/utils/interactive-hooks/src/useConst.ts +++ b/packages/utils/interactive-hooks/src/useConst.ts @@ -1,5 +1,7 @@ import * as React from 'react'; +type FunctionToValue = () => T; + /** * Hook to initialize and return a constant value. Unlike `React.useMemo`, this is guaranteed to * always return the same value (and if the initializer is a function, only call it once). @@ -11,7 +13,7 @@ import * as React from 'react'; * only the value/function passed in the first time this is called is respected. * @returns The value. The identity of this value will always be the same. */ -export function useConst(initialValue: T | (() => T)): T { +export function useConst(initialValue: T | FunctionToValue): T { // Use useRef to store the value because it's the least expensive built-in hook that works here // (we could also use `const [value] = React.useState(initialValue)` but that's more expensive // internally due to reducer handling which we don't need) @@ -20,8 +22,7 @@ export function useConst(initialValue: T | (() => T)): T { // Box the value in an object so we can tell if it's initialized even if the initializer // returns/is undefined ref.current = { - // eslint-disable-next-line @typescript-eslint/ban-types - value: typeof initialValue === 'function' ? (initialValue as Function)() : initialValue, + value: typeof initialValue === 'function' ? (initialValue as FunctionToValue)() : initialValue, }; } return ref.current.value; diff --git a/packages/utils/interactive-hooks/src/useControllableValue.ts b/packages/utils/interactive-hooks/src/useControllableValue.ts index 317fd96c37..c20e4f4ff5 100644 --- a/packages/utils/interactive-hooks/src/useControllableValue.ts +++ b/packages/utils/interactive-hooks/src/useControllableValue.ts @@ -7,6 +7,8 @@ export type ValueChangeCallback void; +type ConvertToValue = (current: unknown) => TValue; + /** * Hook to manage a value that could be either controlled or uncontrolled, such as a checked state or * text box string. @@ -53,8 +55,7 @@ export function useControllableValue (update: React.SetStateAction, ev?: TEvent) => { // Assuming here that TValue is not a function, because a controllable value will typically // be something a user can enter as input - // eslint-disable-next-line @typescript-eslint/ban-types - const newValue = typeof update === 'function' ? (update as Function)(valueRef.current) : update; + const newValue = typeof update === 'function' ? (update as ConvertToValue)(valueRef.current) : update; if (onChangeRef.current) { onChangeRef.current(ev!, newValue); diff --git a/packages/utils/test-tools/src/baseTests.tsx b/packages/utils/test-tools/src/baseTests.tsx index 32d6744321..ec6a16b9ca 100644 --- a/packages/utils/test-tools/src/baseTests.tsx +++ b/packages/utils/test-tools/src/baseTests.tsx @@ -2,7 +2,6 @@ import * as React from 'react'; import * as renderer from 'react-test-renderer'; -// eslint-disable-next-line @typescript-eslint/no-explicit-any export function validateHookValueNotChanged[]>( testDescription: string, useHook: () => TValues, @@ -33,7 +32,7 @@ export function validateHookValueNotChanged[]>( for (let i = 0; i < latestValues!.length; i++) { try { expect(latestValues![i]).toBe(firstValues![i]); - } catch (err) { + } catch { // Make a more informative error message const valueText = latestValues![i].toString(); expect('').toBe(`Identity of value at index ${i} has changed. This might help identify it:\n${valueText}`); diff --git a/scripts/src/tasks/build.js b/scripts/src/tasks/build.js index 26412b0c9a..94168431ea 100644 --- a/scripts/src/tasks/build.js +++ b/scripts/src/tasks/build.js @@ -78,6 +78,9 @@ function getBuildTargets(cwd = process.cwd()) { async function buildTarget(target, cwd) { const { module, outDir, nativeComponents } = target; const extraArgs = ['--outDir', outDir, '--module', module]; + if (module === 'esnext') { + extraArgs.push('--moduleResolution', 'node'); + } const result = await runScript('tsc', ...extraArgs); if (result === 0 && nativeComponents && nativeComponents.length > 0) { diff --git a/scripts/src/tasks/eslint.js b/scripts/src/tasks/eslint.js index 3bff1cf71f..a74d58cf06 100644 --- a/scripts/src/tasks/eslint.js +++ b/scripts/src/tasks/eslint.js @@ -1,7 +1,19 @@ // @ts-check -const { argv, eslintTask } = require('just-scripts'); -exports.eslint = eslintTask({ - files: ['src/'], - ...argv(), -}); +const { argv } = require('just-scripts'); +const { runScript } = require('../utils/runScript.js'); + +/** + * @returns {import('just-scripts').TaskFunction} + */ +module.exports.eslint = () => { + return async (done) => { + const args = argv().fix ? ['--fix'] : []; + const result = await runScript('eslint', 'src/', ...args); + if (result !== 0) { + done(new Error(`ESLint failed with exit code ${result}`)); + } else { + done(); + } + }; +}; diff --git a/yarn.lock b/yarn.lock index 59316503f0..c9c09f974a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3219,6 +3219,7 @@ __metadata: "@rnx-kit/eslint-plugin": "npm:^0.8.6" "@types/eslint": "npm:^9.0.0" eslint: "npm:^9.0.0" + typescript-eslint: "npm:^8.36.0" languageName: unknown linkType: soft @@ -22160,7 +22161,7 @@ __metadata: languageName: node linkType: hard -"typescript-eslint@npm:^8.0.0": +"typescript-eslint@npm:^8.0.0, typescript-eslint@npm:^8.36.0": version: 8.36.0 resolution: "typescript-eslint@npm:8.36.0" dependencies: