babel-eslint
Custom parser for ESLint
Last updated 2 months ago by hzoo .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-eslint 
SYNC missed versions from official npm registry.

babel-eslint npm travis npm-downloads

babel-eslint allows you to lint ALL valid Babel code with the fantastic ESLint.

Why Use babel-eslint

You only need to use babel-eslint if you are using types (Flow) or experimental features not supported in ESLint itself yet. Otherwise try the default parser (you don't have to use it just because you are using Babel).


If there is an issue, first check if it can be reproduced with the regular parser or with the latest versions of eslint and babel-eslint!

For questions and support please visit the #discussion babel slack channel (sign up here) or eslint gitter!

Note that the ecmaFeatures config property may still be required for ESLint to work properly with features not in ECMAScript 5 by default. Examples are globalReturn and modules).

Known Issues

Flow:

Check out eslint-plugin-flowtype: An eslint plugin that makes flow type annotations global variables and marks declarations as used. Solves the problem of false positives with no-undef and no-unused-vars.

  • no-undef for global flow types: ReactElement, ReactClass #130
    • Workaround: define types as globals in .eslintrc or define types and import them import type ReactElement from './types'
  • no-unused-vars/no-undef with Flow declarations (declare module A {}) #132

Modules/strict mode

  • no-unused-vars: [2, {vars: local}] #136

Please check out eslint-plugin-react for React/JSX issues

  • no-unused-vars with jsx

Please check out eslint-plugin-babel for other issues

How does it work?

ESLint allows custom parsers. This is great but some of the syntax nodes that Babel supports aren't supported by ESLint. When using this plugin, ESLint is monkeypatched and your code is transformed into code that ESLint can understand. All location info such as line numbers, columns is also retained so you can track down errors with ease.

Basically babel-eslint exports an index.js that a linter can use. It just needs to export a parse method that takes in a string of code and outputs an AST.

Usage

Supported ESLint versions

ESLint babel-eslint
4.x >= 6.x
3.x >= 6.x
2.x >= 6.x
1.x >= 5.x

Install

Ensure that you have substituted the correct version lock for eslint and babel-eslint into this command:

$ npm install eslint@4.x babel-eslint@8 --save-dev
# or
$ yarn add eslint@4.x babel-eslint@8 -D

Setup

.eslintrc

{
  "parser": "babel-eslint",
  "rules": {
    "strict": 0
  }
}

Check out the ESLint docs for all possible rules.

Configuration

  • sourceType can be set to 'module'(default) or 'script' if your code isn't using ECMAScript modules.
  • allowImportExportEverywhere (default false) can be set to true to allow import and export declarations to appear anywhere a statement is allowed if your build environment supports that. Otherwise import and export declarations can only appear at a program's top level.
  • codeFrame (default true) can be set to false to disable the code frame in the reporter. This is useful since some eslint formatters don't play well with it.

.eslintrc

{
  "parser": "babel-eslint",
  "parserOptions": {
    "sourceType": "module",
    "allowImportExportEverywhere": false,
    "codeFrame": true
  }
}

Run

$ eslint your-files-here

Current Tags

  • 10.0.1                                ...           latest (2 months ago)
  • 9.0.0-beta.3                                ...           next (4 months ago)
  • 5.0.4                                ...           prev (3 years ago)

