Skip to content

kiwicom/eslint-plugin-kiwicom-incubator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This package is deprecated

eslint-plugin-kiwicom-incubator is no longer maintained, use eslint-plugin-adeira instead


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

no-internal-flow-type

Prefers React.Node over React$Node types.

no-invalid-flow-annotations

This rule disallows @noflow and @flow weak annotations. Valid annotations are @flow, @flow strict and @flow strict-local

only-nullable-fields

This rule aims to remove all dangerous uses of GraphQLNonNull on GraphQL type fields. Why? It's a best practice to use nullable fields and not to rely on a returned value. This way every frontend implementation must handle the situation when API returns null because everything will break eventually. Non-nullable fields would in case of failure destroy the whole type and could bubble-up destroying the whole GraphQL response.

Examples of incorrect code for this rule:

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

Examples of correct code for this rule:

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

Non-nullable fields are still allowed in these cases:

  • inside of GraphQLInputObjectType (you want to restrict input values)
  • in query or types arguments (args property)
  • direct child of GraphQLList

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published