Skip to content

Commit

Permalink
chore(crwa): remove React prop-types package (redwoodjs#9206)
Browse files Browse the repository at this point in the history
TypeScript has long been well established; React prop-types is a
vestigial feature. The package hasn't been updated in ~2 years
(https://www.npmjs.com/package/prop-types) and the legacy React docs
recommend moving off it:
https://legacy.reactjs.org/docs/typechecking-with-proptypes.html.

<img width="913" alt="image"
src="https://github.com/redwoodjs/redwood/assets/32992335/acfe01fc-6248-4fc6-a47d-3340b417a637">

There are a few things about this PR that are technically breaking.
`prop-types` isn't a huge package so I don't think it's important this
goes into the next minor or anything; it can just be scheduled for the
next major.
  • Loading branch information
jtoar authored and Tobbe committed Dec 22, 2023
1 parent 2478bbd commit f76bcef
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 30 deletions.
1 change: 0 additions & 1 deletion __fixtures__/test-project/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"@redwoodjs/router": "6.6.0",
"@redwoodjs/web": "6.6.0",
"humanize-string": "2.1.0",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
Expand Down
5 changes: 0 additions & 5 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,6 @@ module.exports = {
default: 'React',
path: 'react',
},
{
// import { PropTypes } from 'prop-types'
default: 'PropTypes',
path: 'prop-types',
},
],
},
],
Expand Down
5 changes: 0 additions & 5 deletions packages/babel-config/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ export const getWebSideBabelPlugins = (
default: 'React',
path: 'react',
},
{
// import PropTypes from 'prop-types'
default: 'PropTypes',
path: 'prop-types',
},
{
// import gql from 'graphql-tag'
default: 'gql',
Expand Down
1 change: 0 additions & 1 deletion packages/core/config/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ const getSharedPlugins = (isEnvProduction) => {
new ReactRefreshWebpackPlugin({ overlay: false }),
new webpack.ProvidePlugin({
React: 'react',
PropTypes: 'prop-types',
gql: 'graphql-tag',
...devTimeAutoImports,
}),
Expand Down
1 change: 0 additions & 1 deletion packages/create-redwood-app/templates/js/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"@redwoodjs/forms": "6.6.0",
"@redwoodjs/router": "6.6.0",
"@redwoodjs/web": "6.6.0",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
Expand Down
1 change: 0 additions & 1 deletion packages/create-redwood-app/templates/ts/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"@redwoodjs/forms": "6.6.0",
"@redwoodjs/router": "6.6.0",
"@redwoodjs/web": "6.6.0",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
Expand Down
8 changes: 1 addition & 7 deletions packages/eslint-config/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@ module.exports = {
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
],
// React rules
'react/prop-types': [
'warn',
{
skipUndeclared: true,
ignore: ['style', 'children', 'className', 'theme'],
},
],
'react/prop-types': 'off',
'react/display-name': 'off',
'react-hooks/exhaustive-deps': 'warn',
'import/order': [
Expand Down
3 changes: 0 additions & 3 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,17 @@
"@babel/core": "^7.22.20",
"@testing-library/jest-dom": "5.17.0",
"@testing-library/react": "14.1.2",
"@types/prop-types": "15.7.5",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"@types/testing-library__jest-dom": "5.14.9",
"jest": "29.7.0",
"nodemon": "3.0.2",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"tstyche": "1.0.0-beta.3",
"typescript": "5.3.3"
},
"peerDependencies": {
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
Expand Down
4 changes: 3 additions & 1 deletion packages/web/src/global.web-auto-imports.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import type _React from 'react'

import type _gql from 'graphql-tag'
import type _PropTypes from 'prop-types'

// These are the global types exposed to a user's project
// For "internal" global types see ambient.d.ts

declare global {
<<<<<<< HEAD
const React: typeof _React
const PropTypes: typeof _PropTypes
=======
>>>>>>> 5921359bf (chore(crwa): remove React `prop-types` package (#9206))
const gql: typeof _gql

interface Window {
Expand Down
7 changes: 2 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9183,7 +9183,6 @@ __metadata:
"@redwoodjs/auth": "npm:6.6.0"
"@testing-library/jest-dom": "npm:5.17.0"
"@testing-library/react": "npm:14.1.2"
"@types/prop-types": "npm:15.7.5"
"@types/react": "npm:18.2.37"
"@types/react-dom": "npm:18.2.15"
"@types/testing-library__jest-dom": "npm:5.14.9"
Expand All @@ -9193,7 +9192,6 @@ __metadata:
graphql-tag: "npm:2.12.6"
jest: "npm:29.7.0"
nodemon: "npm:3.0.2"
prop-types: "npm:15.8.1"
react: "npm:18.2.0"
react-dom: "npm:18.2.0"
react-helmet-async: "npm:1.3.0"
Expand All @@ -9203,7 +9201,6 @@ __metadata:
tstyche: "npm:1.0.0-beta.3"
typescript: "npm:5.3.3"
peerDependencies:
prop-types: 15.8.1
react: 18.2.0
react-dom: 18.2.0
bin:
Expand Down Expand Up @@ -11889,7 +11886,7 @@ __metadata:
languageName: node
linkType: hard

"@types/prop-types@npm:*, @types/prop-types@npm:15.7.5, @types/prop-types@npm:^15.7.2":
"@types/prop-types@npm:*, @types/prop-types@npm:^15.7.2":
version: 15.7.5
resolution: "@types/prop-types@npm:15.7.5"
checksum: 648aae41423821c61c83823ae36116c8d0f68258f8b609bdbc257752dcd616438d6343d554262aa9a7edaee5a19aca2e028a74fa2d0f40fffaf2816bc7056857
Expand Down Expand Up @@ -29419,7 +29416,7 @@ __metadata:
languageName: node
linkType: hard

"prop-types@npm:*, prop-types@npm:15.8.1, prop-types@npm:15.x, prop-types@npm:^15.5.4, prop-types@npm:^15.6.2, prop-types@npm:^15.7.2, prop-types@npm:^15.8.1":
"prop-types@npm:*, prop-types@npm:15.x, prop-types@npm:^15.5.4, prop-types@npm:^15.6.2, prop-types@npm:^15.7.2, prop-types@npm:^15.8.1":
version: 15.8.1
resolution: "prop-types@npm:15.8.1"
dependencies:
Expand Down

0 comments on commit f76bcef

Please sign in to comment.