All Projects β†’ babel β†’ Babel Eslint

babel / Babel Eslint

Licence: mit
πŸ—Ό A wrapper for Babel's parser used for ESLint (renamed to @babel/eslint-parser)

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to Babel Eslint

Asts Workshop
Improved productivity πŸ’― with the practical πŸ€“ use of the power πŸ’ͺ of Abstract Syntax Trees 🌳 to lint ⚠️ and transform πŸ”€ your code
Stars: ✭ 253 (-91.47%)
Mutual labels:  eslint, babel
2life-server
πŸ’Œ εŒη”ŸοΌšι‡θ§ε¦δΈ€εŠηš„ηΎŽε₯½οΌšοΌ‰οΌˆζœεŠ‘η«―οΌ‰
Stars: ✭ 66 (-97.77%)
Mutual labels:  babel, eslint
Express Mongoose Es6 Rest Api
πŸ’₯ A boilerplate application for building RESTful APIs Microservice in Node.js using express and mongoose in ES6 with code coverage and JsonWebToken Authentication
Stars: ✭ 2,811 (-5.23%)
Mutual labels:  eslint, babel
Yarsk
Don't use this, use Create React App
Stars: ✭ 199 (-93.29%)
Mutual labels:  eslint, babel
Threejs Webpack Es6 Boilerplate
A basic boilerplate for a Three.js project compiled with Webpack and transpiled via Babel to enable using ES6 syntax.
Stars: ✭ 267 (-91%)
Mutual labels:  eslint, babel
Front End Guide
πŸ“š Study guide and introduction to the modern front end stack.
Stars: ✭ 14,073 (+374.48%)
Mutual labels:  eslint, babel
webpack-gulp-wordpress-starter-theme
A WordPress theme with Webpack & Gulp
Stars: ✭ 110 (-96.29%)
Mutual labels:  babel, eslint
Express Webpack React Redux Typescript Boilerplate
πŸŽ‰ A full-stack boilerplate that using express with webpack, react and typescirpt!
Stars: ✭ 156 (-94.74%)
Mutual labels:  eslint, babel
React Native Navigation Redux Starter Kit
React Native Navigation(v2) Starter Kit with Redux, Saga, ESLint, Babel, Jest and Facebook SDK 😎
Stars: ✭ 271 (-90.86%)
Mutual labels:  eslint, babel
Webpack-Starter-Kit
Webpack 4 stater kit with SCSS, PostCSS, Babel & ESLint
Stars: ✭ 41 (-98.62%)
Mutual labels:  babel, eslint
Sharec
πŸ“¦ Store your configs in one place and share between projects without any pain
Stars: ✭ 198 (-93.32%)
Mutual labels:  eslint, babel
eslint-config-satya164
An ESLint config with automatic overrides for common environments such as TypeScript, Jest etc.
Stars: ✭ 45 (-98.48%)
Mutual labels:  babel, eslint
React Redux Webpack Starter
Learning react
Stars: ✭ 189 (-93.63%)
Mutual labels:  eslint, babel
React Starter Kit
React, Redux, Webpack, Material UI, Boostrap 4, Code Splitting, HMR
Stars: ✭ 229 (-92.28%)
Mutual labels:  eslint, babel
React Redux Universal Boilerplate
An Universal ReactJS/Redux Boilerplate
Stars: ✭ 165 (-94.44%)
Mutual labels:  eslint, babel
frontplate-cli
γƒ•γƒ­γƒ³γƒˆγ‚¨γƒ³γƒ‰γƒ“γƒ«γƒ‰CLI
Stars: ✭ 25 (-99.16%)
Mutual labels:  babel, eslint
React Itunes Search
🎡Simple web app for itunes search with React
Stars: ✭ 147 (-95.04%)
Mutual labels:  eslint, babel
Lighthouse Badges
🚦Generate badges (shields.io) based on Lighthouse performance.
Stars: ✭ 150 (-94.94%)
Mutual labels:  eslint, babel
gulp-webpack-boilerplate
A good foundation for your next frontend project.
Stars: ✭ 56 (-98.11%)
Mutual labels:  babel, eslint
starbase
⭐ Production-ready website boilerplate made with webpack 5, modern JS (via Babel 7) & Sass
Stars: ✭ 70 (-97.64%)
Mutual labels:  babel, eslint

