Coder Social home page Coder Social logo

eslint-plugin-fp-ts's Introduction

badge npm npm

eslint-plugin-fp-ts

A collection of ESLint rules for fp-ts

Installation

Assuming ESlint is installed locally in your project:

# npm
npm install --save-dev eslint-plugin-fp-ts

# yarn
yarn add --dev eslint-plugin-fp-ts

Then enable the plugin in your .eslintrc config

{
  "plugins": ["fp-ts"]
}

and enable the rules you want, for example

{
  "plugins": ["fp-ts"],
  "rules": {
    "fp-ts/no-lib-imports": "error"
  }
}

If you want to enable rules that require type information (see the table below), then you will also need to add some extra info:

module.exports = {
  plugins: ["fp-ts"],
  parserOptions: {
    tsconfigRootDir: __dirname,
    project: ["./tsconfig.json"],
  },
  rules: {
    "fp-ts/no-discarded-pure-expression": "error",
  },
};

If your project is a multi-package monorepo, you can follow the instructions here.

โš ๏ธ Note that you will need to make the ESLint config file a .js file, due to the need of setting tsconfigRootDir to __dirname. This is necessary to make both editor integrations and the CLI work with the correct path. More info here: typescript-eslint/typescript-eslint#251

List of supported rules

Rule Description Fixable Requires type-checking
fp-ts/no-lib-imports Disallow imports from fp-ts/lib/ ๐Ÿ”ง
fp-ts/no-pipeable Disallow imports from the pipeable module ๐Ÿ”ง
fp-ts/no-module-imports Disallow imports from fp-ts modules ๐Ÿ”ง
fp-ts/no-redundant-flow Remove redundant uses of flow ๐Ÿ”ง
fp-ts/prefer-traverse Replace map + sequence with traverse ๐Ÿ’ก
fp-ts/prefer-chain Replace map + flatten with chain ๐Ÿ’ก
fp-ts/prefer-bimap Replace map + mapLeft with bimap ๐Ÿ’ก
fp-ts/no-discarded-pure-expression Disallow expressions returning pure data types (like Task or IO) in statement position ๐Ÿ’ก ๐Ÿฆ„

Fixable legend:

๐Ÿ”ง = auto-fixable via --fix (or via the appropriate editor configuration)

๐Ÿ’ก = provides in-editor suggestions that need to be applied manually

Configurations

Recommended

The plugin defines a recommended configuration with some reasonable defaults.

To use it, add it to the extends clause of your .eslintrc file:

{
  "extends": ["plugin:fp-ts/recommended"]
}

The rules included in this configuration are:

Recommended requiring type-checking

We also provide a recommended-requiring-type-checking which includes recommended rules which require type information.

This configuration needs to be included in addition to the recommended one:

{
  "extends": [
    "plugin:fp-ts/recommended",
    "plugin:fp-ts/recommended-requiring-type-checking"
  ]
}

๐Ÿ‘‰ You can read more about linting with type information, including performance considerations here

All

The plugin also defines an all configuration which includes every available rule.

To use it, add it to the extends clause of your .eslintrc file:

{
  "extends": ["plugin:fp-ts/all"]
}

eslint-plugin-fp-ts's People

Contributors

bennesp avatar dependabot[bot] avatar gabro avatar oliverjash avatar siuvdlec avatar stefanomagrassi avatar xzhayon 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.