escope was hardcoded to sourcetype: "module" and ecmaVersion: "6" This changes it to take the configuration from the eslint options and still defaulting to "module" and "6". This is done by having to global variables, as monkeypatch is only triggered once. To fix scoping issues, the same logic as in eslint is applied. It disables the nodejs scope if the sourceType is module.
babel-eslint
babel-eslint allows you to lint ALL valid Babel code with the fantastic ESLint.
babel-eslint is successfully linting babel and many other projects.
If there is an issue, first check if it can be reproduced with the regular parser or with the latest versions of
eslintandbabel-eslint!
For questions and support please visit the #linting babel slack channel (sign up here)!
Note that the
ecmaFeaturesconfig property may still be required for ESLint to work properly with features not in ECMAScript 5 by default. Examples areglobalReturnandmodules)
Known Issues
Flow:
Check out eslint-plugin-flow-vars: An
eslintplugin that makes flow type annotations global variables and marks declarations as used. Solves the problem of false positives withno-undefandno-unused-vars.
no-undeffor global flow types:ReactElement,ReactClass#130- Workaround: define types as globals in
.eslintrcor define types and import themimport type ReactElement from './types'
- Workaround: define types as globals in
no-unused-vars/no-undefwith 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-varswith jsx
Please check out eslint-plugin-babel for other issues such as (and more):
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
Install
$ npm install eslint@1.x babel-eslint@5 --save-dev
$ npm install eslint@2.x babel-eslint@6 --save-dev
Setup
.eslintrc
{
"parser": "babel-eslint",
"rules": {
"strict": 0
}
}
Check out the ESLint docs for all possible rules.
Run
$ eslint your-files-here