This package has been deprecated

Author message:

Use eslint-plugin-adeira instead

eslint-plugin-relay-imports

1.0.0 • Public • Published

ESLint plugin relay-imports

ESLint plugin to check Flow type imports from files generated by the Relay Compiler

Why to use

As described in Relay issue #2539, when you mistype an import from these files, Flow doesn't report any error. Your code then looks strongly typed, but in fact it is typed with any.

Typically this happens during refactoring, when you rename a fragment, but forget to update also the import statement.

Installation

  1. Install the package
    • either with Yarn: yarn add --dev eslint-plugin-relay-imports
    • or with NPM: npm i --save-dev eslint-plugin-relay-imports
  2. Add to your .eslintrc:
    {
      "extends": [
        "plugin:relay-imports/recommended"
      ],
      "plugins": [
        "relay-imports"
      ],
    }
    

Rules

no-values

This rule disallows value imports from __generated__. Typically you want to import only types from these files.

Examples of incorrect code:

import { Kiwi } from './__generated__/Kiwi.graphql';
import Kiwi from './__generated__/Kiwi.graphql';

Examples of correct code:

import type { Kiwi } from './__generated__/Kiwi.graphql';
import { type Kiwi } from './__generated__/Kiwi.graphql';

type-must-exist

This rule checks that the type is explicitly exported from the generated file.

Example of incorrect code:

// given the file Kiwi_data.graphql.js doesn't export type Banana_data
import type { Banana_data } from './__generated__/Kiwi_data.graphql';

Example of correct code:

// given the file Kiwi_data.graphql.js exports type Kiwi_data
import type { Kiwi_data } from './__generated__/Kiwi_data.graphql';

Readme

Keywords

none

Package Sidebar

Install

npm i eslint-plugin-relay-imports

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

14.6 kB

Total Files

10

Last publish

Collaborators

  • martin.zlamal