babel-plugin-remove-react-fc-and-vfc
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "babel-plugin-remove-react-fc-and-vfc", | ||
"description": "", | ||
"version": "0.1.0", | ||
"description": "This plugin removes React.VFC and React.FC annotation", | ||
"version": "0.1.1", | ||
"main": "dist/index.js", | ||
@@ -17,4 +17,3 @@ "files": [ | ||
"keywords": [ | ||
"babel-plugin", | ||
"react" | ||
"babel-plugin" | ||
], | ||
@@ -43,25 +42,26 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@babel/cli": "^7.7.7", | ||
"@babel/cli": "^7.16.0", | ||
"@types/babel-core": "^6.25.7", | ||
"@types/babel-plugin-tester": "^9.0.4", | ||
"@types/babel-types": "^7.0.11", | ||
"@types/jest": "^27.0.2", | ||
"@typescript-eslint/eslint-plugin": "^5.2.0", | ||
"@typescript-eslint/parser": "^5.2.0", | ||
"@types/jest": "^27.0.3", | ||
"@typescript-eslint/eslint-plugin": "^5.4.0", | ||
"@typescript-eslint/parser": "^5.4.0", | ||
"babel-plugin-tester": "^10.1.0", | ||
"eslint": "^8.1.0", | ||
"eslint": "^8.2.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"jest": "^27.3.1", | ||
"lint-staged": "^11.2.6", | ||
"lint-staged": "^12.0.3", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.4.1", | ||
"ts-jest": "^27.0.7", | ||
"typescript": "^4.4.4" | ||
"typescript": "^4.5.2" | ||
}, | ||
"lint-staged": { | ||
"*.{js,jsx,ts,tsx}": [ | ||
"*.{ts,tsx}": [ | ||
"npx eslint --fix", | ||
"npx prettier --write" | ||
"npx prettier --write", | ||
"git add" | ||
] | ||
} | ||
} |
# babel-plugin-remove-react-fc-and-vfc | ||
 | ||
[](https://opensource.org/licenses/MIT) | ||
[](https://badge.fury.io/js/babel-plugin-remove-react-fc-and-vfc) | ||
This plugin removes `React.VFC` and `React.FC` annotation. | ||
Input: | ||
```ts | ||
const Component: React.FC<Props> = (props) => { | ||
return <div>{props.value}</div>; | ||
}; | ||
``` | ||
Output: | ||
```ts | ||
const Component = (props: Props) => { | ||
return <div>{props.value}</div>; | ||
}; | ||
``` | ||
## Why? | ||
As `React.XXX` is modified frequently like [`React.SFC` was removed](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/30364) or [the children type will be removed from React.FC](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/46691), I think we should not use `React.XXX` type as much as possible. | ||
See more details | ||
- [Remove React.FC from Typescript template](https://github.com/facebook/create-react-app/pull/8177) | ||
- [【検証】React.FC と React.VFC はべつに使わなくていい説](https://kray.jp/blog/dont-have-to-use-react-fc-and-react-vfc/) | ||
## Install | ||
```bash | ||
$ npm install --save-dev babel-plugin-remove-react-fc-and-vfc | ||
``` | ||
and add it to your `.babelrc`. | ||
```json | ||
{ | ||
"plugins": ["remove-react-fc-and-vfc"] | ||
} | ||
``` | ||
## Contributing | ||
Welcome your contribution! | ||
See also [Babel Plugin Handbook](https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md). | ||
## Setup | ||
``` | ||
$ git clone git@github.com:nissy-dev/babel-plugin-remove-react-fc-and-vfc.git | ||
$ cd babel-plugin-remove-react-fc-and-vfc | ||
$ npm ci | ||
``` | ||
## Development Tools | ||
``` | ||
// run tsc, eslint, prettier | ||
$ npm run lint | ||
// run test | ||
$ npm run test | ||
``` |
6788
71