Skip to content

Commit

Permalink
Docs: add minor formatting improvement to paragraph about parsers (#8816
Browse files Browse the repository at this point in the history
)

* Consistently use code formatting for method names
* Avoid duplicating info about which method gets used
  • Loading branch information
not-an-aardvark authored and platinumazure committed Jun 27, 2017
1 parent 1df6a01 commit 5ad8b70
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/developer-guide/working-with-plugins.md
Expand Up @@ -221,9 +221,9 @@ Add these keywords into your `package.json` file to make it easy for others to f

### Working with Custom Parsers

If you want to use your own parser and provide additional capabilities for your rules, you can specify your own custom parser. By default, the ESLint parser will use its parse method that takes in the source code as a first parameter and additional optional parameters as a second parameter to create an AST. You can specify a `parse` configuration to use your own custom parser. If a `parseForESLint` method is exposed, this method will be used to parse. Otherwise, the parser will use the parse method. `parseForESLint` behaves like `parse` and takes in the the source code and optional ESLint configurations. When `parseForESLint` is called, the method should return an object that contains the required property `ast` and an optional `services` property. `ast` should contain the AST. The `services` property contains the parser-dependent services. The value of the service property is available to rules as `context.parserServices`
If you want to use your own parser and provide additional capabilities for your rules, you can specify your own custom parser. If a `parseForESLint` method is exposed on the parser, this method will be used to parse the code. Otherwise, the `parse` method will be used. Both methods should take in the the source code as the first argument, and an optional configuration object as the second argument (provided as `parserOptions` in a config file). The `parse` method should simply return the AST. The `parseForESLint` method should return an object that contains the required property `ast` and an optional `services` property. `ast` should contain the AST. The `services` property can contain any parser-dependent services (such as type checkers for nodes). The value of the `services` property is available to rules as `context.parserServices`.

If no parseForESLint function is found, the parser will use the default parse method with the source code and the parser options. You can find a ESLint parser project [here](https://github.com/eslint/typescript-eslint-parser).
You can find an ESLint parser project [here](https://github.com/eslint/typescript-eslint-parser).

{

Expand Down

0 comments on commit 5ad8b70

Please sign in to comment.