@@ -11,20 +11,23 @@ const prettier = withBaseConfig('eslint-config-prettier')
11
11
12
12
const hasReact = hasAnyDep ( 'react' )
13
13
14
- const parserRules = ( typescript = false ) => {
14
+ const parserRules = ( typescript = false , react = false ) => {
15
15
const isOff = off => ( off ? 'off' : 'error' )
16
16
17
+ const propTypes = react ? { 'react/prop-types' : isOff ( typescript ) } : { }
18
+
17
19
return {
18
20
'no-implied-eval' : isOff ( typescript ) ,
19
21
'no-throw-literal' : isOff ( typescript ) ,
20
22
'@typescript-eslint/no-implied-eval' : isOff ( ! typescript ) ,
21
23
'@typescript-eslint/no-throw-literal' : isOff ( ! typescript ) ,
22
- 'react/prop-types' : isOff ( typescript ) ,
24
+ ... propTypes ,
23
25
}
24
26
}
25
27
26
28
const buildConfig = ( { withReact = false } = { } ) => {
27
- const ifReact = ( t , f ) => ( withReact || hasReact ? t : f )
29
+ const isReact = withReact || hasReact
30
+ const ifReact = ( t , f ) => ( isReact ? t : f )
28
31
29
32
return {
30
33
plugins : [ 'prettier' , 'jest' , ifReact ( 'react-hooks' ) ] . filter ( Boolean ) ,
@@ -52,7 +55,7 @@ const buildConfig = ({withReact = false} = {}) => {
52
55
optionalDependencies : false ,
53
56
} ,
54
57
] ,
55
- ...parserRules ( ) ,
58
+ ...parserRules ( false , isReact ) ,
56
59
} ,
57
60
overrides : [
58
61
{
@@ -61,7 +64,7 @@ const buildConfig = ({withReact = false} = {}) => {
61
64
'plugin:@typescript-eslint/recommended-requiring-type-checking' ,
62
65
] ,
63
66
rules : {
64
- ...parserRules ( true ) ,
67
+ ...parserRules ( true , isReact ) ,
65
68
} ,
66
69
} ,
67
70
{
0 commit comments