|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thanks for contributing! |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```sh |
| 8 | +git clone https://github.com/ota-meshi/eslint-plugin-svelte.git |
| 9 | +cd eslint-plugin-svelte |
| 10 | +yarn |
| 11 | +``` |
| 12 | + |
| 13 | +## Running the tests |
| 14 | + |
| 15 | +```sh |
| 16 | +yarn test |
| 17 | +``` |
| 18 | + |
| 19 | +To run the tests with debugging log, you can use `yarn test:debug`. |
| 20 | + |
| 21 | +This is an [ESLint](http://eslint.org) plugin. Documentation for the APIs that it uses can be found on ESLint's [Working with Plugins](http://eslint.org/docs/developer-guide/working-with-plugins) page. |
| 22 | + |
| 23 | +This plugin is used to lint itself. The style is checked when `yarn lint` is run, and the build will fail if there are any linting errors. You can use `yarn lint-fix` to fix some linting errors. |
| 24 | + |
| 25 | +## Other Development Tools |
| 26 | + |
| 27 | +- `yarn test` runs tests. |
| 28 | +- `yarn cover` runs tests and measures coverage. |
| 29 | +- `yarn new [new-rule-name]` generate the files needed to implement the new rule. |
| 30 | +- `yarn update` runs in order to update readme and recommended configuration. |
| 31 | +- `yarn docs:watch` launch the document site in development mode. |
| 32 | + |
| 33 | +## Test the Rule |
| 34 | + |
| 35 | +Rule testing almost always uses fixtures. |
| 36 | +For example, for an `indent` rule, the `.ts` file that runs the test is `tests/src/rules/indent.ts` and the fixture is in `tests/fixtures/rules/indent`. |
| 37 | +The fixture directory has an `invalid` directory and a `valid` directory. |
| 38 | + |
| 39 | +- The `invalid` directory contains test cases where the rule reports problems. |
| 40 | +- The `valid` directory contains test cases where the rule does not report a problem. |
| 41 | + |
| 42 | +The fixture input file should be named `*-input.svelte`. It is automatically collected and tested. |
| 43 | +If your test requires configuration, you need to add a json file with the configuration. |
| 44 | + |
| 45 | +- If you want to apply a configuration to `my-test-input.svelte`, add `my-test-config.json`. |
| 46 | +- If you want to apply the same configuration to all the fixtures in that directory, add `_config.json`. |
| 47 | + |
| 48 | +To verify the output of invalid test cases requires `*-errors.json`, and `*-output.svelte` (for auto-fix). However, you don't have to add them yourself. If they do not exist, they will be automatically generated when you run the test. In other words, delete them manually when you want to recreate them. |
| 49 | + |
| 50 | +**Tips**: |
| 51 | + |
| 52 | +If you want to test only one rule, run the following command (for `indent` rule): |
| 53 | + |
| 54 | +```sh |
| 55 | +yarn test -g indent |
| 56 | +``` |
| 57 | + |
| 58 | +Take <https://stackoverflow.com/questions/10832031/how-to-run-a-single-test-with-mocha> as reference for details. |
| 59 | + |
| 60 | +If you want to test only `my-test-input.svelte`, add `my-test-config.json` and save `{"only": true}`. |
| 61 | +(Note that `{"only": true}` must be removed before making a pull request.) |
| 62 | + |
| 63 | +## Commit messages |
| 64 | + |
| 65 | +Please view [commitlint](https://commitlint.js.org) and [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional) for more details. |
| 66 | + |
| 67 | +## Publishing |
| 68 | + |
| 69 | +We're using [changesets](https://github.com/changesets/changesets) for version management, CHANGELOG and releasing automatically. |
| 70 | + |
| 71 | +Please view [changesets-bot](https://github.com/apps/changeset-bot) and its [action](https://github.com/changesets/action) for more details. |
0 commit comments