diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 9e4ed66c8..000000000 --- a/.prettierignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -www -build -dist -**/build/* -**/dist/* -coverage -packages/components/loader/* diff --git a/.prettierrc b/.prettierrc old mode 100755 new mode 100644 diff --git a/package.json b/package.json index 0183bc3f3..1b38b13ad 100755 --- a/package.json +++ b/package.json @@ -15,13 +15,11 @@ "start": "cd packages/components && yarn run start", "build": "lerna run build --stream", "clean": "lerna run clean --concurrency 4", - "lint": "npm-run-all -p lint:prettier lint:eslint", - "lint:prettier": "prettier --check packages/**/*.{ts,tsx,js,json}", - "lint:eslint": "eslint --ext .js,.ts,.tsx .", - "fix": "npm-run-all -p fix:prettier fix:eslint", + "lint": "npm-run-all -p lint:eslint", + "lint:eslint": "eslint --ext .js,.ts,.tsx . --max-warnings 0", + "fix": "npm-run-all -p fix:eslint", "fix:eslint": "eslint --fix --ext .js,.ts,.tsx .", - "fix:prettier": "prettier --write packages/**/*.{ts,tsx,js,json}", - "test": "npm-run-all -p test:unit", + "test": "npm-run-all -p test:unit lint", "test:unit": "lerna run test --stream --concurrency 1", "pack": "lerna run pack" }, @@ -76,8 +74,6 @@ "lerna": "^4.0.0", "lerna-changelog": "^1.0.1", "npm-run-all": "^4.1.5", - "prettier-eslint": "13.0.0", - "prettier-eslint-cli": "5.0.1", "query-string": "^6.13.5", "stylelint": "^11.1.1", "stylelint-config-standard": "^19.0.0", diff --git a/packages/components/src/components/iot-connector/iot-connector.tsx b/packages/components/src/components/iot-connector/iot-connector.tsx index 23f0dd796..764a2f972 100644 --- a/packages/components/src/components/iot-connector/iot-connector.tsx +++ b/packages/components/src/components/iot-connector/iot-connector.tsx @@ -70,7 +70,7 @@ export class IotConnector { this.update({ request: { ...this.request, - viewport: {start, end, lastUpdatedBy} + viewport: { start, end, lastUpdatedBy }, }, }); } diff --git a/packages/core/src/asset-modules/sitewise/requestProcessor.ts b/packages/core/src/asset-modules/sitewise/requestProcessor.ts index b3ad74a72..f6d1cda3e 100644 --- a/packages/core/src/asset-modules/sitewise/requestProcessor.ts +++ b/packages/core/src/asset-modules/sitewise/requestProcessor.ts @@ -30,37 +30,29 @@ export class RequestProcessor { private readonly cache: SiteWiseAssetCache; private readonly MAX_RESULTS: number = 250; - private readonly assetSummaryWorkers: RequestProcessorWorkerGroup< - AssetSummaryQuery, - AssetSummary - > = new RequestProcessorWorkerGroup( - (query) => this.assetSummaryWorkerFactory(query), - (query) => query.assetId - ); + private readonly assetSummaryWorkers: RequestProcessorWorkerGroup = + new RequestProcessorWorkerGroup( + (query) => this.assetSummaryWorkerFactory(query), + (query) => query.assetId + ); - private readonly assetModelWorkers: RequestProcessorWorkerGroup< - AssetModelQuery, - DescribeAssetModelResponse - > = new RequestProcessorWorkerGroup( - (query) => this.assetModelWorkerFactory(query), - (query) => query.assetModelId - ); + private readonly assetModelWorkers: RequestProcessorWorkerGroup = + new RequestProcessorWorkerGroup( + (query) => this.assetModelWorkerFactory(query), + (query) => query.assetModelId + ); - private readonly assetPropertyValueWorkers: RequestProcessorWorkerGroup< - AssetPropertyValueQuery, - AssetPropertyValue - > = new RequestProcessorWorkerGroup( - (query) => this.assetPropertyValueWorkerFactory(query), - (query) => query.assetId + ':' + query.propertyId - ); + private readonly assetPropertyValueWorkers: RequestProcessorWorkerGroup = + new RequestProcessorWorkerGroup( + (query) => this.assetPropertyValueWorkerFactory(query), + (query) => query.assetId + ':' + query.propertyId + ); - private readonly hierarchyWorkers: RequestProcessorWorkerGroup< - AssetHierarchyQuery, - HierarchyAssetSummaryList - > = new RequestProcessorWorkerGroup( - (query) => this.loadHierarchyWorkerFactory(query), - (query) => assetHierarchyQueryKey(query) - ); + private readonly hierarchyWorkers: RequestProcessorWorkerGroup = + new RequestProcessorWorkerGroup( + (query) => this.loadHierarchyWorkerFactory(query), + (query) => assetHierarchyQueryKey(query) + ); constructor(api: SiteWiseAssetDataSource, cache: SiteWiseAssetCache) { this.api = api; diff --git a/packages/core/src/asset-modules/sitewise/requestProcessorWorkerGroup.spec.ts b/packages/core/src/asset-modules/sitewise/requestProcessorWorkerGroup.spec.ts index 531d4b7e7..fd0795de9 100644 --- a/packages/core/src/asset-modules/sitewise/requestProcessorWorkerGroup.spec.ts +++ b/packages/core/src/asset-modules/sitewise/requestProcessorWorkerGroup.spec.ts @@ -213,35 +213,32 @@ it('producers can run a finalizer when the last subscriber unsubscribes', (done) let workerGroup: RequestProcessorWorkerGroup; function unsubscribe() { - expect(recorder.peek()).toEqual(5); - recorder.unsubscribe(); - // expect no workers to remain because finalizer ran to delete the worker - expect(workerGroup.size()).toEqual(0); + expect(recorder.peek()).toEqual(5); + recorder.unsubscribe(); + // expect no workers to remain because finalizer ran to delete the worker + expect(workerGroup.size()).toEqual(0); } - workerGroup = new RequestProcessorWorkerGroup( - (query) => { - let timeoutID: any; - let counter = 0; - return new Observable((subscriber) => { - timeoutID = setInterval(function incrementer() { - counter++; - subscriber.next(counter); - if (counter === 5) { - unsubscribe(); - } - }, 5); - }).pipe( - finalize(() => { - clearInterval(timeoutID); - // the test actually ends here when the timeout is cleared - // if you remove this call to done() the test will hang, timeout and fail - done(); - }) - ); - }, - identity - ); + workerGroup = new RequestProcessorWorkerGroup((query) => { + let timeoutID: any; + let counter = 0; + return new Observable((subscriber) => { + timeoutID = setInterval(function incrementer() { + counter++; + subscriber.next(counter); + if (counter === 5) { + unsubscribe(); + } + }, 5); + }).pipe( + finalize(() => { + clearInterval(timeoutID); + // the test actually ends here when the timeout is cleared + // if you remove this call to done() the test will hang, timeout and fail + done(); + }) + ); + }, identity); workerGroup.subscribe('test', recorder); expect(workerGroup.size()).toEqual(1); diff --git a/packages/core/src/common/predicates.spec.ts b/packages/core/src/common/predicates.spec.ts index 6192570ba..e5ba3c9c0 100644 --- a/packages/core/src/common/predicates.spec.ts +++ b/packages/core/src/common/predicates.spec.ts @@ -176,7 +176,7 @@ describe('isMinimalStaticViewPort', () => { start: new Date(), }; - expect(isMinimalStaticViewport((viewport as unknown) as MinimalLiveViewport)).toBeFalse(); + expect(isMinimalStaticViewport(viewport as unknown as MinimalLiveViewport)).toBeFalse(); }); it('returns false when the start date is missing', () => { @@ -186,6 +186,6 @@ describe('isMinimalStaticViewPort', () => { end: new Date(), }; - expect(isMinimalStaticViewport((viewport as unknown) as MinimalLiveViewport)).toBeFalse(); + expect(isMinimalStaticViewport(viewport as unknown as MinimalLiveViewport)).toBeFalse(); }); }); diff --git a/packages/core/src/common/predicates.ts b/packages/core/src/common/predicates.ts index ca262240c..672e43a15 100644 --- a/packages/core/src/common/predicates.ts +++ b/packages/core/src/common/predicates.ts @@ -29,11 +29,16 @@ import { DataStream, DataType, MinimalStaticViewport, MinimalViewPortConfig } fr export const isDefined = (value: T | null | undefined): value is T => value != null; -export const isValid = (predicate: (t: Partial) => boolean) => (t: Partial): t is T => predicate(t); +export const isValid = + (predicate: (t: Partial) => boolean) => + (t: Partial): t is T => + predicate(t); // As of now, we only check if the current component supports string or not. -export const isSupportedDataType = (supportsString: boolean) => ({ dataType }: { dataType: DataType }) => - (supportsString && dataType === DataType.STRING) || dataType !== DataType.STRING; +export const isSupportedDataType = + (supportsString: boolean) => + ({ dataType }: { dataType: DataType }) => + (supportsString && dataType === DataType.STRING) || dataType !== DataType.STRING; export const isNumberDataStream = (stream: DataStream): stream is DataStream => stream.dataType === DataType.NUMBER; diff --git a/packages/core/src/common/tests/util.ts b/packages/core/src/common/tests/util.ts index a3db0927c..793a70f86 100644 --- a/packages/core/src/common/tests/util.ts +++ b/packages/core/src/common/tests/util.ts @@ -6,7 +6,7 @@ export const createSiteWiseSDK = ({ getAssetPropertyValueHistory = jest.fn(), getInterpolatedAssetPropertyValues = jest.fn(), }) => - (({ + ({ send: (command: { input: Object }) => { // Mocks out the process of a sending a command within the JS AWS-SDK v3, learn more at // https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/index.html#high-level-concepts @@ -27,4 +27,4 @@ export const createSiteWiseSDK = ({ ); } }, - } as unknown) as IoTSiteWiseClient); + } as unknown as IoTSiteWiseClient); diff --git a/packages/core/src/data-module/data-cache/dataCacheWrapped.ts b/packages/core/src/data-module/data-cache/dataCacheWrapped.ts index e332936b0..8e0213c6b 100644 --- a/packages/core/src/data-module/data-cache/dataCacheWrapped.ts +++ b/packages/core/src/data-module/data-cache/dataCacheWrapped.ts @@ -93,16 +93,20 @@ export class DataCache { * coordinating the dispatching of the action throughout the file. */ - public onSuccess = (queryConfig: TimeSeriesDataRequest) => (dataStreams: DataStream[]): void => { - const queryStart: Date = viewportStartDate(queryConfig.viewport); - const queryEnd: Date = viewportEndDate(queryConfig.viewport); - - // TODO: `duration` is not an accurate way to determine what _was_ requested. - // Need to change then code to utilize the actual start and end date, as utilized by the data source which initiated the request. - // For example, if we have queried data for the last day, but it took 1 minute for the query to resolve, we would have the start and the end date - // incorrectly offset by one minute with the correct logic. - dataStreams.forEach((stream) => this.dataCache.dispatch(onSuccessAction(stream.id, stream, queryStart, queryEnd))); - }; + public onSuccess = + (queryConfig: TimeSeriesDataRequest) => + (dataStreams: DataStream[]): void => { + const queryStart: Date = viewportStartDate(queryConfig.viewport); + const queryEnd: Date = viewportEndDate(queryConfig.viewport); + + // TODO: `duration` is not an accurate way to determine what _was_ requested. + // Need to change then code to utilize the actual start and end date, as utilized by the data source which initiated the request. + // For example, if we have queried data for the last day, but it took 1 minute for the query to resolve, we would have the start and the end date + // incorrectly offset by one minute with the correct logic. + dataStreams.forEach((stream) => + this.dataCache.dispatch(onSuccessAction(stream.id, stream, queryStart, queryEnd)) + ); + }; public onError = ({ id, resolution, error }: { id: string; resolution: Resolution; error: string }): void => { this.dataCache.dispatch(onErrorAction(id, resolution, error)); diff --git a/packages/core/src/data-module/data-cache/dataReducer.spec.ts b/packages/core/src/data-module/data-cache/dataReducer.spec.ts index 98ca2a1fe..49fba7195 100755 --- a/packages/core/src/data-module/data-cache/dataReducer.spec.ts +++ b/packages/core/src/data-module/data-cache/dataReducer.spec.ts @@ -407,10 +407,7 @@ it('merges data into existing data cache', () => { name: 'some name', id: ID, aggregates: { - [SECOND_IN_MS]: [ - NEWER_DATA_POINT_1, - OLDER_DATA_POINT_2 - ], + [SECOND_IN_MS]: [NEWER_DATA_POINT_1, OLDER_DATA_POINT_2], }, data: [], resolution: SECOND_IN_MS, diff --git a/packages/core/src/data-module/data-cache/toDataStreams.ts b/packages/core/src/data-module/data-cache/toDataStreams.ts index e5e541afa..b28459a14 100755 --- a/packages/core/src/data-module/data-cache/toDataStreams.ts +++ b/packages/core/src/data-module/data-cache/toDataStreams.ts @@ -19,7 +19,7 @@ export const toDataStreams = ({ const streamsResolutions = dataStreamsStores[info.id] || {}; const resolutions = Object.keys(streamsResolutions); const aggregatedData = resolutions - .map((resolution) => streamsResolutions[(resolution as unknown) as number]) + .map((resolution) => streamsResolutions[resolution as unknown as number]) .filter(isDefined) .filter(({ resolution }) => resolution > 0); diff --git a/packages/related-table/src/HOC/withUseTreeCollection.tsx b/packages/related-table/src/HOC/withUseTreeCollection.tsx index fa0932691..c35ee9a15 100644 --- a/packages/related-table/src/HOC/withUseTreeCollection.tsx +++ b/packages/related-table/src/HOC/withUseTreeCollection.tsx @@ -26,7 +26,13 @@ export const withUseTreeCollection = (RelatedTableComp: React.FC) => { onSortingChange, onSelectionChange, } = wrapperProps; - const { expandNode, items: tree, collectionProps, filterProps, paginationProps } = useTreeCollection(items, { + const { + expandNode, + items: tree, + collectionProps, + filterProps, + paginationProps, + } = useTreeCollection(items, { ...collectionOptions, columnDefinitions, });