From 70b43e7fdeb409a771900e084a0529b8c6a028eb Mon Sep 17 00:00:00 2001 From: Paul Briand <57703518+P0labrD@users.noreply.github.com> Date: Tue, 22 Aug 2023 16:41:53 +0200 Subject: [PATCH] docs: update CONTRIBUTING.md (#41) * docs: update CONTRIBUTING.md * docs: change section title * fix: fix typo in CONTRIBUTING.md --- packages/eslint-plugin/CONTRIBUTING.md | 68 +++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/CONTRIBUTING.md b/packages/eslint-plugin/CONTRIBUTING.md index 84987fc..7860caa 100644 --- a/packages/eslint-plugin/CONTRIBUTING.md +++ b/packages/eslint-plugin/CONTRIBUTING.md @@ -1,6 +1,72 @@ # Contribute -If you find a useful rule that you feel every project at BAM should use, feel free to open a PR. +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. + +## Adding a rule from another plugin + +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: + +#### Open an issue to discuss the rule with the community: + +- Go to this link : [RFC for a new rule on eslint-plugin ⭐](https://github.com/bamlab/react-native-project-config/issues/new?assignees=&labels=%F0%9F%93%8F+eslint-plugin%2C%E2%AD%90+enhancement&projects=&template=RFC-NEW-RULE.yml&title=%5BRFC%5D%3A+plugin%3Arule-name) +- 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 + +#### After the discussion, if the rule is approved, you can create a PR to add the rule to the plugin: + +- Create a new branch from `main` with the name `feat/plugin-rule-name` +- Go to the corresponding shareable config file (for example `recommended.js`) and add the rule to the `rules` object: + ```js + // 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](#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: + ```js + // recommended.js + module.exports = { + ... + plugins: [ + ... + "plugin-name", + ], + } + ``` + - add the plugin to the `peerDependencies` of the `package.json` file: + ```json + // package.json + { + ... + "peerDependencies": { + ... + "plugin-name": "^version", + }, + } + ``` +- In the description of the PR, add `Closes #` 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: + +```tsx +// 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 = () => ; +``` ## Creating new rules