Skip to content

Commit fa030f0

Browse files
authored
chore: add contribution guidelines (#38)
1 parent 9a3be22 commit fa030f0

2 files changed

Lines changed: 120 additions & 2 deletions

File tree

CONTRIBUTING.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Contributing
2+
3+
Thank you for your interest in contributing! Whether it's a bug report, feature request, or a pull request, we appreciate your help in improving this ESLint plugin.
4+
5+
## Table of Contents
6+
7+
- [Code of Conduct](#code-of-conduct)
8+
- [Getting Started](#getting-started)
9+
- [Development Workflow](#development-workflow)
10+
- [Linting, Formatting, and Testing](#linting-formatting-and-testing)
11+
- [Playground](#playground)
12+
- [Submitting Issues](#submitting-issues)
13+
- [Submitting Pull Requests](#submitting-pull-requests)
14+
- [Resources](#resources)
15+
16+
## Code of Conduct
17+
18+
We adhere to the [OpenJS Foundation Code of Conduct](https://github.com/openjs-foundation/cross-project-council/blob/main/CODE_OF_CONDUCT.md). Please be respectful, inclusive, and constructive in all your communications and contributions.
19+
20+
If you're new to open source, this guide might also be helpful:
21+
[How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
22+
23+
## Getting Started
24+
25+
To contribute, **fork the repository**, then clone your fork and install dependencies:
26+
27+
```bash
28+
git clone https://github.com/YOUR_USERNAME/eslint-plugin-php.git
29+
cd eslint-plugin-php
30+
npm install
31+
```
32+
33+
> Replace `YOUR_USERNAME` with your actual GitHub username.
34+
35+
## Development Workflow
36+
37+
1. **Create a new branch** for each feature or fix:
38+
39+
```bash
40+
git checkout -b fix/rule-name-or-feature
41+
```
42+
43+
2. **Make changes** to the codebase:
44+
45+
- Rules live in `src/rules/`
46+
- Tests go in `src/rules/__tests__/`
47+
- Add it to the `recommended` config (under `src/configs/recommended.ts`)
48+
49+
3. **Document your rule:**
50+
51+
- Update the rules list in `README.md`
52+
53+
## Linting, Formatting, and Testing
54+
55+
Run the following before committing:
56+
57+
```bash
58+
npm run lint # Check for linting issues
59+
npm run format # Format code with Prettier
60+
npm run test # Run all tests
61+
```
62+
63+
To run tests for a specific rule:
64+
65+
```bash
66+
npm run test rule-name
67+
```
68+
69+
> Replace `rule-name` with the file name of your rule.
70+
71+
## Playground
72+
73+
If you want to test how the rules work on PHP code, you can use the **playground** directory. This allows you to quickly run the plugin on sample PHP files.
74+
75+
1. Place your PHP code in the `/playground` directory.
76+
2. Run the following command to lint the files using the local project rules:
77+
78+
```bash
79+
npm run playground
80+
```
81+
82+
This will lint all the PHP files in the `/playground` directory with the plugin's current rules.
83+
84+
Don't forget to build your code before running the playground, to ensure all changes are included in the linting process:
85+
86+
```bash
87+
npm run build
88+
```
89+
90+
You can also use `npm run build -- --watch` to automatically rebuild your code when you make changes.
91+
92+
## Submitting Issues
93+
94+
If you find a bug or want to request a feature, please open an issue and include:
95+
96+
- A clear description of the problem
97+
- Code snippets or test cases
98+
- ESLint and `eslint-plugin-php` versions
99+
100+
## Submitting Pull Requests
101+
102+
1. Push your changes to your fork.
103+
2. Open a pull request to the `main` branch of the original repository.
104+
3. Include:
105+
- Tests for your rule or fix
106+
- Updates to the rule list in the README (if applicable)
107+
- Entry in the recommended config (if applicable)
108+
4. Make sure all lint, format, and test checks pass.
109+
110+
We’ll review your PR as soon as possible. Thank you for contributing to `eslint-plugin-php`!
111+
112+
## Resources
113+
114+
- **Creating custom ESLint rules**:
115+
https://eslint.org/docs/latest/extend/custom-rules
116+
117+
- **Explore the PHP AST**:
118+
Use [AST Explorer](https://astexplorer.net/) with the **PHP** language selected to view and understand abstract syntax trees. This is very helpful for rule development.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ export default defineConfig([
6868
| `php/no-array-keyword` | Disallow the use of the array keyword | 🔧 | ||
6969
| `php/require-visibility` | Require visibility for class methods and properties | | 💡 ||
7070

71-
## Development
71+
## Contributing
7272

73-
Use `npm run playground` to lint local PHP files under the `playground` directory.
73+
Contributions are welcome! Please read the [contributing guidelines](CONTRIBUTING.md) for more information.

0 commit comments

Comments
 (0)