Code Monkey home page Code Monkey logo

eslint-plugin-kiwicom-incubator's Introduction

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

eslint-plugin-kiwicom-incubator's People

Contributors

jaroslav-kubicek avatar mrtnzlml avatar stekycz avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.