Add comma-dangle requirement for eslint

This commit is contained in:
Eric Schultz 2020-09-30 12:05:22 -05:00 committed by Eric Schultz
parent a1d03618b9
commit 0f0a0d2063
9 changed files with 47 additions and 47 deletions

View file

@ -6,16 +6,16 @@ const tsSpecBase = {
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
plugins: [ plugins: [
'@typescript-eslint', '@typescript-eslint',
'jest' 'jest',
], ],
extends: [ extends: [
'eslint:recommended', 'eslint:recommended',
'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended',
'plugin:jest/all' 'plugin:jest/all',
], ],
rules: { rules: {
"jest/lowercase-name": ["error", { "ignore": ["describe"] }] "jest/lowercase-name": ["error", { "ignore": ["describe"] }],
} },
}; };
@ -37,7 +37,7 @@ const tsBase = {
'eslint:recommended', 'eslint:recommended',
'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended',
"plugin:react-hooks/recommended", "plugin:react-hooks/recommended",
] ],
}; };
const tsSettings = _.cloneDeep(tsBase); const tsSettings = _.cloneDeep(tsBase);
@ -55,29 +55,30 @@ module.exports = {
"files": ['*.js', 'config/webpack/**/*.js'], "files": ['*.js', 'config/webpack/**/*.js'],
extends: [ extends: [
'eslint:recommended', 'eslint:recommended',
'plugin:node/recommended' 'plugin:node/recommended',
], ],
}, },
tsSpec, tsSpec,
tsxSpec, tsxSpec,
tsSettings, tsSettings,
tsxSettings tsxSettings,
], ],
"rules": { "rules": {
"linebreak-style": [ "linebreak-style": [
"error", "error",
"unix" "unix",
], ],
"semi": [ "semi": [
"error", "error",
"always" "always",
], ],
"no-trailing-spaces": ["error"], "no-trailing-spaces": ["error"],
"indent": ["error", "tab", {"SwitchCase": 1}], // we use tabs for accessibility "indent": ["error", "tab", {"SwitchCase": 1}], // we use tabs for accessibility
"comma-dangle": ["error", "always-multiline"],
}, },
"settings": { "settings": {
"react": { "react": {
"version": "detect" "version": "detect",
}, },
} },
}; };

View file

@ -265,7 +265,7 @@ export class Money {
toJSON(): MoneyAsJson { toJSON(): MoneyAsJson {
return { return {
amount: this.amount, amount: this.amount,
currency: this.currency currency: this.currency,
}; };
} }
} }

View file

