From 2979fba889ed5a5d118651a04ca538d1d3683f43 Mon Sep 17 00:00:00 2001 From: olehan Date: Thu, 18 Nov 2021 18:49:06 +0600 Subject: [PATCH] feat(tests): separate jsx and tsx tests --- .../tests/src/eslint-config-react.test.ts | 44 +++++++++++++++++-- .../src/eslint-config-typescript.test.ts | 24 +++++----- 2 files changed, 50 insertions(+), 18 deletions(-) diff --git a/packages/tests/src/eslint-config-react.test.ts b/packages/tests/src/eslint-config-react.test.ts index 3b6a533..0012b6a 100644 --- a/packages/tests/src/eslint-config-react.test.ts +++ b/packages/tests/src/eslint-config-react.test.ts @@ -1,13 +1,50 @@ import { eslintConfigReact } from '@azimutlabs/eslint-config-react/lib/config'; +import { eslintConfigTypescriptBase } from '../../eslint-config-typescript/lib'; import { buildEslint } from './services/builders'; import { getMessagesFromLintResults } from './services/getMessagesFromLintResults'; -const eslintBase = buildEslint(eslintConfigReact); +const eslintBase = buildEslint(eslintConfigReact, { + overrideConfig: eslintConfigTypescriptBase, +}); describe('successful cases', () => { - it('should lint a client-side react component without jsx', async () => { - const file = `import { createElement, forwardRef } from 'react'; + it('should lint a client-side typescript react component', async () => { + const file = `import { forwardRef } from 'react'; +import type { ReactNode } from 'react'; + +interface ButtonProps { + readonly disabled?: boolean; + readonly color?: string; + readonly children?: ReactNode; +} + +export const Button = forwardRef( + ({ children, color: _color, ...rest }, ref) => ( + + ), +); + +Button.displayName = 'Button'; +Button.defaultProps = { + disabled: true, +}; +`; + expect( + getMessagesFromLintResults(await eslintBase.lintText(file, { filePath: 'component.tsx' })) + ).toStrictEqual([]); + }); + + it('should lint a client-side jsx react component', async () => { + const file = `import { forwardRef } from 'react'; export const Button = forwardRef(({ children, color: _color, ...rest }, ref) => (