Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.npmignore
LICENSE
README.md
package.json

README.md

Rules used at Kiwi.com in the Incubator tribe. You most probably do not need to use this package directly - use @kiwicom/eslint-config instead. This package exists basically only to workaround some Eslint limitations.

Installation

You'll first need to install ESLint. Next, install this plugin:

yarn add --dev eslint-plugin-kiwicom-incubator

Usage

Add kiwicom-incubator to the plugins section of your .eslintrc configuration file:

{
  "plugins": ["eslint-plugin-kiwicom-incubator"]
}

Then configure the rules you want to use under the rules section:

{
  "rules": {
    "kiwicom-incubator/only-nullable-fields": "error",
    "kiwicom-incubator/no-invalid-flow-annotations": "error"
  }
}

Rules

only-nullable-fields

This rule aims to remove all uses of GraphQLNonNull on GraphQL type fields. Why? It's best practice to use nullable fields and not rely on returned value. This way every frontend implementation must handle the situation when API returns null because everything will break eventually.

Examples of incorrect code for this rule:

arrival: {
  type: new GraphQLNonNull(GraphQLRouteStop),
  resolve: ({ arrival }: LegType): ArrivalType => arrival,
},

Examples of correct code for this rule:

arrival: {
  type: GraphQLRouteStop,
  resolve: ({ arrival }: LegType): ArrivalType => arrival,
},

no-invalid-flow-annotations

This rule disallows @noflow and @flow weak annotations.

You can’t perform that action at this time.