UNPKG

1.39 kBMarkdownView Raw
1# JavaScript (`@hint/parser-javascript`)
2
3The `javascript` parser allows hints to analyze `JavaScript` files.
4
5This package is installed automatically by webhint:
6
7```bash
8npm install hint --save-dev
9```
10
11To use it, activate it via the [`.hintrc`][hintrc] configuration file:
12
13```json
14{
15 "connector": {...},
16 "formatters": [...],
17 "hints": {
18 ...
19 },
20 "parsers": ["javascript"],
21 ...
22}
23```
24
25**Note**: The recommended way of running webhint is as a `devDependency` of
26your project.
27
28## Events emitted
29
30This `parser` emits the following events:
31
32* `parse::start::javascript` of type `Event` which contains the following
33 information:
34
35 * `resource`: the resource we are going to parse.
36
37* `parse::end::javascript`, of type `ScriptParse` which contains the following
38 information:
39
40 * `ast`: an `ESTree` AST generated from the script.
41 * `element`: an `HTMLElement` reference if the source was inline
42 in HTML; `null` otherwise.
43 * `resource`: the parsed resource. If the JavaScript is in
44 a `script tag` and not a file, the value will refer to the
45 HTML document containing the script.
46 * `sourceCode`: the raw source code that was parsed.
47 * `tokens`: a list of tokens generated from the source code.
48 * `walk`: helper methods for walking the AST.
49
50<!-- Link labels: -->
51
52[hintrc]: https://webhint.io/docs/user-guide/configuring-webhint/summary/