Skip to content

wework/eslint-config-wework

Repository files navigation

eslint-config-wework

Libraries.io for GitHub NPM version NPM downloads MIT License

Shared ESLint configuration for WeWork projects

Introduction

ESLint config for WeWork projects. This is an extension of eslint-config-airbnb and also provides react, imports, lodash, mocha, and node presets.

Usage

Install:

npm install eslint-config-wework --save

If you're using npm < v3 you'll need to install each of this packages peerDependencies explicitly.

npm install eslint-config-airbnb eslint-plugin-react eslint-plugin-import eslint-plugin-jsx-a11y --save

Note: make sure the versions of the above packages that are installed satisfy this package's peerDependencies, otherwise you might see inconsistent behavior.

Configure:

First, touch .eslintrc if you don't already have one.

Then update it to look like the following:

{
  "root": true,
  "extends": [
    "wework"
  ],
  "rules": {
    # Override preset rules here
  },
}

React:

To enable React-specific rules, extend wework/react:

{
  "root": true,
  "extends": [
    "wework",
    "wework/react"
  ],
  "rules": {
    # Override preset rules here
  },
}

Imports:

To enable linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names, extend wework/imports:

{
  "root": true,
  "extends": [
    "wework",
    "wework/react",
    "wework/imports"
  ],
  "rules": {
    # Override preset rules here
  },
}

Lodash:

To enable React-specific rules, extend wework/lodash:

{
  "root": true,
  "extends": [
    "wework",
    "wework/lodash"
  ],
  "rules": {
    # Override preset rules here
  },
}

Mocha:

To enable linting of Mocha/Chai/Sinon tests add a eslintrc file to your test folder:

{
  "extends": [
    "wework/mocha",
  ],
  "rules": {
    # Override preset rules here
  },
}

Node:

For Node specific config, including identification of security hotspots, add a eslintrc file to your node src folder:

{
  "extends": [
    "wework/node",
  ],
  "rules": {
    # Override preset rules here
  },
}

Note: the security plugin is slow, finds a lot of false positives which need triage by a human, and isn't geared towards client-side. Use sparingly! See https://github.com/nodesecurity/eslint-plugin-security for more info.

Development

  1. Checkout this repo
  2. Make changes in a feature branch and open a PR to master

The purpose of this package is to define and enforce code style in JavaScript code. With that in mind please be mindful when proposing changes, explain your reasoning and consider other users.

npm scripts

Target Behavior
npm run lint (Run as a git pre-commit hook) Lint the config with itself
npm run security-scan (Run as a git pre-push hook) Checks npm dependencies for security vulnerabilities
npm run release <version> Generates a changelog, updates package version, tags and pushes via np. This should only be run on an up-to-date master by a maintainer of this package.

Version can be a semver level: `patch

npm run will list all npm scripts