Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6f20b9b
use eslint
redallen Jan 28, 2020
6b04be4
tweak config
redallen Jan 28, 2020
083578a
tweak config
redallen Jan 28, 2020
0ecfc1b
fix(docs): fixed eslintrc error
evwilkin Jan 28, 2020
2b399d5
fix(docs): lint:ts --fix
evwilkin Jan 28, 2020
df87c32
fix(docs): eslint errors
evwilkin Jan 30, 2020
d7d27be
fix(docs): more eslint errors
evwilkin Jan 30, 2020
70dc57b
fix(docs): fix more eslint errors
evwilkin Jan 30, 2020
2866acf
fix(docs): fixed last eslint error
evwilkin Jan 31, 2020
ce475bd
fix(docs): fix TS errors
evwilkin Jan 31, 2020
3d0f480
fix(docs): fixed DataToolbar tsc error
evwilkin Jan 31, 2020
d394800
fix(docs): topologycontrolbar tsc error
evwilkin Jan 31, 2020
1adacd1
fix(docs): topologysidebar tsc error
evwilkin Jan 31, 2020
dbbd385
fix(docs): updated snapshot
evwilkin Jan 31, 2020
8ecc569
fix(docs): updated snapshot
evwilkin Jan 31, 2020
7fb7bad
fix(docs): working through gutters type errors
evwilkin Feb 4, 2020
d796a7b
fix(docs): fixing Gallery ts error
evwilkin Feb 4, 2020
6a977eb
fix(lint): fixed linting errors
evwilkin Feb 4, 2020
0e04e69
fix(eslint): committing yarn lock
evwilkin Feb 5, 2020
1c7ee5e
merge yarn.lock
evwilkin Feb 5, 2020
2acf2ea
fix(eslint): fixed additional linting errors
evwilkin Feb 5, 2020
bae18cf
fix(DataListItem): fixed a11y aria-selected issue
evwilkin Feb 5, 2020
bc98e7c
fix(lint): update lint:ts for react-table
evwilkin Feb 6, 2020
193481e
fix(lint): resolved eslint errors in react-table
evwilkin Feb 6, 2020
54a4835
fix(react-tables): resolved eslint errors
evwilkin Feb 6, 2020
bd51f63
fix(react-tables): fixed merge conflicts
evwilkin Feb 6, 2020
190c1d5
updated lint:md to target only react-core
evwilkin Feb 6, 2020
7985b41
resolved feedback
evwilkin Feb 10, 2020
f8e4475
fixed a11y error
evwilkin Feb 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"clean:build": "shx rm -rf .cache",
"commit": "git-cz",
"generate": "yarn plop",
"lint:md": "yarn eslintpackages/patternfly-4 --ext md --config .eslintrc-md.json",
"lint:md": "yarn eslint packages/patternfly-4/react-core --ext md --config .eslintrc-md.json",
"lint:style": "stylelint \"**/sass/**/*.scss\" \"!**/dist/**/*.scss\"",
"lint:ts": "node --max-old-space-size=4096 node_modules/.bin/eslint packages/patternfly-4/react-core --ext js,jsx,ts,tsx",
"lint:versions": "node ./packages/patternfly-4/verifyCoreVersions.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ class DataToolbarStacked extends React.Component {
onSelect={this.onSplitButtonSelect}
toggle={(
<DropdownToggle
id="stacked-example-toggle"
splitButtonItems={[
<DropdownToggleCheckbox
id="example-checkbox-1"
Expand Down
4 changes: 3 additions & 1 deletion packages/patternfly-4/react-table/build/copyStyles.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable no-case-declarations */
/* eslint-disable @typescript-eslint/no-var-requires */
const { copySync, readFileSync, writeFileSync } = require('fs-extra');
const { resolve, dirname, join } = require('path');
const { parse: parseCSS, stringify: stringifyCSS } = require('css');
/* eslint-enable @typescript-eslint/no-var-requires */

const baseCSSFilename = 'patternfly-base.css';
const stylesDir = resolve(__dirname, '../dist/styles');
Expand All @@ -26,6 +27,7 @@ ast.stylesheet.rules = ast.stylesheet.rules.filter(rule => {
case 'comment':
return false;
case 'font-face':
// eslint-disable-next-line no-case-declarations
const fontFamilyDecl = rule.declarations.find(decl => decl.property === 'font-family');
return !unusedFontFamilyRegEx.test(fontFamilyDecl.value);
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const { createSerializer } = require('@patternfly/react-styles/snapshot-serializer');
/* eslint-enable @typescript-eslint/no-var-requires */

const pf4CSS = fs.readFileSync(require.resolve('@patternfly/react-styles/css/patternfly-base.css'), 'utf8');

Expand Down
2 changes: 2 additions & 0 deletions packages/patternfly-4/react-table/scripts/copyTS.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const glob = require('glob');
const fse = require('fs-extra');
/* eslint-enable @typescript-eslint/no-var-requires */

const srcDir = path.join('./src');
const distDir = path.join('./dist/js');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as React from 'react';
import { Dropdown } from '@patternfly/react-core/dist/js/components/Dropdown/Dropdown';
import { DropdownPosition, DropdownDirection } from '@patternfly/react-core/dist/js/components/Dropdown/dropdownConstants';
import {
DropdownPosition,
DropdownDirection
} from '@patternfly/react-core/dist/js/components/Dropdown/dropdownConstants';
import { KebabToggle } from '@patternfly/react-core/dist/js/components/Dropdown/KebabToggle';
import { DropdownItem } from '@patternfly/react-core/dist/js/components/Dropdown/DropdownItem';
import { DropdownSeparator } from '@patternfly/react-core/dist/js/components/Dropdown/DropdownSeparator';
Expand Down
14 changes: 10 additions & 4 deletions packages/patternfly-4/react-table/src/components/Table/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RowType, RowKeyType } from './base/types';
import { TableContext, IRow, IRowCell, IExtraRowData } from './Table';
import { isRowExpanded } from './utils';

// eslint-disable-next-line @typescript-eslint/interface-name-prefix
export interface IComputedData {
isInput: boolean;
isButton: boolean;
Expand Down Expand Up @@ -90,6 +91,7 @@ class ContextBody extends React.Component<TableBodyProps, {}> {
};

render() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { className, headerData, rows, rowKey, children, onRowClick, ...props } = this.props;

let mappedRows;
Expand Down Expand Up @@ -125,11 +127,14 @@ class ContextBody extends React.Component<TableBodyProps, {}> {
}

export const TableBody = ({
onRow = (...args: any) => Object,
className = '' as string,
children = null as React.ReactNode,
rowKey = 'id' as string,
onRowClick = (event: React.MouseEvent, row: IRow, rowProps: IExtraRowData, computedData: IComputedData) => undefined as OnRowClick,
/* eslint-disable @typescript-eslint/no-unused-vars */
onRow = (...args: any) => Object,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onRow and onRowClick appear to be used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both onRow and onRowClick were throwing TS errors - it looks like the unused variable errors were for the arguments to both functions (...args for onRow, and event/row/rowProps/computedData for onRowClick)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we track down how onRow is used and give it a proper type?

Also, for the unused variables, just put underscores before the variable names. Like _event: React.MouseEvent. Then you can remove the eslint-disable.

onRowClick = (event: React.MouseEvent, row: IRow, rowProps: IExtraRowData, computedData: IComputedData) =>
/* eslint-enable @typescript-eslint/no-unused-vars */
undefined as OnRowClick,
...props
}: TableBodyProps) => (
<TableContext.Consumer>
Expand All @@ -139,12 +144,13 @@ export const TableBody = ({
rows={rows as IRow[]}
onRow={onRow}
className={className}
children={children}
rowKey={rowKey}
onRowClick={onRowClick}
{...props}
{...rest}
/>
>
{children}
</ContextBody>
)}
</TableContext.Consumer>
);
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ export const BodyCell: React.FunctionComponent<BodyCellProps> = ({
isVisible,
parentId,
textCenter = false,
/* eslint-disable @typescript-eslint/no-unused-vars */
isOpen,
ariaControls = '',
ariaControls,
/* eslint-enable @typescript-eslint/no-unused-vars */
...props
}: BodyCellProps) => {
const Component = component as any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ export interface BodyWrapperProps {

export const BodyWrapper: React.FunctionComponent<BodyWrapperProps> = ({
mappedRows,
tbodyRef,
/* eslint-disable @typescript-eslint/no-unused-vars */
rows = [] as IRow[],
onCollapse,
tbodyRef,
headerRows,
/* eslint-enable @typescript-eslint/no-unused-vars */
...props
}: BodyWrapperProps) => {
if (mappedRows && mappedRows.some(row => row.hasOwnProperty('parent'))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,20 @@ export const CollapseColumn: React.FunctionComponent<CollapseColumnProps> = ({
isOpen,
onToggle,
...props
}: CollapseColumnProps) => {
return (
<React.Fragment>
{isOpen !== undefined && (
<Button
className={css(className, isOpen && styles.modifiers.expanded)}
{...props}
variant="plain"
aria-label="Details"
onClick={onToggle}
aria-expanded={isOpen}
>
<AngleDownIcon />
</Button>
)}
{children}
</React.Fragment>
);
};
}: CollapseColumnProps) => (
<React.Fragment>
{isOpen !== undefined && (
<Button
className={css(className, isOpen && styles.modifiers.expanded)}
{...props}
variant="plain"
aria-label="Details"
onClick={onToggle}
aria-expanded={isOpen}
>
<AngleDownIcon />
</Button>
)}
{children}
</React.Fragment>
);
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ interface ExpandableRowContentProps {
export const ExpandableRowContent: React.FunctionComponent<ExpandableRowContentProps> = ({
children = null as React.ReactNode,
...props
}: ExpandableRowContentProps) => {
return (
<div {...props} className={css(styles.tableExpandableRowContent)}>
{children}
</div>
);
};
}: ExpandableRowContentProps) => (
<div {...props} className={css(styles.tableExpandableRowContent)}>
{children}
</div>
);
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ export interface HeaderCellProps {
export const HeaderCell: React.FunctionComponent<HeaderCellProps> = ({
className = '',
component = 'th',
isVisible,
scope = '',
textCenter = false,
/* eslint-disable @typescript-eslint/no-unused-vars */
isVisible,
dataLabel = '',
/* eslint-enable @typescript-eslint/no-unused-vars */
...props
}: HeaderCellProps) => {
const Component = component as any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ class RowWrapper extends React.Component<RowWrapperProps & InjectedOuiaProps, {}

render() {
const {
trRef,
className,
/* eslint-disable @typescript-eslint/no-unused-vars */
onScroll,
onResize,
row: { isExpanded, isHeightAuto },
rowProps,
/* eslint-enable @typescript-eslint/no-unused-vars */
trRef,
className,
row: { isExpanded, isHeightAuto },
ouiaContext,
ouiaId,
...props
Expand All @@ -104,10 +106,10 @@ class RowWrapper extends React.Component<RowWrapperProps & InjectedOuiaProps, {}
isHeightAuto && styles.modifiers.heightAuto
)}
hidden={isExpanded !== undefined && !isExpanded}
{...ouiaContext.isOuia && {
{...(ouiaContext.isOuia && {
'data-ouia-component-type': 'TableRow',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
}}
})}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ export interface SelectColumnProps {

export const SelectColumn: React.FunctionComponent<SelectColumnProps> = ({
children = null as React.ReactNode,
className = '',
onSelect = null as (event: React.ChangeEvent<HTMLInputElement>) => void,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
className,
...props
}: SelectColumnProps) => {
return (
<React.Fragment>
<input {...props} type="checkbox" onChange={onSelect} />
{children}
</React.Fragment>
);
};
}: SelectColumnProps) => (
<React.Fragment>
<input {...props} type="checkbox" onChange={onSelect} />
{children}
</React.Fragment>
);
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ test('Sortable table', () => {
test('Row click table', () => {
const rowClickHandler = jest.fn();
const view = mount(
<Table
aria-label="Row click table"
cells={columns}
rows={rows}
>
<Table aria-label="Row click table" cells={columns} rows={rows}>
<TableHeader />
<TableBody onRowClick={rowClickHandler} />
</Table>
Expand Down Expand Up @@ -257,12 +253,12 @@ test('Empty state table', () => {
heightAuto: true,
cells: [
{
title: (<div>Empty State Component</div>),
title: <div>Empty State Component</div>,
props: { colSpan: '8' }
}
],
]
}
],
]
};

const view = mount(
Expand All @@ -272,6 +268,16 @@ test('Empty state table', () => {
</Table>
);

expect(view.find('tr').at(1).prop('className')).toEqual('pf-m-height-auto');
expect(view.find('tbody').find('td').prop('colSpan')).toEqual('8');
expect(
view
.find('tr')
.at(1)
.prop('className')
).toEqual('pf-m-height-auto');
expect(
view
.find('tbody')
.find('td')
.prop('colSpan')
).toEqual('8');
});
Loading