Enforce Interface when creating react components with typescript
$ npm i eslint @fabriece/eslint-plugin-react-typescript --save-dev
$ yarn add eslint @fabriece/eslint-plugin-react-typescript -D
Note: If you installed ESLint globally (using the -g
flag) then you must also install @fabriece/eslint-plugin-react-typescript
globally.
Add @fabriece/react-typescript
to the plugins section of your .eslintrc
configuration file.
{
"plugins": ["@fabriece/react-typescript"]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"@fabriece/react-typescript/require-props-suffix": "error",
"@fabriece/react-typescript/require-component-props-interface": "error"
}
}
Name | Description |
---|---|
@fabriece/react-typescript/require-props-suffix |
Require a props interface to be provided to a react component |
@fabriece/react-typescript/require-component-props-interface |
Require a props interface to have a Props suffix |