@treblefm/eslint-config

Shared ESLint config for Treble.fm

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
00Jan 16, 2018Nov 1, 2016Minified + gzip package size for @treblefm/eslint-config in KB

Readme

@treblefm/eslint-config

Shared ESLint config for Treble.fm

Quick Install

(Copy/paste into your terminal)

npm install --save-dev \
  @treblefm/eslint-config \
  eslint@4 \
  eslint-import-resolver-react-native@0.1 \
  eslint-import-resolver-typescript@1 \
  eslint-plugin-import@2 \
  eslint-plugin-node@5

Dependencies

This config requires the following peer dependencies:

  • eslint@4.x (obviously)
  • eslint-import-resolver-react-native@0.1.x 1
  • eslint-import-resolver-typescript@1.x 1
  • eslint-plugin-import@2.x
  • eslint-plugin-node@5.x

Additionally, these optional peer dependencies will automatically be used if installed:

  • eslint-plugin-graphql@1.x 2
  • eslint-plugin-html@4.x
  • eslint-plugin-react@7.x
  • eslint-plugin-react-native@3.x 3
  • eslint-plugin-typescript@0.8.x 4
  • typescript@2.x 4
  • typescript-eslint-parser@12.x 4
1: Required even if you aren't using React Native or TypeScript 2: See additional GraphQL notes below
3: Required by the React Native config
4: Required by the TypeScript config

Usage

By default, this config assumes a Node.js project with ES2017 syntax (though unsupported features will be reported as errors by eslint-plugin-node):

{
  "extends": "@treblefm" // or @treblefm/eslint-config/node
}

Browser (ES6):

{
  "extends": "@treblefm/eslint-config/browser"
}

React Native (includes JSX support):

{
  "extends": "@treblefm/eslint-config/react-native"
}

JSX support can be added to any of the above configs:

{
  "extends": [
    "@treblefm",
    "@treblefm/eslint-config/jsx"
  ]
}

Similarly, TypeScript support can also be added (includes JSX support):

{
  "extends": [
    "@treblefm",
    "@treblefm/eslint-config/typescript"
  ]
}

Note about GraphQL

While GraphQL is supported, the rules are disabled by default and some configuration is required (click here for more info).

.graphqlconfig

{
  "schemaPath": "./path/to/schema.json"
}

.eslintrc

{
  "extends": "@treblefm",
  "rules": {
    "graphql/template-strings": [2, {
      "env": "apollo",
      // "validators": [/* see GraphQL's `specifiedRules` */]
    }],
    "graphql/named-operations": [2, {
      "env": "apollo"
    }],
    "graphql/required-fields": [2, {
      "env": "apollo",
      "requiredFields": ["id"]
    }],
    "graphql/capitalized-type-name": [2, {
      "env": "apollo"
    }]
  }
}

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.