babel-eslint npm travis npm-downloads

NOTE: babel-eslint is now @babel/eslint-parser and has moved into the Babel monorepo.

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

Breaking changes in v11.x.x

As of the v11.x.x release, babel-eslint now requires Babel as a peer dependency and expects a valid Babel configuration file to exist. This ensures that the same Babel configuration is used during both linting and compilation.

v11 also changes some AST node types to match espree v6:

  • ExperimentalSpreadProperty became SpreadElement.
  • ExperimentalRestProperty became RestElement.
  • Literal became JSXText (for JSXText).

When should I use babel-eslint?

ESLint's default parser and core rules only support the latest final ECMAScript standard and do not support experimental (such as new features) and non-standard (such as Flow or TypeScript types) syntax provided by Babel. babel-eslint is a parser that allows ESLint to run on source code that is transformed by Babel.

Note: You only need to use babel-eslint if you are using Babel to transform your code. If this is not the case, please use the relevant parser for your chosen flavor of ECMAScript (note that the default parser supports all non-experimental syntax as well as JSX).

How does it work?

ESLint allows for the use of custom parsers. When using this plugin, your code is parsed by Babel's parser (using the configuration specified in your Babel configuration file) and the resulting AST is transformed into an ESTree-compliant structure that ESLint can understand. All location info such as line numbers, columns is also retained so you can track down errors with ease.

Note: ESLint's core rules do not support experimental syntax and may therefore not work as expected when using babel-eslint. Please use the companion eslint-plugin-babel plugin for core rules that you have issues with.

Usage

Installation

$ npm install eslint babel-eslint --save-dev
# or
$ yarn add eslint babel-eslint -D

Note: babel-eslint requires babel/core@>=7.2.0 and a valid Babel configuration file to run. If you do not have this already set up, please see the Babel Usage Guide.

Setup

To use babel-eslint, "babel-eslint" must be specified as the parser in your ESLint configuration file (see here for more detailed information).

.eslintrc.js

module.exports = {
  parser: "babel-eslint",
};

With the parser set, your configuration can be configured as described in the Configuring ESLint documentation.

Note: The parserOptions described in the official documentation are for the default parser and are not necessarily supported by babel-eslint. Please see the section directly below for supported parserOptions.

Additional parser configuration

Additional configuration options can be set in your ESLint configuration under the parserOptions key. Please note that the ecmaFeatures config property may still be required for ESLint to work properly with features not in ECMAScript 5 by default.

  • requireConfigFile (default true) can be set to false to allow babel-eslint to run on files that do not have a Babel configuration associated with them. This can be useful for linting files that are not transformed by Babel (such as tooling configuration files), though we recommend using the default parser via glob-based configuration. Note: babel-eslint will not parse any experimental syntax when no configuration file is found.
  • 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.
  • ecmaFeatures.globalReturn (default false) allow return statements in the global scope when used with sourceType: "script".
  • babelOptions passes through Babel's configuration loading and merging options (for instance, in case of a monorepo). When not defined, babel-eslint will use Babel's default configuration file resolution logic.

.eslintrc.js

module.exports = {
  parser: "babel-eslint",
  parserOptions: {
    sourceType: "module",
    allowImportExportEverywhere: false,
    ecmaFeatures: {
      globalReturn: false,
    },
    babelOptions: {
      configFile: "path/to/config.js",
    },
  },
};

.eslintrc.js using glob-based configuration

This configuration would use the default parser for all files except for those found by the "files/transformed/by/babel/*.js" glob.

module.exports = {
  rules: {
    indent: "error"
  },
  overrides: [
    {
      files: ["files/transformed/by/babel/*.js"],
      parser: "babel-eslint",
    }
  ]
};

Run

$ ./node_modules/.bin/eslint yourfile.js

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: ["error", { 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.

Questions and support

If you have an issue, please first check if it can be reproduced with the default parser and with the latest versions of eslint and babel-eslint. If it is not reproducible with the default parser, it is most likely an issue with babel-eslint.

For questions and support please visit the #discussion Babel Slack channel (sign up here) or the ESLint Gitter.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].