eslint-plugin-fin-eslint-flow-enforcement

1.0.12 • Public • Published

eslint-plugin-fin-eslint-flow-enforcement

Custom rules by Fin Analytics to enforce flow typing

Installation

To add this ESLint plugin to your repo, add eslint-plugin-fin-eslint-flow-enforcement under devDependencies in your package.json. You may also need to run:

$ npm install eslint-plugin-fin-eslint-flow-enforcement --save-dev

Usage

Add fin-eslint-flow-enforcement to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "fin-eslint-flow-enforcement"
    ]
}

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

{
    "rules": {
        "fin-eslint-flow-enforcement/rule-name": 2
    }
}

Supported Rules

  • require-typed-returns-on-exports - require only exported functions to declare return types. Takes the same options as the eslint-plugin-flowtype rule it was based on: https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-require-return-type
  • require-specific-typed-variables - require variables that result from one of the function calls in the includeCalls option to be typed. Exempt any variables that regex match excludeVariableMatch
  • require-specific-param-casts - require specific property names in function calls, such as apolloClient.mutate({ variables }) to be type cast so flow can validate their shape. Below is some sample options:

{
  checkPropertyNamesByCallName: {
    "apolloClient.mutate": ["variables"],
    "apolloClient.query": ["variables"],
    "sendExtensionVersionedMessage": ["data"]
  }
}

Package Sidebar

Install

npm i eslint-plugin-fin-eslint-flow-enforcement

Weekly Downloads

0

Version

1.0.12

License

ISC

Unpacked Size

207 kB

Total Files

30

Last publish

Collaborators

  • benfinxpc