@@ -11,7 +11,7 @@ function filterRules(rules, predicate) {
11
11
12
12
/**
13
13
* @param {object } rules - rules object mapping rule name to rule module
14
- * @returns {Record<string, 2 | 'error'> }
14
+ * @returns {Record<string, SEVERITY_ERROR | 'error'> }
15
15
*/
16
16
function configureAsError ( rules ) {
17
17
return fromEntries ( Object . keys ( rules ) . map ( ( key ) => [ `react/${ key } ` , 2 ] ) ) ;
@@ -31,6 +31,10 @@ const plugins = [
31
31
'react' ,
32
32
] ;
33
33
34
+ // TODO: with TS 4.5+, inline this
35
+ const SEVERITY_ERROR = /** @type {2 } */ ( 2 ) ;
36
+ const SEVERITY_OFF = /** @type {0 } */ ( 0 ) ;
37
+
34
38
const configs = {
35
39
recommended : {
36
40
plugins,
@@ -40,28 +44,28 @@ const configs = {
40
44
} ,
41
45
} ,
42
46
rules : {
43
- 'react/display-name' : 2 ,
44
- 'react/jsx-key' : 2 ,
45
- 'react/jsx-no-comment-textnodes' : 2 ,
46
- 'react/jsx-no-duplicate-props' : 2 ,
47
- 'react/jsx-no-target-blank' : 2 ,
48
- 'react/jsx-no-undef' : 2 ,
49
- 'react/jsx-uses-react' : 2 ,
50
- 'react/jsx-uses-vars' : 2 ,
51
- 'react/no-children-prop' : 2 ,
52
- 'react/no-danger-with-children' : 2 ,
53
- 'react/no-deprecated' : 2 ,
54
- 'react/no-direct-mutation-state' : 2 ,
55
- 'react/no-find-dom-node' : 2 ,
56
- 'react/no-is-mounted' : 2 ,
57
- 'react/no-render-return-value' : 2 ,
58
- 'react/no-string-refs' : 2 ,
59
- 'react/no-unescaped-entities' : 2 ,
60
- 'react/no-unknown-property' : 2 ,
61
- 'react/no-unsafe' : 0 ,
62
- 'react/prop-types' : 2 ,
63
- 'react/react-in-jsx-scope' : 2 ,
64
- 'react/require-render-return' : 2 ,
47
+ 'react/display-name' : SEVERITY_ERROR ,
48
+ 'react/jsx-key' : SEVERITY_ERROR ,
49
+ 'react/jsx-no-comment-textnodes' : SEVERITY_ERROR ,
50
+ 'react/jsx-no-duplicate-props' : SEVERITY_ERROR ,
51
+ 'react/jsx-no-target-blank' : SEVERITY_ERROR ,
52
+ 'react/jsx-no-undef' : SEVERITY_ERROR ,
53
+ 'react/jsx-uses-react' : SEVERITY_ERROR ,
54
+ 'react/jsx-uses-vars' : SEVERITY_ERROR ,
55
+ 'react/no-children-prop' : SEVERITY_ERROR ,
56
+ 'react/no-danger-with-children' : SEVERITY_ERROR ,
57
+ 'react/no-deprecated' : SEVERITY_ERROR ,
58
+ 'react/no-direct-mutation-state' : SEVERITY_ERROR ,
59
+ 'react/no-find-dom-node' : SEVERITY_ERROR ,
60
+ 'react/no-is-mounted' : SEVERITY_ERROR ,
61
+ 'react/no-render-return-value' : SEVERITY_ERROR ,
62
+ 'react/no-string-refs' : SEVERITY_ERROR ,
63
+ 'react/no-unescaped-entities' : SEVERITY_ERROR ,
64
+ 'react/no-unknown-property' : SEVERITY_ERROR ,
65
+ 'react/no-unsafe' : SEVERITY_OFF ,
66
+ 'react/prop-types' : SEVERITY_ERROR ,
67
+ 'react/react-in-jsx-scope' : SEVERITY_ERROR ,
68
+ 'react/require-render-return' : SEVERITY_ERROR ,
65
69
} ,
66
70
} ,
67
71
all : {
@@ -82,8 +86,8 @@ const configs = {
82
86
jsxPragma : null , // for @typescript /eslint-parser
83
87
} ,
84
88
rules : {
85
- 'react/react-in-jsx-scope' : 0 ,
86
- 'react/jsx-uses-react' : 0 ,
89
+ 'react/react-in-jsx-scope' : SEVERITY_OFF ,
90
+ 'react/jsx-uses-react' : SEVERITY_OFF ,
87
91
} ,
88
92
} ,
89
93
} ;
0 commit comments