File tree Expand file tree Collapse file tree 7 files changed +30
-10
lines changed
test/fixtures/typescript-advanced Expand file tree Collapse file tree 7 files changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -26,11 +26,11 @@ yarn create react-app my-app --template typescript
26
26
To add [ TypeScript] ( https://www.typescriptlang.org/ ) to a Create React App project, first install it:
27
27
28
28
``` sh
29
- npm install --save typescript @types/node @types/react @types/react-dom @types/jest
29
+ npm install --save typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser @ types/node @types/react @types/react-dom @types/jest
30
30
31
31
# or
32
32
33
- yarn add typescript @types/node @types/react @types/react-dom @types/jest
33
+ yarn add typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser @ types/node @types/react @types/react-dom @types/jest
34
34
```
35
35
36
36
Next, rename any file to be a TypeScript file (e.g. ` src/index.js ` to ` src/index.tsx ` ) and ** restart your development server** !
Original file line number Diff line number Diff line change 8
8
"@types/react" : " ^16.9.0" ,
9
9
"@types/react-dom" : " ^16.9.0" ,
10
10
"@types/jest" : " ^25.0.0" ,
11
- "typescript" : " ^3.8.0"
11
+ "typescript" : " ^3.8.0" ,
12
+ "@typescript-eslint/eslint-plugin" : " ^2.28.0" ,
13
+ "@typescript-eslint/parser" : " ^2.28.0"
12
14
}
13
15
}
14
16
}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ If you want to use this ESLint configuration in a project not built with Create
19
19
First, install this package, ESLint and the necessary plugins.
20
20
21
21
``` sh
22
- npm install --save-dev eslint-config-react-app @typescript-eslint/eslint-plugin@2.x @typescript-eslint/parser@2.x babel-eslint@10.x eslint@6.x eslint-plugin-flowtype@4.x eslint-plugin-import@2.x eslint-plugin-jsx-a11y@6.x eslint-plugin-react@7.x eslint-plugin-react-hooks@2.x
22
+ npm install --save-dev eslint-config-react-app babel-eslint@10.x eslint@6.x eslint-plugin-flowtype@4.x eslint-plugin-import@2.x eslint-plugin-jsx-a11y@6.x eslint-plugin-react@7.x eslint-plugin-react-hooks@2.x
23
23
```
24
24
25
25
Then create a file named ` .eslintrc.json ` with following contents in the root folder of your project:
Original file line number Diff line number Diff line change 25
25
"eslint-plugin-react" : " 7.x" ,
26
26
"eslint-plugin-react-hooks" : " 1.x || 2.x || 3.x || 4.x"
27
27
},
28
+ "peerDependenciesMeta" : {
29
+ "@typescript-eslint/eslint-plugin" : {
30
+ "optional" : true
31
+ },
32
+ "@typescript-eslint/parser" : {
33
+ "optional" : true
34
+ }
35
+ },
28
36
"dependencies" : {
29
- "confusing-browser-globals" : " ^1.0.9"
37
+ "confusing-browser-globals" : " ^1.0.9" ,
38
+ "resolve" : " ^1.16.0"
30
39
}
31
40
}
Original file line number Diff line number Diff line change 31
31
"@babel/core" : " 7.10.1" ,
32
32
"@pmmmwh/react-refresh-webpack-plugin" : " 0.3.2" ,
33
33
"@svgr/webpack" : " 5.4.0" ,
34
- "@typescript-eslint/eslint-plugin" : " ^2.10.0" ,
35
- "@typescript-eslint/parser" : " ^2.10.0" ,
36
34
"babel-eslint" : " 10.1.0" ,
37
35
"babel-jest" : " ^26.0.1" ,
38
36
"babel-loader" : " 8.1.0" ,
92
90
"fsevents" : " ^2.1.3"
93
91
},
94
92
"peerDependencies" : {
95
- "typescript" : " ^3.2.1"
93
+ "typescript" : " ^3.2.1" ,
94
+ "@typescript-eslint/eslint-plugin" : " ^2.28.0" ,
95
+ "@typescript-eslint/parser" : " ^2.28.0"
96
96
},
97
97
"peerDependenciesMeta" : {
98
98
"typescript" : {
99
99
"optional" : true
100
+ },
101
+ "@typescript-eslint/eslint-plugin" : {
102
+ "optional" : true
103
+ },
104
+ "@typescript-eslint/parser" : {
105
+ "optional" : true
100
106
}
101
107
},
102
108
"browserslist" : {
Original file line number Diff line number Diff line change 1
1
const testSetup = require ( '../__shared__/test-setup' ) ;
2
2
3
3
test ( 'builds in development' , async ( ) => {
4
- const { fulfilled } = await testSetup . scripts . start ( { smoke : true } ) ;
4
+ const { fulfilled, stderr } = await testSetup . scripts . start ( { smoke : true } ) ;
5
+ expect ( stderr ) . toBe ( "We detected TypeScript in your project (src/App.test.ts) and created a tsconfig.json file for you.\n" ) ;
5
6
expect ( fulfilled ) . toBe ( true ) ;
6
7
} ) ;
7
8
test ( 'builds in production' , async ( ) => {
Original file line number Diff line number Diff line change 5
5
"@types/jest" : " *" ,
6
6
"react" : " *" ,
7
7
"react-dom" : " *" ,
8
- "typescript" : " 3.7.2"
8
+ "typescript" : " 3.7.2" ,
9
+ "@typescript-eslint/eslint-plugin" : " ^2.28.0" ,
10
+ "@typescript-eslint/parser" : " ^2.28.0"
9
11
}
10
12
}
You can’t perform that action at this time.
0 commit comments