From 5220888b2b28976821038284d4771e6799bc8e43 Mon Sep 17 00:00:00 2001 From: Francesco Trotta Date: Sun, 29 Dec 2024 12:48:01 +0100 Subject: [PATCH] docs: update cusom parser docs --- docs/src/extend/custom-parsers.md | 32 ++++++++++++++++++++++++++++--- docs/src/extend/ways-to-extend.md | 2 +- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/docs/src/extend/custom-parsers.md b/docs/src/extend/custom-parsers.md index f9cbb9f08726..80b08eea2f3d 100644 --- a/docs/src/extend/custom-parsers.md +++ b/docs/src/extend/custom-parsers.md @@ -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 }; ``` @@ -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 { diff --git a/docs/src/extend/ways-to-extend.md b/docs/src/extend/ways-to-extend.md index 3bf8314e1afa..2684d340974a 100644 --- a/docs/src/extend/ways-to-extend.md +++ b/docs/src/extend/ways-to-extend.md @@ -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). 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