ESLint Plugin Flowtype Errors

raw JSON →
4.5.0 verified Sat Apr 25 auth: no javascript

An ESLint plugin that wraps Flow errors and displays them as ESLint errors. Version 4.5.0 is the latest stable release. It allows any editor with ESLint support to also show Flow type errors, reducing configuration complexity by eliminating the need for a separate Flow linter integration. Maintained actively with frequent dependency updates. Supports Flow >=0.93.0 and ESLint >=5.16.0. Only works on 64-bit operating systems; Windows 32-bit is not supported.

error Cannot find module 'eslint-plugin-flowtype-errors'
cause Plugin not installed or not present in node_modules.
fix
Run 'npm install --save-dev eslint-plugin-flowtype-errors'.
error Error: No such plugin: flowtype-errors
cause ESLint config references a plugin that is not loaded.
fix
Add 'plugins: ["flowtype-errors"]' to your ESLint config.
error Configuration for rule 'flowtype-errors/...' is invalid
cause Incorrect rule configuration or rule name.
fix
Check that you are using valid rule names like 'flowtype-errors/enforce-min-coverage'.
gotcha Only 64-bit OS is supported. 32-bit operating systems, especially Windows 32-bit, will fail to run Flow.
fix Install a 64-bit version of your operating system.
breaking Version 4.0.0 changed the plugin export structure. The recommended config is now under 'plugin:flowtype-errors/recommended' instead of previous paths.
fix Update your ESLint config extends to 'plugin:flowtype-errors/recommended'.
deprecated The 'flowtype-errors' plugin ID is deprecated in favor of 'eslint-plugin-flowtype-errors' in ESLint config.
fix Use 'plugins: ["flowtype-errors"]' or specifiy full package name if necessary.
breaking Peer dependency flow-bin must be >=0.93.0. Older versions of Flow are not supported.
fix Upgrade flow-bin to >=0.93.0.
breaking Peer dependency eslint must be >=5.16.0. Older ESLint versions are incompatible.
fix Upgrade ESLint to >=5.16.0.
npm install eslint-plugin-flowtype-errors
yarn add eslint-plugin-flowtype-errors
pnpm add eslint-plugin-flowtype-errors

Shows how to install and configure the plugin with ESLint, enabling Flow errors as ESLint errors.

// Install the plugin and required peer dependencies
// npm install --save-dev eslint eslint-plugin-flowtype-errors flow-bin

// .eslintrc.js
module.exports = {
  plugins: ['flowtype-errors'],
  extends: ['plugin:flowtype-errors/recommended'],
  // Optional: specify Flow path or options
  settings: {
    flowtype: {
      onlyFilesWithFlowAnnotation: true,
    },
  },
};

// Now ESLint will show Flow type errors in your editor
// Example file with Flow:
// @flow
function foo(x: number): string { return x; } // ESLint reports Flow error: string expected number