1.0.1 • Published 7 years ago

eslint-multiple-parsers v1.0.1

Weekly downloads
111
License
ISC
Repository
github
Last release
7 years ago

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.