129 Versions

  • 10.0.1                                ...           2 months ago
  • 10.0.0                                ...           2 months ago
  • 9.0.0                                ...           3 months ago
  • 8.2.6                                ...           4 months ago
  • 9.0.0-beta.3                                ...           4 months ago
  • 9.0.0-beta.2                                ...           4 months ago
  • 9.0.0-beta.1                                ...           5 months ago
  • 8.2.5                                ...           5 months ago
  • 8.2.4                                ...           5 months ago
  • 8.2.3                                ...           7 months ago
  • 8.2.2                                ...           9 months ago
  • 8.2.1                                ...           10 months ago
  • 8.2.0                                ...           10 months ago
  • 8.1.2                                ...           a year ago
  • 8.1.1                                ...           a year ago
  • 8.1.0                                ...           a year ago
  • 8.0.3                                ...           a year ago
  • 8.0.2                                ...           a year ago
  • 8.0.1                                ...           a year ago
  • 8.0.0                                ...           a year ago
  • 8.0.0-alpha.17                                ...           a year ago
  • 8.0.0-alpha.15                                ...           a year ago
  • 8.0.0-alpha.13                                ...           a year ago
  • 8.0.0-alpha.12                                ...           a year ago
  • 7.2.3                                ...           2 years ago
  • 7.2.2                                ...           2 years ago
  • 7.2.1                                ...           2 years ago
  • 7.2.0                                ...           2 years ago
  • 7.1.1                                ...           2 years ago
  • 7.1.0                                ...           2 years ago
  • 7.0.0                                ...           2 years ago
  • 6.1.2                                ...           2 years ago
  • 6.1.1                                ...           2 years ago
  • 6.1.0                                ...           2 years ago
  • 6.0.5                                ...           2 years ago
  • 6.0.4                                ...           3 years ago
  • 6.0.3                                ...           3 years ago
  • 5.0.4                                ...           3 years ago
  • 6.0.2                                ...           3 years ago
  • 6.0.1                                ...           3 years ago
  • 5.0.3                                ...           3 years ago
  • 5.0.2                                ...           3 years ago
  • 6.0.0                                ...           3 years ago
  • 5.0.1                                ...           3 years ago
  • 6.0.0-beta.6                                ...           3 years ago
  • 6.0.0-beta.5                                ...           3 years ago
  • 6.0.0-beta.4                                ...           3 years ago
  • 6.0.0-beta.3                                ...           3 years ago
  • 6.0.0-beta.2                                ...           3 years ago
  • 6.0.0-beta.1                                ...           3 years ago
  • 5.0.0                                ...           3 years ago
  • 4.1.8                                ...           3 years ago
  • 5.0.0-beta10                                ...           3 years ago
  • 4.1.7                                ...           3 years ago
  • 5.0.0-beta9                                ...           3 years ago
  • 5.0.0-beta8                                ...           3 years ago
  • 5.0.0-beta7                                ...           3 years ago
  • 5.0.0-beta6                                ...           3 years ago
  • 5.0.0-beta5                                ...           3 years ago
  • 5.0.0-beta4                                ...           3 years ago
  • 5.0.0-beta3                                ...           3 years ago
  • 5.0.0-beta2                                ...           3 years ago
  • 5.0.0-beta1                                ...           3 years ago
  • 4.1.6                                ...           3 years ago
  • 4.1.5                                ...           3 years ago
  • 4.1.4                                ...           3 years ago
  • 4.1.3                                ...           3 years ago
  • 4.1.2                                ...           3 years ago
  • 4.1.1                                ...           3 years ago
  • 4.1.0                                ...           3 years ago
  • 4.0.10                                ...           3 years ago
  • 4.0.9                                ...           3 years ago
  • 4.0.8                                ...           3 years ago
  • 4.0.7                                ...           3 years ago
  • 4.0.6                                ...           3 years ago
  • 4.0.5                                ...           3 years ago
  • 3.1.30                                ...           3 years ago
  • 4.0.4                                ...           3 years ago
  • 3.1.29                                ...           3 years ago
  • 4.0.3                                ...           3 years ago
  • 3.1.28                                ...           3 years ago
  • 4.0.2                                ...           3 years ago
  • 4.0.1                                ...           3 years ago
  • 4.0.0                                ...           3 years ago
  • 3.1.27                                ...           3 years ago
  • 3.1.26                                ...           3 years ago
  • 3.1.25                                ...           3 years ago
  • 3.1.24                                ...           3 years ago
  • 3.1.23                                ...           3 years ago
  • 3.1.22                                ...           3 years ago
  • 3.1.21                                ...           3 years ago
  • 3.1.20                                ...           3 years ago
  • 3.1.19                                ...           3 years ago
  • 3.1.18                                ...           3 years ago
  • 3.1.17                                ...           3 years ago
  • 3.1.16                                ...           3 years ago
  • 3.1.15                                ...           3 years ago
  • 3.1.14                                ...           3 years ago
  • 3.1.13                                ...           3 years ago
  • 3.1.12                                ...           3 years ago
  • 3.1.11                                ...           3 years ago
  • 3.1.10                                ...           3 years ago
  • 3.1.9                                ...           3 years ago
  • 3.1.8                                ...           3 years ago
  • 3.1.7                                ...           4 years ago
  • 3.1.6                                ...           4 years ago
  • 3.1.5                                ...           4 years ago
  • 3.1.4                                ...           4 years ago
  • 3.1.3                                ...           4 years ago
  • 3.1.1                                ...           4 years ago
  • 3.1.0                                ...           4 years ago
  • 3.0.1                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 2.0.2                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.14                                ...           4 years ago
  • 1.0.13                                ...           4 years ago
  • 1.0.12                                ...           4 years ago
  • 1.0.11                                ...           4 years ago
  • 1.0.10                                ...           4 years ago
  • 1.0.9                                ...           4 years ago
  • 1.0.8                                ...           4 years ago
  • 1.0.7                                ...           4 years ago
  • 1.0.6                                ...           4 years ago
  • 1.0.4                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Downloads
Today 13,134
This Week 40,008
This Month 187,633
Last Day 13,825
Last Week 72,830
Last Month 253,396
Dependencies (6)
Dev Dependencies (12)
Dependents (6719)