eslint-multiple-parsers

Multiple parsers for ESLint

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
eslint-multiple-parsers
001.0.16 years ago6 years agoMinified + gzip package size for eslint-multiple-parsers in KB

Readme

eslint-multiple-parsers
Build Status Greenkeeper badge JavaScript Style Guide
Use multiple parsers in one ESLint run.

DEPRECATION NOTICE

Superseded by ESLint configuration based on glob patterns.

What

ESLint can currently have configured only a single parser
. If your code has multiple languages and thus requires multiple parsers, you’re out of luck.
Or, are you?

Usage

Install this package:
npm i --save-dev eslint-multiple-parsers
Specify this package as the parser and configure the multiple parsers like so:
.eslintrc.json:
{
  "parser": "eslint-multiple-parsers",
  "parserOptions": {
    "parsers": [
      {
        "test": ".*\\.js$",
        "path": "babel-eslint",
        "options": {
          "sourceType": "module"
        }
      },
      {
        "test": ".*\\.ts$",
        "path": "typescript-eslint-parser"
      }
    ]
  }
}

The test is a regular expression. It will be matched against the basename of the file path. The first matched parser will be used.
Of course, any specified parsers must be installed.
Notice: the parser path must be a package path. A relative path will not work. PR welcome.