Neanderthals Programming Machines
Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

eslint-config-osedea

3.2.0 • Public • Published

eslint-config-osedea

Prerequisites

eslint >= 4.19.1

Adding to a project

npm install -D eslint-config-osedea@latest
yarn 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.

Config name Extends
angular
base
es5 base
esnext base, promise
flow
import
lodash (v4)
node import
prettier
react esnext, import
react-native react
testing

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.

Some example .eslintrc.yml configs:

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

Global settings

Depending on your config, you may need to add a settings block to your .eslintrc.yml.

osedea/react

For react config (if version is not specified, will assume latest version):

settings:
  react:
    version: "16.2.0"  # for example, if not using latest version
    flowVersion: "0.70" # for example

osedea/lodash

For lodash config:

settings:
  lodash:
    pragma: "_" # name of lodash variable, default is _
    version: 4 # version of lodash, can be 3 or 4, default is 4

osedea/flow

For flow config:

settings:
  flowtype:
    onlyFilesWithFlowAnnotation: true

Additionally, with Flow, it is recommended to install eslint-plugin-flowtype-errors in your project directly.

osedea/node

For node config, it uses the engines section of package.json:

{
  ...
  engines: {
    "node": ">= 6.0.0"
  },
  ...
}

osedea/react-native

For 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.

{
  "name": "CoolProject",
  ...
}

eslint FAQ

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 .eslintrc.yml in src, src/tests, and src/server. The rules for tests and server will apply to its directory and any subdirectories, and src will apply to everything else.

Ignoring directories

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.

node_modules/**
public/**
webpack/**

Modifying/Ignoring a rule for an entire project:

Change it to your .eslintrc.yml

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 quotes and 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

/* eslint-enable no-alert */

Disabling a rule for one line:

Add a line comment with eslint-disable-line or eslint-disable-next-line and the rules you want to disable. If no rules are passed, it will disable all rules.

alert('foo'); // eslint-disable-line
alert('foo'); // eslint-disable-line no-alert
 
// eslint-disable-next-line
alert('foo');
// eslint-disable-next-line no-alert
alert('foo');

install

npm i eslint-config-osedea

Downloadsweekly downloads

158

version

3.2.0

license

none

last publish

collaborators

  • avatar
Report a vulnerability