Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make @typescript-eslint an optional peer dependency #9078

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docusaurus/docs/adding-typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ yarn create react-app my-app --template typescript
To add [TypeScript](https://www.typescriptlang.org/) to a Create React App project, first install it:

```sh
npm install --save typescript @types/node @types/react @types/react-dom @types/jest
npm install --save typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser @types/node @types/react @types/react-dom @types/jest

# or

yarn add typescript @types/node @types/react @types/react-dom @types/jest
yarn add typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser @types/node @types/react @types/react-dom @types/jest
```

Next, rename any file to be a TypeScript file (e.g. `src/index.js` to `src/index.tsx`) and **restart your development server**!
Expand Down
4 changes: 3 additions & 1 deletion packages/cra-template-typescript/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"@types/jest": "^25.0.0",
"typescript": "^3.8.0"
"typescript": "^3.8.0",
"@typescript-eslint/eslint-plugin": "^2.28.0",
"@typescript-eslint/parser": "^2.28.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/eslint-config-react-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If you want to use this ESLint configuration in a project not built with Create
First, install this package, ESLint and the necessary plugins.

```sh
npm install --save-dev eslint-config-react-app @typescript-eslint/[email protected] @typescript-eslint/[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
npm install --save-dev eslint-config-react-app [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
```

Then create a file named `.eslintrc.json` with following contents in the root folder of your project:
Expand Down
11 changes: 10 additions & 1 deletion packages/eslint-config-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@
"eslint-plugin-react": "7.x",
"eslint-plugin-react-hooks": "1.x || 2.x || 3.x || 4.x"
},
"peerDependenciesMeta": {
"@typescript-eslint/eslint-plugin": {
"optional": true
},
"@typescript-eslint/parser": {
"optional": true
}
},
"dependencies": {
"confusing-browser-globals": "^1.0.9"
"confusing-browser-globals": "^1.0.9",
"resolve": "^1.16.0"
}
}
12 changes: 9 additions & 3 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
"@babel/core": "7.10.1",
"@pmmmwh/react-refresh-webpack-plugin": "0.3.2",
"@svgr/webpack": "5.4.0",
"@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.10.0",
"babel-eslint": "10.1.0",
"babel-jest": "^26.0.1",
"babel-loader": "8.1.0",
Expand Down Expand Up @@ -92,11 +90,19 @@
"fsevents": "^2.1.3"
},
"peerDependencies": {
"typescript": "^3.2.1"
"typescript": "^3.2.1",
"@typescript-eslint/eslint-plugin": "^2.28.0",
"@typescript-eslint/parser": "^2.28.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
},
"@typescript-eslint/eslint-plugin": {
"optional": true
},
"@typescript-eslint/parser": {
"optional": true
}
},
"browserslist": {
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/typescript-advanced/index.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const testSetup = require('../__shared__/test-setup');

test('builds in development', async () => {
const { fulfilled } = await testSetup.scripts.start({ smoke: true });
const { fulfilled, stderr } = await testSetup.scripts.start({ smoke: true });
expect(stderr).toBe("We detected TypeScript in your project (src/App.test.ts) and created a tsconfig.json file for you.\n");
expect(fulfilled).toBe(true);
});
test('builds in production', async () => {
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/typescript-advanced/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"@types/jest": "*",
"react": "*",
"react-dom": "*",
"typescript": "3.7.2"
"typescript": "3.7.2",
"@typescript-eslint/eslint-plugin": "^2.28.0",
"@typescript-eslint/parser": "^2.28.0"
}
}