Permalink
Browse files

Docs: Improve documentation around `.hintrc`

Fix #884
Fix #997
Fix #1174
  • Loading branch information...
molant committed Oct 22, 2018
1 parent 8d6c5ad commit a05e45bce1bad3b5b571bf3f1d05c3c9a98c8223
@@ -0,0 +1,85 @@
# Configuring webhint
There are 2 ways in which you can configure `webhint`:
1. Via a `.hintrc` file.
1. Adding a `hintConfig` property in your `package.json`.
To create a basic `.hintrc` file you can use the following command:
```bash
npm create hintrc
```
If `webhint` cannot find a (valid) configuration, it will use a default
one and warn you about it.
![webhint default configuration warning](images/default-config.png)
In both cases, the format used is the same. The following is an example
for a `.hintrc`:
```json
{
"connector": {
"name": "connectorName"
},
"formatters": ["formatterName"],
"parsers": ["parserName"],
"hints": {
"hint1": "error",
"hint2": "warning",
"hint3": "off"
},
"hintsTimeout": 120000
}
```
And for a `package.json`:
```json
{
"name": "project name",
"dependencies": {
...
},
"scripts": {
...
},
...
"hintConfig": {
"connector": {
"name": "connectorName"
},
"formatters": ["formatterName"],
"parsers": ["parserName"],
"hints": {
"hint1": "error",
"hint2": "warning",
"hint3": "off"
},
"hintsTimeout": 120000
}
}
```
The main things you can configure are:
* `connector`: how to access the resources.
* `formatter`s: how to output the results.
* `parser`s: how to handle special files like stylesheets, JavaScript,
manifest, etc.
* `hint`s: what to test for and the `severity` it should have.
The `severity` of a `hint` can be:
* `off`: The `hint` will not be run. This is the same as deleting it
from the `.hintrc`.
* `warning`: If the `hint` finds any issue it will be reported but the
exit code will be `0`.
* `error`: If the `hint` finds any issue it will be reported and the
exit code will be `1`.
`webhint` allows you to configure it in many different ways. Please
check the other entires under _Configuring webhint_ and the main page
for each package to have more details.

This file was deleted.

Oops, something went wrong.
@@ -19,11 +19,13 @@ npm install -g --engine-strict hint
You can also install it as a `devDependency` if you prefer not to
have it globally (which is the team's preferred option).
The next thing that `webhint` needs is a `.hintrc` file. By
default, `webhint` will look for this file first in the current
folder and then in the user's home directory.
`webhint` needs a configuration file to know what `hint`s,
`connector`s, etc. to use. By default it will look for a `.hintrc`
file in the current folder and then in the user's home directory.
If none is found, it will use a built-in default configuration and
warn the user about it.
The fastest and easiest way to create one is by running:
The recommended way to create the configuration file is by running:
```bash
npm create hintrc

0 comments on commit a05e45b

Please sign in to comment.