eslint >= 4191
Adding to a project
npm install -D eslint-config-osedea@latestyarn add -D eslint-config-osedea@latest
Configuring rules for project
eslint-config-osedea comes with the following environments, some of which are already pre-configured, however you can mix-and-match the environments if you want.
Create a file called
.eslintrc.yml in the root of your project. Here, you will specify your rules, and extend one (or more) of the above rulesets.
extends:- osedea/react-native# This is the same as writing# - osedea/base# - osedea/esnext# - osedea/react# - osedea/react-native
extends:- osedea/es5- osedea/angular- osedea/testing# You can override rules from the linter here. Use at your own risk.# rules:# comma-dangle: off # For example, if you do not want the linter to check for dangling commas ever
Depending on your config, you may need to add a settings block to your
react config (if version is not specified, will assume latest version):
settings:react:version: "16.2.0" # for example, if not using latest versionflowVersion: "0.70" # for example
settings:lodash:pragma: "_" # name of lodash variable, default is _version: 4 # version of lodash, can be 3 or 4, default is 4
Additionally, with Flow, it is recommended to install
eslint-plugin-flowtype-errors in your project directly.
node config, it uses the
engines section of
react-native config, in order to resolve imports (import x from CoolProject/.../...), the project name must be defined. The plugin will use the
name param of the package.json in order to solve this.
Multiple config files
You can add multiple
.eslintrc.yml files to a project if you will need different rules in different directories. For example, you could add an
src/server. The rules for tests and server will apply to its directory and any subdirectories, and src will apply to everything else.
You can optionally add a
.eslintignore to your project. This file works just like a
.gitignore and will prevent eslint from linting the files or paths specified in this file.
Modifying/Ignoring a rule for an entire project:
Change it to your
Modifying a rule in one file:
Add a block comment with
eslint and the rules you want to change. For example, this would change the
curly rules. You could modify these (or other) rules further down in the same file.
/* eslint quotes: ["error", "double"], curly: "error" */
Disabling a rule for one (or part of a) file:
Add a block comment with
eslint-disable and the rules you want to disable. If no rules are passed, it will disable all rules.
/* eslint-disable no-alert, no-console *//* eslint-disable */
You could turn back on some or all of the rules you disabled with
/* eslint-enable no-alert */
Disabling a rule for one line:
Add a line comment with
eslint-disable-next-line and the rules you want to disable. If no rules are passed, it will disable all rules.
; // eslint-disable-line; // eslint-disable-line no-alert// eslint-disable-next-line;// eslint-disable-next-line no-alert;