Skip to content
Permalink
Browse files

Chore: Change configurations message

Fix #3368
  • Loading branch information
molant committed Nov 21, 2019
1 parent d59be96 commit 7c72e1a7c3fd831755c36bae2732cfa15de06ea2
Showing with 25 additions and 94 deletions.
  1. +22 −86 packages/hint/docs/user-guide/index.md
  2. +3 −8 packages/hint/src/lib/cli/analyze.ts
@@ -2,17 +2,19 @@

## Getting started

If you want to have an idea of what `webhint` does and you
have an updated version of `npm` (v5.2.0) and [Node.js LTS (v8.9.2)
or later, x64 version recommended][nodejs] you can use the
following command:
If you want to have an idea of what `webhint` does you will
need to use [Node.js 10 or later, x64 version recommended][nodejs]
and run the following command:

```bash
npx hint https://example.com
```

The recommended way of running webhint is as a `devDependency` of
your project.
You can also run webhint from within [VS Code][] and as a
[browser extension][].

If you are going to add it to your project, the recommended way
is as a `devDependency`:

```bash
npm install hint --save-dev
@@ -35,89 +37,22 @@ And run it via:
npm run webhint
```

You can also run webhint from within [VS Code][] and as a
[browser extension][].

**NOTE**: If you run into any issues during the install process
please check the [troubleshoot section](./troubleshoot/summary.md).

`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 recommended way to create the configuration file is by running:

```bash
npm create hintrc
```

This command will start a wizard that will ask you a series of
questions (e.g.: do you want to use a predefined `configuration` or prefer to
create one with the installed resource, what connector to use, formatter,
hints, etc.). Answer them and you will end up with something similar to the
following if you decided to use a predefined configuration:

```json
{
"extends": ["configurationName"]
}
```

or the following if custom:

```json
{
"connector": {
"name": "connectorName"
},
"formatters": ["formatterName"],
"hints": {
"hint1": "error",
"hint2": "warning",
"hint3": "off"
},
"hintsTimeout": 120000
...
}
```

Then you have to run the following command to scan a website:

```bash
hint https://example.com
```
You can also use webhint to analyze local files or directories and get
hints on different areas that are not available from a website (e.g.:
hints related to JSX, `tsconfig.json`, etc.).

Wait a few seconds and you will get something similar to the following:
Depending on the target to analyze it will use:

![Example output for the summary formatter](images/summary-output.png)
* [web-recommended][] if analyzing a website (i.e.: target starts with
`http(s)://`).
* [development][] if analyzing a local file or directory.

It might take a few minutes to get some of the results. Some of the
hints (e.g.: [`SSL Labs`][ssl labs]) can take a few minutes
to report the results.

### Default configuration

To run `webhint` you need a `.hintrc` file. If you do not have one,
`webhint` will use the [`web-recommended` set of hints][web recommended]
to analyze an URL or [`development`][development] if you are analyzing
an existing directory or file in your filesystem.
This configuration will be equivalent to the following `.hintrc`:

```json
{
"extends": ["web-recommended"]
}
```

or

```json
{
"extends": ["development"]
}
```
If you want to change the connector, hints, etc. you can add a `.hintrc`
file in the current folder. To learn more about the format and the
options visit [configuring webhint][].

### Further reading

@@ -132,9 +67,10 @@ about the different pieces:

<!-- Link labels: -->

[configuring webhint]: https://webhint.io/docs/user-guide/configuring-webhint/summary/
[browser extension]: https://webhint.io/docs/user-guide/extensions/extension-browser/
[development]: https://webhint.io/docs/user-guide/configurations/configuration-development/
[nodejs]: https://nodejs.org/en/download/current/
[web recommended]: https://github.com/webhintio/hint/blob/master/packages/configuration-web-recommended/index.json
[development]: https://github.com/webhintio/hint/blob/master/packages/configuration-development/index.json
[ssl labs]: https://webhint.io/docs/user-guide/hints/hint-ssllabs/
[VS Code]: https://webhint.io/docs/user-guide/extensions/vscode-webhint/
[browser extension]: https://webhint.io/docs/user-guide/extensions/extension-browser/
[web-recommended]: https://webhint.io/docs/user-guide/configurations/configuration-web-recommended/
@@ -173,15 +173,10 @@ const sendTelemetryIfEnabled = async (userConfig: UserConfig) => {
* defaults will be used.
*/
const showDefaultMessage = () => {
const defaultMessage = `${chalk.yellow(`Couldn't find any valid configuration`)}
const defaultMessage = `Using the built-in configuration.
Visit https://webhint.io/docs/user-guide/ to learn how to create your own configuration.`;

Running hint with the default configuration.
Learn more about how to create your own configuration at:
${chalk.green('https://webhint.io/docs/user-guide/')}`;

printFrame(defaultMessage);
logger.log(defaultMessage);
};

const areFiles = (targets: URL[]) => {

0 comments on commit 7c72e1a

Please sign in to comment.
You can’t perform that action at this time.