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.
- Code of Conduct
- Getting Started
- Development Workflow
- Linting, Formatting, and Testing
- Playground
- Submitting Issues
- Submitting Pull Requests
- Resources
We adhere to the OpenJS Foundation Code of Conduct. Please be respectful, inclusive, and constructive in all your communications and contributions.
If you're new to open source, this guide might also be helpful: How to Contribute to Open Source
To contribute, fork the repository, then clone your fork and install dependencies:
git clone https://github.com/YOUR_USERNAME/eslint-plugin-php.git
cd eslint-plugin-php
npm installReplace
YOUR_USERNAMEwith your actual GitHub username.
-
Create a new branch for each feature or fix:
git checkout -b fix/rule-name-or-feature
-
Make changes to the codebase:
- Rules live in
src/rules/ - Tests go in
src/rules/__tests__/ - Add it to the
recommendedconfig (undersrc/configs/recommended.ts)
- Rules live in
-
Document your rule:
- Update the rules list in
README.md
- Update the rules list in
Run the following before committing:
npm run lint # Check for linting issues
npm run format # Format code with Prettier
npm run test # Run all testsTo run tests for a specific rule:
npm run test rule-nameReplace
rule-namewith the file name of your rule.
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.
- Place your PHP code in the
/playgrounddirectory. - Run the following command to lint the files using the local project rules:
npm run playgroundThis will lint all the PHP files in the /playground directory with the plugin's current rules.
Don't forget to build your code before running the playground, to ensure all changes are included in the linting process:
npm run buildYou can also use npm run build -- --watch to automatically rebuild your code when you make changes.
If you find a bug or want to request a feature, please open an issue and include:
- A clear description of the problem
- Code snippets or test cases
- ESLint and
eslint-plugin-phpversions
- Push your changes to your fork.
- Open a pull request to the
mainbranch of the original repository. - Include:
- Tests for your rule or fix
- Updates to the rule list in the README (if applicable)
- Entry in the recommended config (if applicable)
- Make sure all lint, format, and test checks pass.
We’ll review your PR as soon as possible. Thank you for contributing to eslint-plugin-php!
-
Creating custom ESLint rules:
https://eslint.org/docs/latest/extend/custom-rules -
Explore the PHP AST:
Use AST Explorer with the PHP language selected to view and understand abstract syntax trees. This is very helpful for rule development.