ESLint shareable config for ES2015+
$ npm install --save-dev eslint eslint-config-prev
extends field to your ESLint config (if you haven't created, create one):
Or if you prefer
Every config provided by this sharable config have ECMAScript modules support and
esnext features by default.
prev/react: The config for React projects with support for React and JSX.
prev/native: The config for ReactNative projects with support for React and JSX.
If you are on browser environment, you may need to add
browser option to
Whenever you need to use global variables for some case (e.g. refering external library), you can add them to your config to let ESLint recognize that variables are populated in
You can specify the variable name with
boolean value as a property of
globals object in the config. Specifying
true will allow the variable to be overwritten in the code or
false to disallow overwriting.
script source type
Every config enables
modules syntax by default. Add next to config if you want to disable it:
Using ES5 instead of ES2015+
This is not generally recommended, you can fallback to ES5 by adding next to your config if you need. This will change environment to ES5:
env:es6: falseparserOptions:ecmaVersion: 5
Note: However, ESLint might still show you error or warning since this sharable config is created in mind that you are in ES2015+ environment. In this case, you can safely disable the rule manually.
By default, the top-level configs described above enforce you to use ECMAScript modules and
esnext features via
If you don't want to be enforced by this rule to use them, you can choose what you just need and compose your own rules from
extends:- prev/rules/base- prev/rules/react
You can find more details about ESLint configuration here.
If you loved this config, please consider to add this fancy badge to your awesome project!