This plugin is a way to share the best programming experience via rules and configurations to be used in different projects. It is important to keep it up to date and to add new rules and configurations when needed.
If you feel that a rule could be useful to all react-native new projects, you can add it to the plugin by following these steps:
- Go to this link : RFC for a new rule on eslint-plugin ⭐
- Fill the template with any relevant information about the rule (why it is needed, how it works, shareable configs to add it to, etc.)
- Submit the issue and share it with the community
-
Create a new branch from
main
with the namefeat/plugin-rule-name
-
Go to the corresponding shareable config file (for example
recommended.js
) and add the rule to therules
object:// recommended.js module.exports = { ... rules: { ... "plugin-name/rule-name": ["error", { ... }], }, }
If you feel a new shareable config should be created for the rule, please refer to the Creating new shareable configuration section.
-
(Optional) If the plugin the rule is part of is not yet added as a dependency:
-
add the plugin in the
plugins
array of the shareable config file:// recommended.js module.exports = { ... plugins: [ ... "plugin-name", ], }
-
add the plugin to the
peerDependencies
of thepackage.json
file:// package.json { ... "peerDependencies": { ... "plugin-name": "^version", }, }
-
-
In the description of the PR, add
Closes #<issue number>
to link the PR to the issue and close it automatically when the PR is merged
(OPTIONAL) Feel free to add a breaking example of the rule in the example-app/eslint-breaking-examples
directory
Here's an example:
// break-react-eslint-rules.tsx
// Save without formatting: [⌘ + K] > [S]
// This should trigger one error breaking eslint-plugin-react:
// react/jsx-no-undef
export const MyComponent = () => <ThisIsAViewThatDoesntExist />;
Creating new rules is quite simple:
-
Create a new rule from the template:
cd eslint-plugin yo eslint:rule
-
Optionally, add it to some shareable configs (for example
recommended
):// recommended.js module.exports = { ... rules: { ... "@bam.tech/my-new-rule": "error", }, }
-
Update the README and run the tests:
yarn build yarn update:eslint-docs yarn lint yarn test
Creating a shareable config is simple, you just have to create a new config file in the lib/configs
directory and modify it.
Extending new shareable configurations is quite simple, you just have to modify the config file and add your shareable configuration to the extends
array (the order of configurations is important):
module.exports = {
...
extends: [
...
"@some-scope/eslint-config",
],
}
The package containing your shareable configuration should be added as a dependency by running yarn add your-package
.
Adding a plugin is quite simple, you just have to modify your config file and add your plugin to the plugins
array:
module.exports = {
...
plugins: [
...
"some-plugin",
],
}
The package containing your plugin should be added as a peer dependency by running yarn add --peer eslint-plugin-some-plugin
.
Once your PR has been merged, your changes will be added to the main
branch of the project. However they won't be accessible for current plugin users, since the plugin is available through versionned npm packages.
If you need to release a new version of the package including your changes, please follow this Publishing a new version of a package section.