Skip to content

Commit

Permalink
Update the README section 'How to create a new rule' (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
tilmanschweitzer committed Nov 22, 2015
1 parent 6cf66b1 commit 312f461
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,39 @@ If it is time to release, @Gillespie59 will bump the version in `package.json`,
## How to create a new rule
Here are the things you should do before sending a Pull Request with a new Rule :
We appreciate contributions and the following notes will help you before you send a Pull Request.
- Create a JavaScript file for the new rule in the rules directory
- Create an unit test for this rule in the test directory (with the same name)
- Update the main index.js file, in order to add the new rule in the 'rules' property, and set the default configuration in the rulesConfig property
- Update the "Rules" part of the README.md file with a small description of the rule and its default configuration. In this file, you have to add your rule in the default JSON configuration object.
### Check the issues
Have a look at the existing issues, they may exist similar issues with useful information.
### Files you have to create
* `rules/<your-rule>.js`
* JavaScript file with the new rule
* The filename `<your-rule>` is exactly the usage name in eslint configs `angular/<your-rule>`
* Have a look at the `angularRule` wrapper and the `utils` (both in `rules/utils/`) - they probably make things easier for you
* Add a documentation comment to generate a markdown documentation with the `gulp docs` task
* `test/<your-rule>.js`
* Write some tests and execute them with `gulp test`
* Have a look at the coverage reports `coverage/lcov-report/index.html`
* `examples/<your-rule>.js`
* Add some examples for the documentation
* Run the `gulp docs` task to test the examples and update the markdown documentation
* `docs/<your-rule>.js`
* Generated by the `gulp docs` task
### Files you have to touch
* `index.js`
* Add your rule `rulesConfiguration.addRule('<your-rule>', [0, {someConfig: 'someValue'])`
### Before you open your PR
* Check that the `gulp` is working
* Commit generated changes the README.md and the documentation markdown
### Rules specific for Angular 1 or 2
We can use a property, defined in the ESLint configuration file, in order to know which version is used : Angular 1 or Angular 2. based on this property, you can create rules for each version.
Expand Down

0 comments on commit 312f461

Please sign in to comment.