| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| lib/ | 12-May-2024 | - | 913 | 716 | ||
| node_modules/ | 12-May-2024 | - | 104,975 | 64,089 | ||
| LICENSE | D | 12-May-2024 | 1.1 KiB | 23 | 18 | |
| README.md | D | 12-May-2024 | 4.2 KiB | 104 | 72 | |
| package.json | D | 12-May-2024 | 1.7 KiB | 67 | 67 |
README.md
1# babel-eslint [](https://www.npmjs.com/package/babel-eslint) [](https://travis-ci.org/babel/babel-eslint) [](https://www.npmjs.com/package/babel-eslint) 2 3**babel-eslint** allows you to lint **ALL** valid Babel code with the fantastic 4[ESLint](https://github.com/eslint/eslint). 5 6### Why Use babel-eslint 7 8You 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). 9 10--- 11 12> 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`! 13 14For questions and support please visit the [`#discussion`](https://babeljs.slack.com/messages/discussion/) babel slack channel (sign up [here](https://github.com/babel/notes/issues/38)) or eslint [gitter](https://gitter.im/eslint/eslint)! 15 16> 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`). 17 18## Known Issues 19 20Flow: 21> Check out [eslint-plugin-flowtype](https://github.com/gajus/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`. 22- `no-undef` for global flow types: `ReactElement`, `ReactClass` [#130](https://github.com/babel/babel-eslint/issues/130#issuecomment-111215076) 23 - Workaround: define types as globals in `.eslintrc` or define types and import them `import type ReactElement from './types'` 24- `no-unused-vars/no-undef` with Flow declarations (`declare module A {}`) [#132](https://github.com/babel/babel-eslint/issues/132#issuecomment-112815926) 25 26Modules/strict mode 27- `no-unused-vars: [2, {vars: local}]` [#136](https://github.com/babel/babel-eslint/issues/136) 28 29Please check out [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) for React/JSX issues 30- `no-unused-vars` with jsx 31 32Please check out [eslint-plugin-babel](https://github.com/babel/eslint-plugin-babel) for other issues 33 34## How does it work? 35 36ESLint allows custom parsers. This is great but some of the syntax nodes that Babel supports 37aren't supported by ESLint. When using this plugin, ESLint is monkeypatched and your code is 38transformed into code that ESLint can understand. All location info such as line numbers, 39columns is also retained so you can track down errors with ease. 40 41Basically `babel-eslint` exports an [`index.js`](/index.js) that a linter can use. 42It just needs to export a `parse` method that takes in a string of code and outputs an AST. 43 44## Usage 45 46### Supported ESLint versions 47 48ESLint | babel-eslint 49------------ | ------------- 504.x | >= 6.x 513.x | >= 6.x 522.x | >= 6.x 531.x | >= 5.x 54 55### Install 56 57Ensure that you have substituted the correct version lock for `eslint` and `babel-eslint` into this command: 58 59```sh 60$ npm install eslint@4.x babel-eslint@8 --save-dev 61# or 62$ yarn add eslint@4.x babel-eslint@8 -D 63``` 64 65### Setup 66 67**.eslintrc** 68 69```json 70{ 71 "parser": "babel-eslint", 72 "rules": { 73 "strict": 0 74 } 75} 76``` 77 78Check out the [ESLint docs](http://eslint.org/docs/rules/) for all possible rules. 79 80### Configuration 81 82- `sourceType` can be set to `'module'`(default) or `'script'` if your code isn't using ECMAScript modules. 83- `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. 84- `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. 85 86**.eslintrc** 87 88```json 89{ 90 "parser": "babel-eslint", 91 "parserOptions": { 92 "sourceType": "module", 93 "allowImportExportEverywhere": false, 94 "codeFrame": true 95 } 96} 97``` 98 99### Run 100 101```sh 102$ eslint your-files-here 103``` 104