File tree 3 files changed +43
-2
lines changed
3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export default defineConfig(
21
21
parserOptions : {
22
22
ecmaFeatures : {
23
23
jsx : true ,
24
+ jsxPragma : null ,
24
25
} ,
25
26
} ,
26
27
} ,
@@ -83,7 +84,7 @@ export default defineConfig(
83
84
'react/jsx-no-undef' : 'error' ,
84
85
'react/jsx-no-useless-fragment' : [ 'error' , { allowExpressions : true } ] ,
85
86
'react/jsx-pascal-case' : [ 'error' , { allowAllCaps : true } ] ,
86
- 'react/jsx-uses-react' : 'error ' ,
87
+ 'react/jsx-uses-react' : 'off ' ,
87
88
'react/jsx-uses-vars' : 'error' ,
88
89
} ,
89
90
} ,
Original file line number Diff line number Diff line change
1
+ import React , { useEffect , useState } from 'react' ;
2
+
3
+ export default function MyComponent ( ) {
4
+ const [ value ] = useState ( '' ) ;
5
+ useEffect ( ( ) => value , [ ] ) ;
6
+ return < div > Hello world</ div > ;
7
+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,39 @@ const ESLint = await loadESLint({ useFlatConfig: true });
6
6
/** @type {import('eslint').ESLint } */
7
7
const eslint = new ESLint ( ) ;
8
8
9
- const [ okResult ] = await eslint . lintFiles ( [ 'test/ok.jsx' ] ) ;
9
+ const [ okResult , notOkResult ] = await eslint . lintFiles ( [
10
+ 'test/ok.jsx' ,
11
+ 'test/not_ok.jsx' ,
12
+ ] ) ;
10
13
11
14
assert . strictEqual ( okResult . errorCount , 0 , 'ok.jsx should have no error' ) ;
15
+
16
+ const errors = notOkResult . messages . filter ( isError ) . map ( getRuleId ) . sort ( ) ;
17
+
18
+ assert . deepStrictEqual ( errors , [
19
+ 'no-unused-vars' ,
20
+ 'react-hooks/exhaustive-deps' ,
21
+ ] ) ;
22
+
23
+ const warnings = notOkResult . messages
24
+ . filter ( isWarning )
25
+ . filter ( excludeJsdoc )
26
+ . map ( getRuleId )
27
+ . sort ( ) ;
28
+ assert . deepStrictEqual ( warnings , [ ] ) ;
29
+
30
+ function isError ( message ) {
31
+ return message . severity === 2 ;
32
+ }
33
+
34
+ function isWarning ( message ) {
35
+ return message . severity === 1 ;
36
+ }
37
+
38
+ function excludeJsdoc ( message ) {
39
+ return ! message . ruleId . startsWith ( 'jsdoc/' ) ;
40
+ }
41
+
42
+ function getRuleId ( message ) {
43
+ return message . ruleId ;
44
+ }
You can’t perform that action at this time.
0 commit comments