From 843c54d4e0ef67f81076a33fe2d5355e29f728ef Mon Sep 17 00:00:00 2001 From: Brian Diehr Date: Fri, 17 Mar 2023 23:17:26 -0700 Subject: [PATCH] refactor(ESLint): enforce import related eslint rules across monorepo --- configuration/eslint-config/index.js | 11 +- configuration/eslint-config/package.json | 7 +- package-lock.json | 230 ++++++++++++++---- packages/components/package.json | 2 +- packages/core/src/index.ts | 2 - packages/dashboard/package.json | 2 +- .../src/components/contextMenu/option.tsx | 2 +- .../components/internalDashboard/index.tsx | 2 +- .../src/components/resourceExplorer/index.tsx | 4 +- .../src/components/sidePanel/index.tsx | 5 +- .../propertiesAlarmSection/index.test.tsx | 2 +- .../src/components/widgets/dynamicWidget.tsx | 7 +- packages/dashboard/src/hooks/useKeyPress.ts | 2 +- .../video-player/requestVideoUpload.tsx | 4 +- .../components/video-player/videoPlayer.tsx | 8 +- .../src/HOC/withUseTreeCollection.tsx | 12 +- .../src/RelatedTable/ButtonWithTreeLines.tsx | 4 +- packages/scene-composer/.eslintignore | 1 + packages/scene-composer/package.json | 2 +- .../tests/utils/objectThreeUtils.spec.ts | 2 + .../src/asset-modules/sitewise/cache.spec.ts | 3 +- .../src/time-series-data/data-source.ts | 3 +- 22 files changed, 234 insertions(+), 83 deletions(-) diff --git a/configuration/eslint-config/index.js b/configuration/eslint-config/index.js index daa49184c..3c6e2507b 100644 --- a/configuration/eslint-config/index.js +++ b/configuration/eslint-config/index.js @@ -6,12 +6,10 @@ module.exports = { node: true, }, ignorePatterns: [ - 'cypress', 'stencil.config.ts', 'configuration', '__mocks__', 'packages/scene-composer/src/three/tiles3d/*', - 'examples/**/*', ], extends: [ 'turbo', @@ -19,9 +17,10 @@ module.exports = { 'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', - 'plugin:chai-friendly/recommended', + 'plugin:import/recommended', + 'plugin:import/typescript', ], - plugins: ['prettier', 'chai-friendly', 'react', 'jest', 'import'], + plugins: ['prettier', 'react', 'jest', 'import'], globals: { module: true, process: true, @@ -37,6 +36,10 @@ module.exports = { react: { pragma: 'h', }, + 'import/resolver': { + typescript: true, + node: true, + }, }, rules: { '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], diff --git a/configuration/eslint-config/package.json b/configuration/eslint-config/package.json index fd4eb42f7..3cc32d685 100644 --- a/configuration/eslint-config/package.json +++ b/configuration/eslint-config/package.json @@ -12,8 +12,6 @@ "eslint-config-airbnb-typescript": "^17.0.0", "eslint-config-prettier": "8.3.0", "eslint-config-turbo": "latest", - "eslint-plugin-chai-friendly": "0.7.2", - "eslint-plugin-cypress": "2.12.1", "eslint-plugin-formatjs": "3.0.0", "eslint-plugin-import": "2.25.2", "eslint-plugin-jest": "^26.6.0", @@ -25,5 +23,8 @@ }, "files": [ "index.js" - ] + ], + "devDependencies": { + "eslint-import-resolver-typescript": "^3.5.3" + } } diff --git a/package-lock.json b/package-lock.json index da67e818b..62e8f6c8a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,8 +48,6 @@ "eslint-config-airbnb-typescript": "^17.0.0", "eslint-config-prettier": "8.3.0", "eslint-config-turbo": "latest", - "eslint-plugin-chai-friendly": "0.7.2", - "eslint-plugin-cypress": "2.12.1", "eslint-plugin-formatjs": "3.0.0", "eslint-plugin-import": "2.25.2", "eslint-plugin-jest": "^26.6.0", @@ -58,6 +56,9 @@ "eslint-plugin-prettier": "4.0.0", "eslint-plugin-react": "7.26.1", "eslint-plugin-react-hooks": "^4.2.0" + }, + "devDependencies": { + "eslint-import-resolver-typescript": "^3.5.3" } }, "configuration/eslint-config/node_modules/eslint-config-airbnb-typescript": { @@ -9151,6 +9152,26 @@ "node": ">= 8" } }, + "node_modules/@pkgr/utils": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.3.1.tgz", + "integrity": "sha512-wfzX8kc1PMyUILA+1Z/EqoE4UCXGy0iRGMhPwdfae1+f0OXlLqCk+By+aMzgJBzR9AzS4CDizioG6Ss1gvAFJw==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "is-glob": "^4.0.3", + "open": "^8.4.0", + "picocolors": "^1.0.0", + "tiny-glob": "^0.2.9", + "tslib": "^2.4.0" + }, + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/@playwright/test": { "version": "1.31.2", "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.31.2.tgz", @@ -24798,6 +24819,62 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-import-resolver-typescript": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.5.3.tgz", + "integrity": "sha512-njRcKYBc3isE42LaTcJNVANR3R99H9bAxBDMNDr2W7yq5gYPxbU3MkdhsQukxZ/Xg9C2vcyLlDsbKfRDg0QvCQ==", + "dev": true, + "dependencies": { + "debug": "^4.3.4", + "enhanced-resolve": "^5.10.0", + "get-tsconfig": "^4.2.0", + "globby": "^13.1.2", + "is-core-module": "^2.10.0", + "is-glob": "^4.0.3", + "synckit": "^0.8.4" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts/projects/eslint-import-resolver-ts" + }, + "peerDependencies": { + "eslint": "*", + "eslint-plugin-import": "*" + } + }, + "node_modules/eslint-import-resolver-typescript/node_modules/globby": { + "version": "13.1.3", + "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.3.tgz", + "integrity": "sha512-8krCNHXvlCgHDpegPzleMq07yMYTO2sXKASmZmquEYWEmCx6J5UTRbp5RwMJkTJGtcQ44YpiUYUiN0b9mzy8Bw==", + "dev": true, + "dependencies": { + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.11", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-import-resolver-typescript/node_modules/slash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", + "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/eslint-module-utils": { "version": "2.7.4", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz", @@ -24824,30 +24901,6 @@ "ms": "^2.1.1" } }, - "node_modules/eslint-plugin-chai-friendly": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-chai-friendly/-/eslint-plugin-chai-friendly-0.7.2.tgz", - "integrity": "sha512-LOIfGx5sZZ5FwM1shr2GlYAWV9Omdi+1/3byuVagvQNoGUuU0iHhp7AfjA1uR+4dJ4Isfb4+FwBJgQajIw9iAg==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - }, - "peerDependencies": { - "eslint": ">=3.0.0" - } - }, - "node_modules/eslint-plugin-cypress": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-cypress/-/eslint-plugin-cypress-2.12.1.tgz", - "integrity": "sha512-c2W/uPADl5kospNDihgiLc7n87t5XhUbFDoTl6CfVkmG+kDAb5Ux10V9PoLPu9N+r7znpc+iQlcmAqT1A/89HA==", - "license": "MIT", - "dependencies": { - "globals": "^11.12.0" - }, - "peerDependencies": { - "eslint": ">= 3.2.1" - } - }, "node_modules/eslint-plugin-es": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", @@ -27521,6 +27574,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-tsconfig": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.4.0.tgz", + "integrity": "sha512-0Gdjo/9+FzsYhXCEFueo2aY1z1tpXrxWZzP7k8ul9qt1U5o8rYJwTJYmaeHdrVosYIVYkOy2iwCJ9FdpocJhPQ==", + "dev": true, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/get-value": { "version": "2.0.6", "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", @@ -49186,6 +49248,28 @@ "dev": true, "license": "BSD-3-Clause" }, + "node_modules/synckit": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.5.tgz", + "integrity": "sha512-L1dapNV6vu2s/4Sputv8xGsCdAVlb5nRDMFU/E27D44l5U6cw1g0dGd45uLc+OXjNMmF4ntiMdCimzcjFKQI8Q==", + "dev": true, + "dependencies": { + "@pkgr/utils": "^2.3.1", + "tslib": "^2.5.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, + "node_modules/synckit/node_modules/tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + }, "node_modules/table": { "version": "6.8.0", "resolved": "https://registry.npmjs.org/table/-/table-6.8.0.tgz", @@ -53327,12 +53411,12 @@ "@awsui/design-tokens": "^3.0.0", "@iot-app-kit/core": "4.0.0", "@iot-app-kit/related-table": "4.0.0", - "@iot-app-kit/source-iotsitewise": "4.0.0", "@stencil/core": "^2.7.0", "@synchro-charts/core": "7.2.0", "styled-components": "^5.3.9" }, "devDependencies": { + "@iot-app-kit/source-iotsitewise": "^4.0.0", "@iot-app-kit/testing-util": "*", "@rollup/plugin-replace": "^3.0.0", "@stencil/router": "^1.0.1", @@ -62712,7 +62796,7 @@ "@awsui/design-tokens": "^3.0.0", "@iot-app-kit/core": "4.0.0", "@iot-app-kit/related-table": "4.0.0", - "@iot-app-kit/source-iotsitewise": "4.0.0", + "@iot-app-kit/source-iotsitewise": "*", "@iot-app-kit/testing-util": "*", "@rollup/plugin-replace": "^3.0.0", "@stencil/core": "^2.7.0", @@ -68522,6 +68606,20 @@ "fastq": "^1.6.0" } }, + "@pkgr/utils": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.3.1.tgz", + "integrity": "sha512-wfzX8kc1PMyUILA+1Z/EqoE4UCXGy0iRGMhPwdfae1+f0OXlLqCk+By+aMzgJBzR9AzS4CDizioG6Ss1gvAFJw==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.3", + "is-glob": "^4.0.3", + "open": "^8.4.0", + "picocolors": "^1.0.0", + "tiny-glob": "^0.2.9", + "tslib": "^2.4.0" + } + }, "@playwright/test": { "version": "1.31.2", "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.31.2.tgz", @@ -80033,8 +80131,7 @@ "eslint-config-airbnb-typescript": "^17.0.0", "eslint-config-prettier": "8.3.0", "eslint-config-turbo": "latest", - "eslint-plugin-chai-friendly": "0.7.2", - "eslint-plugin-cypress": "2.12.1", + "eslint-import-resolver-typescript": "^3.5.3", "eslint-plugin-formatjs": "3.0.0", "eslint-plugin-import": "2.25.2", "eslint-plugin-jest": "^26.6.0", @@ -80255,6 +80352,42 @@ } } }, + "eslint-import-resolver-typescript": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.5.3.tgz", + "integrity": "sha512-njRcKYBc3isE42LaTcJNVANR3R99H9bAxBDMNDr2W7yq5gYPxbU3MkdhsQukxZ/Xg9C2vcyLlDsbKfRDg0QvCQ==", + "dev": true, + "requires": { + "debug": "^4.3.4", + "enhanced-resolve": "^5.10.0", + "get-tsconfig": "^4.2.0", + "globby": "^13.1.2", + "is-core-module": "^2.10.0", + "is-glob": "^4.0.3", + "synckit": "^0.8.4" + }, + "dependencies": { + "globby": { + "version": "13.1.3", + "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.3.tgz", + "integrity": "sha512-8krCNHXvlCgHDpegPzleMq07yMYTO2sXKASmZmquEYWEmCx6J5UTRbp5RwMJkTJGtcQ44YpiUYUiN0b9mzy8Bw==", + "dev": true, + "requires": { + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.11", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^4.0.0" + } + }, + "slash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", + "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", + "dev": true + } + } + }, "eslint-module-utils": { "version": "2.7.4", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz", @@ -80273,19 +80406,6 @@ } } }, - "eslint-plugin-chai-friendly": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-chai-friendly/-/eslint-plugin-chai-friendly-0.7.2.tgz", - "integrity": "sha512-LOIfGx5sZZ5FwM1shr2GlYAWV9Omdi+1/3byuVagvQNoGUuU0iHhp7AfjA1uR+4dJ4Isfb4+FwBJgQajIw9iAg==" - }, - "eslint-plugin-cypress": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-cypress/-/eslint-plugin-cypress-2.12.1.tgz", - "integrity": "sha512-c2W/uPADl5kospNDihgiLc7n87t5XhUbFDoTl6CfVkmG+kDAb5Ux10V9PoLPu9N+r7znpc+iQlcmAqT1A/89HA==", - "requires": { - "globals": "^11.12.0" - } - }, "eslint-plugin-es": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", @@ -82042,6 +82162,12 @@ "get-intrinsic": "^1.1.1" } }, + "get-tsconfig": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.4.0.tgz", + "integrity": "sha512-0Gdjo/9+FzsYhXCEFueo2aY1z1tpXrxWZzP7k8ul9qt1U5o8rYJwTJYmaeHdrVosYIVYkOy2iwCJ9FdpocJhPQ==", + "dev": true + }, "get-value": { "version": "2.0.6", "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", @@ -97588,6 +97714,24 @@ "integrity": "sha512-qImOD23aDfnIDNqlG1NOehdB9IYsn1V9oByPjKY1nakv2MQYCEMyX033/q+aEtYCpmYK1cv2+NTmlH+ra6GA5A==", "dev": true }, + "synckit": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.5.tgz", + "integrity": "sha512-L1dapNV6vu2s/4Sputv8xGsCdAVlb5nRDMFU/E27D44l5U6cw1g0dGd45uLc+OXjNMmF4ntiMdCimzcjFKQI8Q==", + "dev": true, + "requires": { + "@pkgr/utils": "^2.3.1", + "tslib": "^2.5.0" + }, + "dependencies": { + "tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + } + } + }, "table": { "version": "6.8.0", "resolved": "https://registry.npmjs.org/table/-/table-6.8.0.tgz", diff --git a/packages/components/package.json b/packages/components/package.json index 1f4a1aaa9..c5d882ae0 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -62,12 +62,12 @@ "@awsui/design-tokens": "^3.0.0", "@iot-app-kit/core": "4.0.0", "@iot-app-kit/related-table": "4.0.0", - "@iot-app-kit/source-iotsitewise": "4.0.0", "@stencil/core": "^2.7.0", "@synchro-charts/core": "7.2.0", "styled-components": "^5.3.9" }, "devDependencies": { + "@iot-app-kit/source-iotsitewise": "^4.0.0", "@iot-app-kit/testing-util": "*", "@rollup/plugin-replace": "^3.0.0", "@stencil/router": "^1.0.1", diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index d2f71d6cc..cfd17e5fa 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -24,5 +24,3 @@ export const SECOND_IN_MS = 1000; export const MINUTE_IN_MS = 60 * SECOND_IN_MS; export const HOUR_IN_MS = 60 * MINUTE_IN_MS; export const DAY_IN_MS = 24 * HOUR_IN_MS; - -export type { CacheSettings } from './data-module/data-cache/types'; diff --git a/packages/dashboard/package.json b/packages/dashboard/package.json index fd8938b9b..d4953dbb0 100644 --- a/packages/dashboard/package.json +++ b/packages/dashboard/package.json @@ -29,7 +29,7 @@ "clean": "rimraf dist", "start": "start-storybook -p 6006", "test": "jest --silent", - "lint": "eslint . --max-warnings=3", + "lint": "eslint . --max-warnings=0", "fix": "eslint --fix .", "test:ui": "npx playwright test" }, diff --git a/packages/dashboard/src/components/contextMenu/option.tsx b/packages/dashboard/src/components/contextMenu/option.tsx index 3b803c3f2..12c5b9b02 100644 --- a/packages/dashboard/src/components/contextMenu/option.tsx +++ b/packages/dashboard/src/components/contextMenu/option.tsx @@ -1,4 +1,4 @@ -import isHotkey from 'is-hotkey'; +import { isHotkey } from 'is-hotkey'; import React from 'react'; import './option.css'; diff --git a/packages/dashboard/src/components/internalDashboard/index.tsx b/packages/dashboard/src/components/internalDashboard/index.tsx index e4a974d85..e74cc0e70 100644 --- a/packages/dashboard/src/components/internalDashboard/index.tsx +++ b/packages/dashboard/src/components/internalDashboard/index.tsx @@ -13,7 +13,7 @@ import UserSelection from '../userSelection'; import SidePanel from '../sidePanel'; import ComponentPalette from '../palette'; import CustomDragLayer from '../dragLayer'; -import ResourceExplorer from '../resourceExplorer'; +import { ResourceExplorer } from '../resourceExplorer'; import ViewportSelection from '../viewportSelection'; import Actions from '../actions'; diff --git a/packages/dashboard/src/components/resourceExplorer/index.tsx b/packages/dashboard/src/components/resourceExplorer/index.tsx index 0f8f36a6a..79e734323 100644 --- a/packages/dashboard/src/components/resourceExplorer/index.tsx +++ b/packages/dashboard/src/components/resourceExplorer/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { memo } from 'react'; import { StencilResourceExplorer } from './stencil'; import Box from '@cloudscape-design/components/box'; import { useQueries } from '../dashboard/queryContext'; @@ -19,4 +19,4 @@ export const ResourceExplorer = () => { ); }; -export default React.memo(ResourceExplorer); +export default memo(ResourceExplorer); diff --git a/packages/dashboard/src/components/sidePanel/index.tsx b/packages/dashboard/src/components/sidePanel/index.tsx index bdf758aaa..74b807c0c 100644 --- a/packages/dashboard/src/components/sidePanel/index.tsx +++ b/packages/dashboard/src/components/sidePanel/index.tsx @@ -5,13 +5,14 @@ import LinkSettings from './sections/textSettingSection/link'; import { BaseSettings } from './sections/baseSettingSection'; import AxisSetting, { isAxisSettingsSupported } from './sections/axisSettingSection'; import ThresholdsSection, { isThresholdsSupported } from './sections/thresholdsSection/thresholdsSection'; -import PropertiesAlarmsSection, { isPropertiesAndAlarmsSupported } from './sections/propertiesAlarmSection'; +import { isPropertiesAndAlarmsSupported, PropertiesAlarmsSection } from './sections/propertiesAlarmSection'; import type { DashboardMessages } from '~/messages'; +import type { FC } from 'react'; import { useSelectedWidgets } from '~/hooks/useSelectedWidgets'; import './index.css'; -const SidePanel: React.FC<{ messageOverrides: DashboardMessages }> = ({ messageOverrides }) => { +const SidePanel: FC<{ messageOverrides: DashboardMessages }> = ({ messageOverrides }) => { const selectedWidgets = useSelectedWidgets(); if (selectedWidgets.length !== 1) { return ( diff --git a/packages/dashboard/src/components/sidePanel/sections/propertiesAlarmSection/index.test.tsx b/packages/dashboard/src/components/sidePanel/sections/propertiesAlarmSection/index.test.tsx index d1da99a33..7601ada25 100644 --- a/packages/dashboard/src/components/sidePanel/sections/propertiesAlarmSection/index.test.tsx +++ b/packages/dashboard/src/components/sidePanel/sections/propertiesAlarmSection/index.test.tsx @@ -6,7 +6,7 @@ import { SiteWiseAssetQuery } from '@iot-app-kit/source-iotsitewise'; import { createMockIoTEventsSDK, createMockSiteWiseSDK } from '@iot-app-kit/testing-util'; import { MOCK_KPI_WIDGET } from '../../../../../testing/mocks'; -import PropertiesAlarmsSection from './index'; +import { PropertiesAlarmsSection } from './index'; import { configureDashboardStore } from '../../../../store'; import { ClientContext } from '~/components/dashboard/clientContext'; diff --git a/packages/dashboard/src/components/widgets/dynamicWidget.tsx b/packages/dashboard/src/components/widgets/dynamicWidget.tsx index b62354a6f..9d2935e32 100644 --- a/packages/dashboard/src/components/widgets/dynamicWidget.tsx +++ b/packages/dashboard/src/components/widgets/dynamicWidget.tsx @@ -1,11 +1,12 @@ -import React from 'react'; +import React, { createElement } from 'react'; import { WidgetComponentMap } from '~/customization/widgetComponentMap'; +import type { FC } from 'react'; import './dynamicWidget.css'; import type { Widget } from '~/types'; import type { WidgetsMessages } from '~/messages'; -const IconX: React.FC = () => ( +const IconX: FC = () => (
diff --git a/packages/dashboard/src/hooks/useKeyPress.ts b/packages/dashboard/src/hooks/useKeyPress.ts index 0f329dda1..bdd901b3e 100644 --- a/packages/dashboard/src/hooks/useKeyPress.ts +++ b/packages/dashboard/src/hooks/useKeyPress.ts @@ -1,5 +1,5 @@ import { useCallback, useEffect, useRef, useState } from 'react'; -import isHotkey from 'is-hotkey'; +import { isHotkey } from 'is-hotkey'; type KeyPressCallback = (e: KeyboardEvent) => void; type KeyPressOptions = { diff --git a/packages/react-components/src/components/video-player/requestVideoUpload.tsx b/packages/react-components/src/components/video-player/requestVideoUpload.tsx index db20e8af6..40971c7bf 100644 --- a/packages/react-components/src/components/video-player/requestVideoUpload.tsx +++ b/packages/react-components/src/components/video-player/requestVideoUpload.tsx @@ -1,11 +1,11 @@ import { Button, DateRangePicker, SpaceBetween } from '@cloudscape-design/components'; -import React from 'react'; +import React, { Component } from 'react'; import { i18nStrings, requestVideoButtonLabel } from './constants'; import { getStartAndEndTimeFromRange } from './utils/dateRangeUtils'; import type { DateRangePickerProps } from '@cloudscape-design/components'; import type { IVideoUploadRequestProps, IVideoUploadRequestState } from './types'; -export class RequestVideoUpload extends React.Component { +export class RequestVideoUpload extends Component { private uploadStartTime = ''; private uploadEndTime = ''; diff --git a/packages/react-components/src/components/video-player/videoPlayer.tsx b/packages/react-components/src/components/video-player/videoPlayer.tsx index 48e496531..e4efe2500 100644 --- a/packages/react-components/src/components/video-player/videoPlayer.tsx +++ b/packages/react-components/src/components/video-player/videoPlayer.tsx @@ -1,5 +1,7 @@ +// VideoJS exports as a single namespace +/* eslint-disable import/no-named-as-default-member */ import DOMPurify from 'dompurify'; -import React from 'react'; +import React, { Component, RefObject } from 'react'; import { v4 as uuid } from 'uuid'; import videojs from 'video.js'; import 'video.js/dist/video-js.css'; @@ -26,8 +28,8 @@ import type { VideoJsPlayer } from 'video.js'; import type { IVideoPlayerProps, IVideoPlayerState, VideoTimeRanges, VideoTimeRangesWithSource } from './types'; import type { Viewport } from '@iot-app-kit/core'; -export class VideoPlayer extends React.Component { - private domRef: React.RefObject; +export class VideoPlayer extends Component { + private domRef: RefObject; private videoPlayerId: string = uuid(); private videoPlayer?: VideoJsPlayer; private seekbar?: HTMLElement; diff --git a/packages/related-table/src/HOC/withUseTreeCollection.tsx b/packages/related-table/src/HOC/withUseTreeCollection.tsx index ef4e2a9f8..ad6ed5bcd 100644 --- a/packages/related-table/src/HOC/withUseTreeCollection.tsx +++ b/packages/related-table/src/HOC/withUseTreeCollection.tsx @@ -1,4 +1,4 @@ -import React, { FC } from 'react'; +import React, { FC, createElement } from 'react'; import TextFilter from '@awsui/components-react/text-filter'; import Pagination from '@awsui/components-react/pagination'; import { NonCancelableCustomEvent, TableProps } from '@awsui/components-react'; @@ -16,7 +16,7 @@ export interface RelatedTableExtendedProps extends Omit, } export const withUseTreeCollection = (RelatedTableComp: FC) => { - return (wrapperProps: RelatedTableExtendedProps) => { + return (wrapperProps: RelatedTableExtendedProps) => { const { items, empty, @@ -43,12 +43,12 @@ export const withUseTreeCollection = (RelatedTableComp: FC) => { expanded ); - const emptyComponent = React.createElement(EmptyState, empty); - const filterComponent = React.createElement(TextFilter, { + const emptyComponent = createElement(EmptyState, empty); + const filterComponent = createElement(TextFilter, { ...filterProps, filteringPlaceholder: filterPlaceholder || '', }); - const paginationComponent = React.createElement(Pagination, paginationProps); + const paginationComponent = createElement(Pagination, paginationProps); const hocProps = { ...wrapperProps, @@ -77,7 +77,7 @@ export const withUseTreeCollection = (RelatedTableComp: FC) => { onSelectionChange(event); } if (collectionProps.onSelectionChange) { - collectionProps.onSelectionChange(event); + collectionProps.onSelectionChange(event as any); } }, }; diff --git a/packages/related-table/src/RelatedTable/ButtonWithTreeLines.tsx b/packages/related-table/src/RelatedTable/ButtonWithTreeLines.tsx index 1d4d9dd29..fe750e7a6 100644 --- a/packages/related-table/src/RelatedTable/ButtonWithTreeLines.tsx +++ b/packages/related-table/src/RelatedTable/ButtonWithTreeLines.tsx @@ -1,5 +1,5 @@ import Button from '@awsui/components-react/button'; -import React, { ReactNode } from 'react'; +import React, { ReactNode, memo } from 'react'; import { EmptySpace, LeftPad, Wrapper, ButtonWrapper } from './Common/StyledComponents'; import { ExpandableTableNodeStatus, ITreeNode } from '../Model/TreeNode'; import { createPrefixLines, Theme } from './Common/TreeLines'; @@ -38,7 +38,7 @@ function createToggleButton(props: ButtonWithTreeLinesProps) { ); } -export const ButtonWithTreeLines = React.memo(function ButtonWithTreeLinesComp(props: ButtonWithTreeLinesProps) { +export const ButtonWithTreeLines = memo(function ButtonWithTreeLinesComp(props: ButtonWithTreeLinesProps) { const { node, content, alwaysExpanded } = props; const leftPadLength = node.getPrefix().length ? MARGIN_LEFT_REM_MULTIPLICATOR * (node.getPrefix().length - 1) : 0; return ( diff --git a/packages/scene-composer/.eslintignore b/packages/scene-composer/.eslintignore index f1901e4c3..c1fae0b6d 100644 --- a/packages/scene-composer/.eslintignore +++ b/packages/scene-composer/.eslintignore @@ -2,4 +2,5 @@ dist *.min.js *.d.ts jest.config.js +storybook-static coverage diff --git a/packages/scene-composer/package.json b/packages/scene-composer/package.json index 9c0888ac2..904d5260d 100644 --- a/packages/scene-composer/package.json +++ b/packages/scene-composer/package.json @@ -46,7 +46,7 @@ "convert-svg": "npx @svgr/cli --out-dir src/assets/auto-gen/icons/ --typescript --index-template tools/index-template.js -- src/assets/icons/", "release": "run-s compile copy-assets", "copy-assets": "copyfiles -e \"**/*.tsx\" -e \"**/*.ts\" -e \"**/*.snap\" -e \"**/*.js\" -e \"**/*.jsx\" -e \"**/*.json\" \"src/**/*\" dist/", - "lint": "eslint . --max-warnings=838", + "lint": "eslint . --max-warnings=912", "fix": "eslint --fix .", "test": "jest --config jest.config.ts --coverage --silent", "test:dev": "jest --config jest.config.ts --coverage", diff --git a/packages/scene-composer/tests/utils/objectThreeUtils.spec.ts b/packages/scene-composer/tests/utils/objectThreeUtils.spec.ts index 238d89245..1da4a31b8 100644 --- a/packages/scene-composer/tests/utils/objectThreeUtils.spec.ts +++ b/packages/scene-composer/tests/utils/objectThreeUtils.spec.ts @@ -89,6 +89,7 @@ describe('objectThreeUtils', () => { }); it('should not enable shadow', () => { + // eslint-disable-next-line import/namespace const texture = new THREE.DataTexture(new Uint8Array(3), 2, 2, THREE.RGBFormat); const object = new THREE.Mesh(new THREE.BoxGeometry(1, 2, 3), new THREE.MeshBasicMaterial({ map: texture })); @@ -100,6 +101,7 @@ describe('objectThreeUtils', () => { }); it('should enable shadow', () => { + // eslint-disable-next-line import/namespace const texture = new THREE.DataTexture(new Uint8Array(3), 2, 2, THREE.RGBFormat); const object = new THREE.Mesh(new THREE.BoxGeometry(1, 2, 3), new THREE.MeshBasicMaterial({ map: texture })); diff --git a/packages/source-iotsitewise/src/asset-modules/sitewise/cache.spec.ts b/packages/source-iotsitewise/src/asset-modules/sitewise/cache.spec.ts index 9a93dd268..0c8ab4a39 100644 --- a/packages/source-iotsitewise/src/asset-modules/sitewise/cache.spec.ts +++ b/packages/source-iotsitewise/src/asset-modules/sitewise/cache.spec.ts @@ -1,8 +1,7 @@ import { SiteWiseAssetCache } from './cache'; import { LoadingStateEnum } from './types'; import { ASSET_MODEL_ID, sampleAssetModel } from '../../__mocks__/assetModel'; -import { sampleAssetSummary } from '../../__mocks__/asset'; -import { ASSET_ID, sampleAssetDescription } from '../../__mocks__/asset'; +import { sampleAssetSummary, ASSET_ID, sampleAssetDescription } from '../../__mocks__/asset'; import { samplePropertyValue } from '../../__mocks__/assetPropertyValue'; const ASSET_PROPERTY_ID = 'assetPropertyIdAbc123'; diff --git a/packages/source-iotsitewise/src/time-series-data/data-source.ts b/packages/source-iotsitewise/src/time-series-data/data-source.ts index 0c36d110a..2a6abe3ee 100644 --- a/packages/source-iotsitewise/src/time-series-data/data-source.ts +++ b/packages/source-iotsitewise/src/time-series-data/data-source.ts @@ -1,5 +1,4 @@ -import { IoTSiteWiseClient } from '@aws-sdk/client-iotsitewise'; -import { AggregateType } from '@aws-sdk/client-iotsitewise'; +import { IoTSiteWiseClient, AggregateType } from '@aws-sdk/client-iotsitewise'; import { SiteWiseClient } from './client/client'; import { toId } from './util/dataStreamId'; import { viewportEndDate, viewportStartDate, parseDuration } from '@iot-app-kit/core';