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.
You'll first need to install ESLint. Next, install this plugin:
yarn add --dev eslint-plugin-kiwicom-incubator
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"
}
}
Prefers React.Node
over React$Node
types.
This rule disallows @noflow
and @flow weak
annotations. Valid annotations are @flow
, @flow strict
and @flow strict-local
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