Skip to content

Commit

Permalink
chore: lint forms
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfrancois committed Oct 12, 2023
1 parent c72ba53 commit 9528a05
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 56 deletions.
1 change: 1 addition & 0 deletions packages/forms/src/UIForm/Widget/Widget.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import shouldRender from '../utils/condition';
import theme from './Widget.component.module.scss';
import { useWidget } from '../context';

// eslint-disable-next-line @typescript-eslint/default-param-last
function isUpdating(updatingKeys = [], key) {
if (updatingKeys.length === 0 || !key) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class Datalist extends Component {
{...this.state}
dataFeature={this.props.schema.dataFeature}
className="form-control-container"
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={this.props.schema.autoFocus}
disabled={this.props.schema.disabled || this.props.valueIsUpdating}
multiSection={get(this.props, 'schema.options.isMultiSection', false)}
Expand Down
1 change: 1 addition & 0 deletions packages/forms/src/UIForm/fields/Date/Date.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function DateWidget(props) {
valueIsUpdating={valueIsUpdating}
>
<InputDatePicker
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={schema.autoFocus}
dateFormat={options.dateFormat}
disabled={schema.disabled || valueIsUpdating}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function DateTimeWidget(props) {
>
<InputDateTimePicker
id={id}
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={schema.autoFocus}
disabled={schema.disabled || valueIsUpdating}
readOnly={schema.readOnly}
Expand Down
1 change: 1 addition & 0 deletions packages/forms/src/UIForm/fields/Date/Time.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function TimeWidget({
>
<InputTimePicker
id={id}
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={schema.autoFocus}
disabled={schema.disabled || valueIsUpdating}
readOnly={schema.readOnly}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export default class MultiSelectTag extends Component {
<FocusManager onFocusOut={this.resetSuggestions} className={theme['focus-manager']}>
<Typeahead
id={id}
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={schema.autoFocus || false}
disabled={schema.disabled || valueIsUpdating}
focusedItemIndex={this.state.focusedItemIndex}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,56 @@ import userEvent from '@testing-library/user-event';

import ResourcePicker from './ResourcePicker.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');
jest.mock(
'@talend/react-components/lib/ResourcePicker',
const ResourcePickerMock =
() =>
({ toolbar, onRowClick, isSelected, collection, ...props }) =>
(
<div data-testid="ResourcePicker" data-props={JSON.stringify(props, null, 2)}>
<div data-testid="toolbar" data-props={JSON.stringify(toolbar, null, 2)}>
<div>
<label htmlFor="toolbar-name">{toolbar.name.label}</label>
<input
id="toolbar-name"
type="text"
onChange={e => toolbar.name.onChange(e)}
value={toolbar.name.value}
/>
</div>
<div className="tc-resource-picker-state-filters">
<button onClick={() => toolbar.state.onChange('selection', true)}>
state filter
</button>
<button onClick={() => toolbar.state.onChange('certified', true)}>
certified filter
</button>
<button onClick={() => toolbar.state.onChange('favorites', true)}>
favorites filter
</button>
</div>
<div className="tc-resource-picker-sort-options">
<button onClick={() => toolbar.sort.onChange('name', 'asc')}>sort by name</button>
<button onClick={() => toolbar.sort.onChange('date', 'asc')}>sort by date</button>

<button onClick={() => toolbar.sort.onChange('name', 'desc')}>
sort by name desc
</button>
<button onClick={() => toolbar.sort.onChange('date', 'desc')}>
sort by date desc
</button>
</div>
</div>
<button type="button" onClick={e => onRowClick(e, { id: '0' })}>
onRowClick
</button>
<button type="button" onClick={e => onRowClick(e, { id: '1' })}>
onRowClick first
({ toolbar, onRowClick, isSelected, collection, ...props }) => (
<div data-testid="ResourcePicker" data-props={JSON.stringify(props, null, 2)}>
<div data-testid="toolbar" data-props={JSON.stringify(toolbar, null, 2)}>
<div>
<label htmlFor="toolbar-name">{toolbar.name.label}</label>
<input
id="toolbar-name"
type="text"
onChange={e => toolbar.name.onChange(e)}
value={toolbar.name.value}
/>
</div>
<div className="tc-resource-picker-state-filters">
<button onClick={() => toolbar.state.onChange('selection', true)}>state filter</button>
<button onClick={() => toolbar.state.onChange('certified', true)}>
certified filter
</button>
<button type="button" onClick={e => isSelected(e)}>
isSelected
<button onClick={() => toolbar.state.onChange('favorites', true)}>
favorites filter
</button>
{collection && (
<span
data-testid="collection"
data-collection={JSON.stringify(collection, null, 2)}
></span>
)}
ResourcePicker
</div>
),
);
<div className="tc-resource-picker-sort-options">
<button onClick={() => toolbar.sort.onChange('name', 'asc')}>sort by name</button>
<button onClick={() => toolbar.sort.onChange('date', 'asc')}>sort by date</button>

<button onClick={() => toolbar.sort.onChange('name', 'desc')}>sort by name desc</button>
<button onClick={() => toolbar.sort.onChange('date', 'desc')}>sort by date desc</button>
</div>
</div>
<button type="button" onClick={e => onRowClick(e, { id: '0' })}>
onRowClick
</button>
<button type="button" onClick={e => onRowClick(e, { id: '1' })}>
onRowClick first
</button>
<button type="button" onClick={e => isSelected(e)}>
isSelected
</button>
{collection && (
<span data-testid="collection" data-collection={JSON.stringify(collection, null, 2)}></span>
)}
ResourcePicker
</div>
);

jest.mock('ally.js');
jest.unmock('@talend/design-system');
jest.mock('@talend/react-components/lib/ResourcePicker', ResourcePickerMock);

describe('ResourcePicker field', () => {
const collection = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function ToggleWidget(props) {
valueIsUpdating={valueIsUpdating}
>
<Toggle
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={autoFocus}
checked={value}
disabled={disabled || valueIsUpdating}
Expand Down
1 change: 1 addition & 0 deletions packages/forms/src/UIForm/utils/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function convertValue(type, value) {
* @param {any} value The value to set
* @returns {object} The new mutated properties.
*/
// eslint-disable-next-line @typescript-eslint/default-param-last
function mutateValueFromKey(properties = {}, key, value) {
if (!key || !key.length) {
return value;
Expand Down

0 comments on commit 9528a05

Please sign in to comment.