📝 Enforce a specific set of props on specific elements.
Before starting, make sure you have ESLint as a devDependency of your project.
Next, install eslint-plugin-react-native-enforce-props:
npm install eslint-plugin-react-native-enforce-props --save-dev
# or
yarn add eslint-plugin-react-native-enforce-props --devImport the plugin in your eslint config, add it to the plugins section and set the rules you want to use:
const enforceProps = require('../eslint-plugin-react-native-enforce-props/dist/index');
module.exports = tsEslint.config(
{ ignores: ['babel.config.js', '*.jpg', 'index.js'] },
{
...other options...
plugins: {
...other plugins...
'react-native-enforce-props': enforceProps,
},
rules: {
...other rules...
'react-native-enforce-props/enforce-props': [
'error',
{
propsToCheck: ['onPress'],
componentsToCheck: ['TouchableOpacity'],
},
],
}
},
);
The plugin provides the following rules:
| Name | Description |
|---|---|
| enforce-props | Enforce a specific set of props on specific elements |
eslint-plugin-react-native-enforce-props is licensed under the MIT License.