Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update custom parser docs #19288

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions docs/src/extend/custom-parsers.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,29 @@ Once you've published the npm package, you can use it by adding the package to y
npm install eslint-parser-myparser --save-dev
```

Then add the custom parser to your ESLint configuration file with the `parser` property. For example:
Then add the custom parser to your ESLint configuration file with the `languageOptions.parser` property. For example:

```js
// eslint.config.js

const myparser = require("eslint-parser-myparser");

module.exports = [{
languageOptions: {
parser: myparser
},
// ... rest of configuration
}];
```

When using legacy configuration, specify the `parser` property as a string:

```js
// .eslintrc.js

module.exports = {
parser: 'eslint-parser-myparser',
// ... rest of configuration
parser: "eslint-parser-myparser",
// ... rest of configuration
};
```

Expand Down Expand Up @@ -161,6 +176,17 @@ module.exports = { parseForESLint };

Include the custom parser in an ESLint configuration file:

```js
// eslint.config.js
module.exports = [{
languageOptions: {
parser: require("./path/to/awesome-custom-parser")
}
}];
```

Or if using legacy configuration:

```js
// .eslintrc.json
{
Expand Down
2 changes: 1 addition & 1 deletion docs/src/extend/ways-to-extend.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ ESLint ships with a built-in JavaScript parser (Espree), but custom parsers allo

For example, the custom parser [@typescript-eslint/parser](https://typescript-eslint.io/packages/parser) extends ESLint to lint TypeScript code.

Custom parsers **cannot** be included in a plugin, unlike the other extension types.
Custom parsers can be also included in a plugin.

To learn more about creating a custom parser, refer to [Custom Parsers](custom-parsers).
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy