11import { eslintConfigReact } from '@azimutlabs/eslint-config-react/lib/config' ;
22
3+ import { eslintConfigTypescriptBase } from '../../eslint-config-typescript/lib' ;
34import { buildEslint } from './services/builders' ;
45import { getMessagesFromLintResults } from './services/getMessagesFromLintResults' ;
56
6- const eslintBase = buildEslint ( eslintConfigReact ) ;
7+ const eslintBase = buildEslint ( eslintConfigReact , {
8+ overrideConfig : eslintConfigTypescriptBase ,
9+ } ) ;
710
811describe ( 'successful cases' , ( ) => {
9- it ( 'should lint a client-side react component without jsx' , async ( ) => {
10- const file = `import { createElement, forwardRef } from 'react';
12+ it ( 'should lint a client-side typescript react component' , async ( ) => {
13+ const file = `import { forwardRef } from 'react';
14+ import type { ReactNode } from 'react';
15+
16+ interface ButtonProps {
17+ readonly disabled?: boolean;
18+ readonly color?: string;
19+ readonly children?: ReactNode;
20+ }
21+
22+ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
23+ ({ children, color: _color, ...rest }, ref) => (
24+ <button
25+ ref={ref}
26+ type="button"
27+ {...rest}
28+ >
29+ <span className="d-flex">
30+ {children}
31+ </span>
32+ </button>
33+ ),
34+ );
35+
36+ Button.displayName = 'Button';
37+ Button.defaultProps = {
38+ disabled: true,
39+ };
40+ ` ;
41+ expect (
42+ getMessagesFromLintResults ( await eslintBase . lintText ( file , { filePath : 'component.tsx' } ) )
43+ ) . toStrictEqual ( [ ] ) ;
44+ } ) ;
45+
46+ it ( 'should lint a client-side jsx react component' , async ( ) => {
47+ const file = `import { forwardRef } from 'react';
1148
1249export const Button = forwardRef(({ children, color: _color, ...rest }, ref) => (
1350 <button
@@ -22,7 +59,6 @@ export const Button = forwardRef(({ children, color: _color, ...rest }, ref) =>
2259));
2360
2461Button.displayName = 'Button';
25-
2662Button.defaultProps = {
2763 disabled: true,
2864};
0 commit comments