Skip to content

Commit

Permalink
fix: remove prettier, enforce eslint on build (#29)
Browse files Browse the repository at this point in the history
* apply linting
  • Loading branch information
diehbria committed Jan 18, 2022
1 parent 2b5fdf5 commit 225afef
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 95 deletions.
8 changes: 0 additions & 8 deletions .prettierignore

This file was deleted.

Empty file modified .prettierrc
100755 → 100644
Empty file.
12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class IotConnector {
this.update({
request: {
...this.request,
viewport: {start, end, lastUpdatedBy}
viewport: { start, end, lastUpdatedBy },
},
});
}
Expand Down
48 changes: 20 additions & 28 deletions packages/core/src/asset-modules/sitewise/requestProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AssetSummaryQuery, AssetSummary>(
(query) => this.assetSummaryWorkerFactory(query),
(query) => query.assetId
);
private readonly assetSummaryWorkers: RequestProcessorWorkerGroup<AssetSummaryQuery, AssetSummary> =
new RequestProcessorWorkerGroup<AssetSummaryQuery, AssetSummary>(
(query) => this.assetSummaryWorkerFactory(query),
(query) => query.assetId
);

private readonly assetModelWorkers: RequestProcessorWorkerGroup<
AssetModelQuery,
DescribeAssetModelResponse
> = new RequestProcessorWorkerGroup<AssetModelQuery, DescribeAssetModelResponse>(
(query) => this.assetModelWorkerFactory(query),
(query) => query.assetModelId
);
private readonly assetModelWorkers: RequestProcessorWorkerGroup<AssetModelQuery, DescribeAssetModelResponse> =
new RequestProcessorWorkerGroup<AssetModelQuery, DescribeAssetModelResponse>(
(query) => this.assetModelWorkerFactory(query),
(query) => query.assetModelId
);

private readonly assetPropertyValueWorkers: RequestProcessorWorkerGroup<
AssetPropertyValueQuery,
AssetPropertyValue
> = new RequestProcessorWorkerGroup<AssetPropertyValueQuery, AssetPropertyValue>(
(query) => this.assetPropertyValueWorkerFactory(query),
(query) => query.assetId + ':' + query.propertyId
);
private readonly assetPropertyValueWorkers: RequestProcessorWorkerGroup<AssetPropertyValueQuery, AssetPropertyValue> =
new RequestProcessorWorkerGroup<AssetPropertyValueQuery, AssetPropertyValue>(
(query) => this.assetPropertyValueWorkerFactory(query),
(query) => query.assetId + ':' + query.propertyId
);

private readonly hierarchyWorkers: RequestProcessorWorkerGroup<
AssetHierarchyQuery,
HierarchyAssetSummaryList
> = new RequestProcessorWorkerGroup<AssetHierarchyQuery, HierarchyAssetSummaryList>(
(query) => this.loadHierarchyWorkerFactory(query),
(query) => assetHierarchyQueryKey(query)
);
private readonly hierarchyWorkers: RequestProcessorWorkerGroup<AssetHierarchyQuery, HierarchyAssetSummaryList> =
new RequestProcessorWorkerGroup<AssetHierarchyQuery, HierarchyAssetSummaryList>(
(query) => this.loadHierarchyWorkerFactory(query),
(query) => assetHierarchyQueryKey(query)
);

constructor(api: SiteWiseAssetDataSource, cache: SiteWiseAssetCache) {
this.api = api;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,35 +213,32 @@ it('producers can run a finalizer when the last subscriber unsubscribes', (done)
let workerGroup: RequestProcessorWorkerGroup<string, number>;

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<string, number>(
(query) => {
let timeoutID: any;
let counter = 0;
return new Observable<number>((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<string, number>((query) => {
let timeoutID: any;
let counter = 0;
return new Observable<number>((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);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/common/predicates.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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();
});
});
11 changes: 8 additions & 3 deletions packages/core/src/common/predicates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ import { DataStream, DataType, MinimalStaticViewport, MinimalViewPortConfig } fr

export const isDefined = <T>(value: T | null | undefined): value is T => value != null;

export const isValid = <T>(predicate: (t: Partial<T>) => boolean) => (t: Partial<T>): t is T => predicate(t);
export const isValid =
<T>(predicate: (t: Partial<T>) => boolean) =>
(t: Partial<T>): 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<number> =>
stream.dataType === DataType.NUMBER;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/common/tests/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,4 +27,4 @@ export const createSiteWiseSDK = ({
);
}
},
} as unknown) as IoTSiteWiseClient);
} as unknown as IoTSiteWiseClient);
24 changes: 14 additions & 10 deletions packages/core/src/data-module/data-cache/dataCacheWrapped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/data-module/data-cache/dataReducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/data-module/data-cache/toDataStreams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 7 additions & 1 deletion packages/related-table/src/HOC/withUseTreeCollection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ export const withUseTreeCollection = (RelatedTableComp: React.FC<any>) => {
onSortingChange,
onSelectionChange,
} = wrapperProps;
const { expandNode, items: tree, collectionProps, filterProps, paginationProps } = useTreeCollection(items, {
const {
expandNode,
items: tree,
collectionProps,
filterProps,
paginationProps,
} = useTreeCollection(items, {
...collectionOptions,
columnDefinitions,
});
Expand Down

0 comments on commit 225afef

Please sign in to comment.