From ed6e1d1a0b984dead09b29a17817992d7b7652d7 Mon Sep 17 00:00:00 2001 From: Evan Date: Mon, 17 Feb 2020 12:44:51 -0500 Subject: [PATCH] chore(react-virtualized-extension): resolved linter errors (#3726) * chore(react-virtualized-extension): resolved linter errors * updated circleci caching * resolved PR feedback * removed no-var-requires and no-use-before-define inline comments --- .circleci/config.yml | 2 +- package.json | 2 +- .../Virtualized/VirtualizedTable.test.tsx | 21 ++++++++----------- .../accessibilityOverscanIndicesGetter.ts | 3 +++ .../defaultOverscanIndicesGetter.ts | 3 +++ ...izeAndPositionDataAndUpdateScrollOffset.ts | 3 +++ .../utils/createCallbackMemoizer.ts | 4 +++- .../utils/requestAnimationTimeout.ts | 4 ++++ .../utils/updateScrollIndexHelper.ts | 3 +++ .../src/declarations.d.ts | 2 +- 10 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a08ed15eba1..4ac05e54cb8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,7 +57,7 @@ references: build_cache_key: &build_cache_key build-cache-v{{.Environment.CACHE_VERSION}}-{{checksum "yarn.lock"}} lint_cache_key: &lint_cache_key - lint-cache-v{{.Environment.CACHE_VERSION}} + lint-cache-v{{.Environment.CACHE_VERSION}}-{{checksum "package.json"}} attach_workspace: &attach_workspace attach_workspace: at: ~/project diff --git a/package.json b/package.json index 7dc4becb4d2..5fc65e6e73a 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "generate": "yarn plop", "lint:md": "yarn eslint packages/patternfly-4 --ext md --no-eslintrc --config .eslintrc-md.json --cache", "lint:style": "stylelint \"**/sass/**/*.scss\" \"!**/dist/**/*.scss\"", - "lint:ts": "node --max-old-space-size=4096 node_modules/.bin/eslint packages/patternfly-4/react-core packages/patternfly-4/react-table packages/patternfly-4/react-topology packages/patternfly-4/react-catalog-view-extension packages/patternfly-4/react-docs packages/patternfly-4/react-inline-edit-extension packages/patternfly-4/react-charts packages/patternfly-4/react-integration packages/patternfly-4/react-styled-system packages/patternfly-4/react-styles packages/patternfly-4/react-tokens --ext js,jsx,ts,tsx --cache", + "lint:ts": "node --max-old-space-size=4096 node_modules/.bin/eslint packages/patternfly-4/react-core packages/patternfly-4/react-table packages/patternfly-4/react-topology packages/patternfly-4/react-catalog-view-extension packages/patternfly-4/react-docs packages/patternfly-4/react-inline-edit-extension packages/patternfly-4/react-charts packages/patternfly-4/react-integration packages/patternfly-4/react-styled-system packages/patternfly-4/react-styles packages/patternfly-4/react-tokens packages/patternfly-4/react-virtualized-extension --ext js,jsx,ts,tsx --cache", "lint:versions": "node ./packages/patternfly-4/verifyCoreVersions.js", "prettier": "node node_modules/.bin/prettier --write \"storybook/**/*.{js,ts,tsx}\" \"packages/**/*.{js,ts,tsx}\" \"scripts/**/*.{js,ts,tsx}\"", "serve:docs": "lerna run serve", diff --git a/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/VirtualizedTable.test.tsx b/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/VirtualizedTable.test.tsx index 769f9fb5b10..ee05c9661a0 100644 --- a/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/VirtualizedTable.test.tsx +++ b/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/VirtualizedTable.test.tsx @@ -1,14 +1,11 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as React from 'react'; import clsx from 'clsx'; import { mount } from 'enzyme'; -import { - Table, - TableHeader, - sortable -} from '@patternfly/react-table'; +import { Table, TableHeader, sortable } from '@patternfly/react-table'; import { VirtualTableBody } from './index'; import { rows, columns, actions } from '@patternfly/react-table/src/test-helpers/data-sets'; -import { CellMeasurerCache, CellMeasurer } from 'react-virtualized'; +import { CellMeasurerCache } from 'react-virtualized'; const measurementCache = new CellMeasurerCache({ fixedWidth: true, @@ -17,7 +14,7 @@ const measurementCache = new CellMeasurerCache({ }); describe('Simple virtualized table', () => { - const rowRenderer = ( index: number , isVisible: boolean ) => { + const rowRenderer = (index: number, isVisible: boolean) => { const text = rows[index].cells[0]; const className = clsx({ @@ -67,7 +64,7 @@ describe('Simple virtualized table', () => { }); test('Sortable Virtualized Table', () => { - const rowRenderer = ( index: number , isVisible: boolean ) => { + const rowRenderer = (index: number, isVisible: boolean) => { const text = rows[index].cells[0]; const className = clsx({ @@ -96,7 +93,7 @@ test('Sortable Virtualized Table', () => { }); test('Simple Actions table', () => { - const rowRenderer = ( index: number , isVisible: boolean ) => { + const rowRenderer = (index: number, isVisible: boolean) => { const text = rows[index].cells[0]; const className = clsx({ @@ -133,7 +130,7 @@ test('Simple Actions table', () => { }); test('Actions virtualized table', () => { - const rowRenderer = ( index: number , isVisible: boolean ) => { + const rowRenderer = (index: number, isVisible: boolean) => { const text = rows[index].cells[0]; const className = clsx({ @@ -168,7 +165,7 @@ test('Actions virtualized table', () => { }); test('Selectable virtualized table', () => { - const rowRenderer = ( index: number , isVisible: boolean ) => { + const rowRenderer = (index: number, isVisible: boolean) => { const text = rows[index].cells[0]; const className = clsx({ @@ -180,7 +177,7 @@ test('Selectable virtualized table', () => { const view = mount( - {( width: number ) => ( + {(width: number) => ( { updateScrollOffsetForScrollToIndex: () => void; } +/** + * + */ export default function calculateSizeAndPositionDataAndUpdateScrollOffset({ cellCount, cellSize, diff --git a/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/utils/createCallbackMemoizer.ts b/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/utils/createCallbackMemoizer.ts index 1e7cd77a662..1e7c671fdc3 100644 --- a/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/utils/createCallbackMemoizer.ts +++ b/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/utils/createCallbackMemoizer.ts @@ -1,10 +1,12 @@ /** * Helper utility that updates the specified callback whenever any of the specified indices have changed. + * + * @param {boolean} requireAllKeys - Require all keys */ export default function createCallbackMemoizer(requireAllKeys = true) { let cachedIndices: any = {}; - return ({callback, indices }: { callback: any, indices: any}) => { + return ({ callback, indices }: { callback: any; indices: any }) => { const keys = Object.keys(indices); const allInitialized = !requireAllKeys || diff --git a/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/utils/requestAnimationTimeout.ts b/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/utils/requestAnimationTimeout.ts index 58009f6ded9..e224c0b13df 100644 --- a/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/utils/requestAnimationTimeout.ts +++ b/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/utils/requestAnimationTimeout.ts @@ -15,10 +15,14 @@ export const cancelAnimationTimeout: any = (frame: { id: any }) => caf(frame.id) * When the delay time has been reached the function you're timing out will be called. * * Credit: Joe Lambert (https://gist.github.com/joelambert/1002116#file-requesttimeout-js) + * + * @param {any} callback - callback + * @param {number} delay - delay number */ export const requestAnimationTimeout = (callback: any, delay: number) => { let start: any; // wait for end of processing current event handler, because event handler may be long + // eslint-disable-next-line no-undef Promise.resolve().then(() => { start = Date.now(); }); diff --git a/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/utils/updateScrollIndexHelper.ts b/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/utils/updateScrollIndexHelper.ts index e55c62190b5..6702b2c761e 100644 --- a/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/utils/updateScrollIndexHelper.ts +++ b/packages/patternfly-4/react-virtualized-extension/src/components/Virtualized/utils/updateScrollIndexHelper.ts @@ -45,6 +45,9 @@ interface Params { updateScrollIndexCallback: (index: number) => void; } +/** + * + */ export default function updateScrollIndexHelper({ cellSize, cellSizeAndPositionManager, diff --git a/packages/patternfly-4/react-virtualized-extension/src/declarations.d.ts b/packages/patternfly-4/react-virtualized-extension/src/declarations.d.ts index 69d7a61821f..42946d05aa7 100644 --- a/packages/patternfly-4/react-virtualized-extension/src/declarations.d.ts +++ b/packages/patternfly-4/react-virtualized-extension/src/declarations.d.ts @@ -1 +1 @@ -declare module 'linear-layout-vector'; \ No newline at end of file +declare module 'linear-layout-vector';