@ -39,7 +39,7 @@ function FormikHandler(props: { value: Money, onChange:(args:{value:Money})=> vo
FormikHandler.defaultProps = { FormikHandler.defaultProps = {
// eslint-disable-next-line @typescript-eslint/no-empty-function // eslint-disable-next-line @typescript-eslint/no-empty-function
onChange: () => {} onChange: () => {},
}; };
describe('MoneyTextField', () => { describe('MoneyTextField', () => {

View file

@ -35,7 +35,7 @@ export function useSerializeMoney(props:UseSerializeMoneyProps) : ReturnType<typ
const i18n = useI18nCurrencyInput({...other, locale, const i18n = useI18nCurrencyInput({...other, locale,
currency, currency,
value:amount value:amount,
}); });

View file

@ -3,7 +3,6 @@
import { renderHook, act } from '@testing-library/react-hooks'; import { renderHook, act } from '@testing-library/react-hooks';
import useSteps, { KeyedStep, KeyedStepMap } from './useSteps'; import useSteps, { KeyedStep, KeyedStepMap } from './useSteps';
import fromPairs from 'lodash/fromPairs'; import fromPairs from 'lodash/fromPairs';
import { initial } from 'lodash';
// eslint-disable-next-line @typescript-eslint/no-empty-function // eslint-disable-next-line @typescript-eslint/no-empty-function
@ -26,7 +25,7 @@ describe('.next', () => {
it('nothing changes if next is disabled', async () => { it('nothing changes if next is disabled', async () => {
expect.assertions(2); expect.assertions(2);
const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }], ...stepActions }, { const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }], ...stepActions }, {
disabled: { 'i': false, '2': true } disabled: { 'i': false, '2': true },
})); }));
const original = result.current; const original = result.current;
act(() => { act(() => {
@ -70,7 +69,7 @@ describe('.back', () => {
expect.assertions(2); expect.assertions(2);
const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }, { key: 'last' }], ...stepActions }, { const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }, { key: 'last' }], ...stepActions }, {
activeStep: 2, activeStep: 2,
disabled: { 'i': true, '2': true, 'last': false } disabled: { 'i': true, '2': true, 'last': false },
})); }));
const original = result.current; const original = result.current;
act(() => { act(() => {
@ -85,7 +84,7 @@ describe('.back', () => {
expect.assertions(2); expect.assertions(2);
const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }, { key: 'last' }], ...stepActions }, { const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }, { key: 'last' }], ...stepActions }, {
activeStep: 1, activeStep: 1,
disabled: { 'i': true, '2': false, 'last': false } disabled: { 'i': true, '2': false, 'last': false },
})); }));
const original = result.current; const original = result.current;
act(() => { act(() => {
@ -139,7 +138,7 @@ describe('.goto', () => {
it('nothing changes if goto value is disabled', async () => { it('nothing changes if goto value is disabled', async () => {
expect.assertions(2); expect.assertions(2);
const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }], ...stepActions }, { const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }], ...stepActions }, {
disabled: { 'i': false, '2': true } disabled: { 'i': false, '2': true },
})); }));
const original = result.current; const original = result.current;
act(() => { act(() => {
@ -154,7 +153,7 @@ describe('.goto', () => {
expect.assertions(2); expect.assertions(2);
const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }], ...stepActions }, { const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }], ...stepActions }, {
activeStep: 1, activeStep: 1,
disabled: { 'i': false, '2': true } disabled: { 'i': false, '2': true },
})); }));
const original = result.current; const original = result.current;
act(() => { act(() => {
@ -197,7 +196,7 @@ describe('.first', () => {
expect.assertions(2); expect.assertions(2);
const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }], ...stepActions }, { const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }], ...stepActions }, {
activeStep: 1, activeStep: 1,
disabled: { 'i': true, '2': false } disabled: { 'i': true, '2': false },
})); }));
const original = result.current; const original = result.current;
act(() => { act(() => {
@ -239,7 +238,7 @@ describe('.last', () => {
it('changes nothing if last is disabled', async () => { it('changes nothing if last is disabled', async () => {
expect.assertions(2); expect.assertions(2);
const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }], ...stepActions }, { const { result } = renderHook(() => useSteps({ steps: [{ key: 'i' }, { key: '2' }], ...stepActions }, {
disabled: { 'i': false, '2': true } disabled: { 'i': false, '2': true },
})); }));
const original = result.current; const original = result.current;
act(() => { act(() => {
@ -270,7 +269,7 @@ describe('.disable', () => {
[[{ key: 'i' }, { key: '2' }], 1, { i: false, 2: false }, 1, 0, { i: false, 2: true }], [[{ key: 'i' }, { key: '2' }], 1, { i: false, 2: false }, 1, 0, { i: false, 2: true }],
[[{ key: 'i' }, { key: '2' }], 0, { i: false, 2: false }, 1, 0, { i: false, 2: true }], [[{ key: 'i' }, { key: '2' }], 0, { i: false, 2: false }, 1, 0, { i: false, 2: true }],
[[{ key: 'i' }, { key: '2' }], 1, { i: true, 2: false }, 1, 0, { i: true, 2: true }], [[{ key: 'i' }, { key: '2' }], 1, { i: true, 2: false }, 1, 0, { i: true, 2: true }],
[[{ key: 'i' }, { key: '2' }], 0, { i: false, 2: false }, 0, 0, { i: true, 2: false }] [[{ key: 'i' }, { key: '2' }], 0, { i: false, 2: false }, 0, 0, { i: true, 2: false }],
])('.disable with keys of %j, activeStep: %d, initial disabled: %j, we disabled index %d', ( ])('.disable with keys of %j, activeStep: %d, initial disabled: %j, we disabled index %d', (
steps, steps,
initialActiveStep, initialActiveStep,
@ -309,7 +308,7 @@ describe('.enable', () => {
[[{ key: 'i' }, { key: '2' }], 1, { i: false, 2: false }, 1, 1, { i: false, 2: false }], [[{ key: 'i' }, { key: '2' }], 1, { i: false, 2: false }, 1, 1, { i: false, 2: false }],
[[{ key: 'i' }, { key: '2' }], 0, { i: false, 2: true }, 1, 0, { i: false, 2: false }], [[{ key: 'i' }, { key: '2' }], 0, { i: false, 2: true }, 1, 0, { i: false, 2: false }],
[[{ key: 'i' }, { key: '2' }], 1, { i: true, 2: false }, 1, 1, { i: true, 2: false }], [[{ key: 'i' }, { key: '2' }], 1, { i: true, 2: false }, 1, 1, { i: true, 2: false }],
[[{ key: 'i' }, { key: '2' }], 0, { i: true, 2: false }, 0, 0, { i: false, 2: false }] [[{ key: 'i' }, { key: '2' }], 0, { i: true, 2: false }, 0, 0, { i: false, 2: false }],
])('.enable with keys of %j, activeStep: %d, initial enabled: %j, we enable index %d', ( ])('.enable with keys of %j, activeStep: %d, initial enabled: %j, we enable index %d', (
steps, steps,
initialActiveStep, initialActiveStep,
@ -368,12 +367,12 @@ describe('modify steps', () => {
activeStep: props.initial.activeStep || 0, activeStep: props.initial.activeStep || 0,
disabled: props.initial.disabled || fromPairs(props.initial.steps.map(i => [i.key, false])), disabled: props.initial.disabled || fromPairs(props.initial.steps.map(i => [i.key, false])),
completed: props.initial.completed || fromPairs(props.initial.steps.map(i => [i.key, false])), completed: props.initial.completed || fromPairs(props.initial.steps.map(i => [i.key, false])),
...props.expectation ...props.expectation,
}; };
return [ return [
props.initial.steps, props.initial.activeStep, props.initial.disabled, props.initial.completed, props.initial.steps, props.initial.activeStep, props.initial.disabled, props.initial.completed,
props.stepChange, props.stepChange,
expectation.activeStep, expectation.disabled, expectation.completed expectation.activeStep, expectation.disabled, expectation.completed,
]; ];
} }
@ -382,15 +381,15 @@ describe('modify steps', () => {
initial: { steps: [{ key: 'i' }, { key: '2' }] }, initial: { steps: [{ key: 'i' }, { key: '2' }] },
stepChange: [{ key: 'i' }, { key: '2' }], stepChange: [{ key: 'i' }, { key: '2' }],
expectation: { expectation: {
} },
}), }),
createTableEntry({ createTableEntry({
initial: { steps: [{ key: 'i' }, { key: '2' }], activeStep: 0 }, initial: { steps: [{ key: 'i' }, { key: '2' }], activeStep: 0 },
stepChange: [ { key: '2' }], stepChange: [ { key: '2' }],
expectation: { expectation: {
disabled: {2: false}, disabled: {2: false},
completed: {2: false} completed: {2: false},
} },
}), }),
createTableEntry({ createTableEntry({
initial: { steps: [{ key: 'i' }, { key: '2' }], activeStep: 1 }, initial: { steps: [{ key: 'i' }, { key: '2' }], activeStep: 1 },
@ -398,8 +397,8 @@ describe('modify steps', () => {
expectation: { expectation: {
activeStep: 0, activeStep: 0,
disabled: {i: false}, disabled: {i: false},
completed: {i: false} completed: {i: false},
} },
}), }),
createTableEntry({ createTableEntry({
initial: { steps: [{ key: 'i' }, { key: '2' }, {key: 'last'}], activeStep: 2, disabled: {i: false, 2: true, last:false}}, initial: { steps: [{ key: 'i' }, { key: '2' }, {key: 'last'}], activeStep: 2, disabled: {i: false, 2: true, last:false}},
@ -407,8 +406,8 @@ describe('modify steps', () => {
expectation: { expectation: {
activeStep: 0, activeStep: 0,
disabled: {i: false, 2: true}, disabled: {i: false, 2: true},
completed: {i: false, 2: false} completed: {i: false, 2: false},
} },
}), }),
createTableEntry({ createTableEntry({
initial: { steps: [{ key: 'i' }, { key: '2' }, {key: 'last'}], activeStep: 2, disabled: {i: false, 2: true, last:false}}, initial: { steps: [{ key: 'i' }, { key: '2' }, {key: 'last'}], activeStep: 2, disabled: {i: false, 2: true, last:false}},
@ -416,19 +415,19 @@ describe('modify steps', () => {
expectation: { expectation: {
activeStep: 1, activeStep: 1,
disabled: {i: false, 2: true, last:false}, disabled: {i: false, 2: true, last:false},
completed: {i: false, 2: false, last: false} completed: {i: false, 2: false, last: false},
} },
}), }),
createTableEntry({ createTableEntry({
initial: { steps: [{ key: 'i' }, { key: '2' }, {key: 'last'}], activeStep: 2, disabled: {i: false, 2: true, last:false}}, initial: { steps: [{ key: 'i' }, { key: '2' }, {key: 'last'}], activeStep: 2, disabled: {i: false, 2: true, last:false}},
stepChange: [ {key: 'last'},{ key: 'i' },], stepChange: [ {key: 'last'},{ key: 'i' }],
expectation: { expectation: {
activeStep: 0, activeStep: 0,
disabled: {i: false, last:false}, disabled: {i: false, last:false},
completed: {i: false, last: false} completed: {i: false, last: false},
} },
}) }),
])('with initial steps %j, active: %d, disabled: %o, completed: %o and change steps to %j', ( ])('with initial steps %j, active: %d, disabled: %o, completed: %o and change steps to %j', (
initialSteps, initialActiveStep, initialDisabled, initialCompleted, initialSteps, initialActiveStep, initialDisabled, initialCompleted,
stepChange, stepChange,

View file

@ -232,7 +232,7 @@ export default function useSteps(state: InputStepsState, initOptions: StepsInitO
disabled: initOptions.disabled || fromPairs(initialSteps.map((i) => [i, false])), disabled: initOptions.disabled || fromPairs(initialSteps.map((i) => [i, false])),
stepKeys: initialSteps, stepKeys: initialSteps,
activeStep, activeStep,
activeStepKey: activeStep >= 0 && activeStep < state.steps.length ? state.steps[activeStep].key : null activeStepKey: activeStep >= 0 && activeStep < state.steps.length ? state.steps[activeStep].key : null,
}; };
const [stepsState, dispatch] = useReducer(stepsReducer, initialState); const [stepsState, dispatch] = useReducer(stepsReducer, initialState);
@ -295,7 +295,7 @@ export default function useSteps(state: InputStepsState, initOptions: StepsInitO
// eslint-disable-next-line @typescript-eslint/no-empty-function // eslint-disable-next-line @typescript-eslint/no-empty-function
addStep: () => { }, addStep: () => { },
// eslint-disable-next-line @typescript-eslint/no-empty-function // eslint-disable-next-line @typescript-eslint/no-empty-function
removeStep: () => { } removeStep: () => { },
}); });
} }

View file

@ -29,7 +29,7 @@ describe('formatMoney', () => {
[oneEuro, {currencyDisplay: "name"}, "1.00 euros"], [oneEuro, {currencyDisplay: "name"}, "1.00 euros"],
[oneHundredYen, {}, "¥100"], [oneHundredYen, {}, "¥100"],
[oneHundredYen, {currencyDisplay: 'code'}, `JPY${NBSP}100`], [oneHundredYen, {currencyDisplay: 'code'}, `JPY${NBSP}100`],
[oneHundredYen, {currencyDisplay: "name"}, "100 Japanese yen"] [oneHundredYen, {currencyDisplay: "name"}, "100 Japanese yen"],
]; ];
it.each(tests)('money representing %j with opts %j returns %s', (money, opts, expected ) => { it.each(tests)('money representing %j with opts %j returns %s', (money, opts, expected ) => {
expect.assertions(1); expect.assertions(1);

View file

@ -12,7 +12,7 @@ class WithIntl extends React.Component<any,any> {
super(props); super(props);
this.state = { this.state = {
locale: props.intlConfig.defaultLocale || null locale: props.intlConfig.defaultLocale || null,
}; };
this.setLocale = this.setLocale.bind(this); this.setLocale = this.setLocale.bind(this);
@ -28,7 +28,7 @@ class WithIntl extends React.Component<any,any> {
setLocale (locale:string) { setLocale (locale:string) {
this.setState({ this.setState({
locale: locale locale: locale,
}); });
} }
@ -46,7 +46,7 @@ class WithIntl extends React.Component<any,any> {
children, children,
getMessages, getMessages,
getFormats, getFormats,
intlConfig intlConfig,
} = this.props; } = this.props;
const { locale } = this.state; const { locale } = this.state;
@ -77,7 +77,7 @@ export const setIntlConfig = (config:any) => {
const channel = addons.getChannel(); const channel = addons.getChannel();
channel.emit(EVENT_SET_CONFIG_ID, { channel.emit(EVENT_SET_CONFIG_ID, {
locales: config.locales, locales: config.locales,
defaultLocale: config.defaultLocale defaultLocale: config.defaultLocale,
}); });
}; };

View file

@ -13,7 +13,7 @@ class ScreenReaderOnlyText extends React.Component<Record<string,unknown>, Recor
margin: '-1px', margin: '-1px',
overflow: 'hidden', overflow: 'hidden',
clip: 'rect(0,0,0,0)', clip: 'rect(0,0,0,0)',
border: 0 border: 0,
}; };
return <span style={style}>{this.props.children}</span>; return <span style={style}>{this.props.children}</span>;
} }