Coder Social home page Coder Social logo

woody-morgan / eslint-plugin-functional Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eslint-functional/eslint-plugin-functional

0.0 0.0 0.0 5.14 MB

ESLint rules to disable mutation and promote fp in JavaScript and TypeScript.

License: MIT License

TypeScript 100.00%

eslint-plugin-functional's Introduction

eslint-logo

eslint-plugin-functional

npm version Release Coverage Status semantic-release code style: prettier MIT license GitHub Discussions

An ESLint plugin to disable mutation and promote functional programming in JavaScript and TypeScript.

Donate

Any donations would be much appreciated. πŸ˜„

Enterprise Users

eslint-plugin-functional is available as part of the Tidelift Subscription.

Tidelift is working with the maintainers of eslint-plugin-functional and a growing network of open source maintainers to ensure your open source software supply chain meets enterprise standards now and into the future. Learn more.

Getting Started

See our getting started guide.

Rulesets

The following rulesets are made available by this plugin.

Presets:

  • Strict (configs.strict)
    Enforce recommended rules designed to strictly enforce functional programming.

  • Recommended (configs.recommended)
    Has the same goal as the strict preset but a little more lenient, allowing for functional-like coding styles and nicer integration with non-functional 3rd-party libraries.

  • Lite (configs.lite)
    Good if you're new to functional programming or are converting a large codebase.

Categorized:

  • Currying (configs.currying)
    JavaScript functions support syntax that is not compatible with curried functions. To enforce currying, this syntax should be prevented.

  • No Exceptions (configs.noExceptions)
    Functional programming style does not use run-time exceptions. Instead expressions produces values to indicate errors.

  • No Mutations (configs.noMutations)
    Prevent mutating any data as that's not functional

  • No Other Paradigms (configs.noOtherParadigms)
    JavaScript is multi-paradigm, allowing not only functional, but object-oriented as well as other programming styles. To promote a functional style, prevent the use of other paradigm styles.

  • No Statements (configs.noStatements)
    In functional programming everything is an expression that produces a value. JavaScript has a lot of syntax that is just statements that does not produce a value. That syntax has to be prevented to promote a functional style.

  • Stylistic (configs.stylistic)
    Enforce code styles that can be considered to be more functional.

Other:

  • All (configs.all)
    Enables all rules defined in this plugin.

  • Off (configs.off)
    Disable all rules defined in this plugin.

  • Disable Type Checked (configs.disableTypeChecked)
    Disable all rules that require type information.

  • External Vanilla Recommended (configs.externalVanillaRecommended)
    Configures recommended vanilla ESLint rules.

  • External Typescript Recommended (configs.externalTypescriptRecommended)
    Configures recommended TypeScript ESLint rules. Enabling this ruleset will also enable the vanilla one.

The below section gives details on which rules are enabled by each ruleset.

Rules

πŸ’Ό Configurations enabled in.
⚠️ Configurations set to warn in.
🚫 Configurations disabled in.
β˜‘οΈ Set in the lite configuration.
βœ… Set in the recommended configuration.
πŸ”’ Set in the strict configuration.
🎨 Set in the stylistic configuration.
πŸ”§ Automatically fixable by the --fix CLI option.
πŸ’‘ Manually fixable by editor suggestions.
πŸ’­ Requires type information.
❌ Deprecated.

Currying

Name Description πŸ’Ό ⚠️ 🚫 πŸ”§ πŸ’‘ πŸ’­ ❌
functional-parameters Enforce functional parameters. β˜‘οΈ βœ… πŸ”’ badge-currying ![badge-disableTypeChecked][] πŸ’­

No Exceptions

Name Description πŸ’Ό ⚠️ 🚫 πŸ”§ πŸ’‘ πŸ’­ ❌
no-promise-reject Disallow rejecting promises.
no-throw-statements Disallow throwing exceptions. β˜‘οΈ βœ… πŸ”’ ![badge-noExceptions][]
no-try-statements Disallow try-catch[-finally] and try-finally patterns. πŸ”’ ![badge-noExceptions][] β˜‘οΈ βœ…

No Mutations

NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  Description πŸ’Ό ⚠️ 🚫 πŸ”§ πŸ’‘ πŸ’­ ❌
immutable-data Enforce treating data as immutable. β˜‘οΈ βœ… πŸ”’ ![badge-noMutations][] ![badge-disableTypeChecked][] πŸ’­
no-let Disallow mutable variables. β˜‘οΈ βœ… πŸ”’ ![badge-noMutations][]
prefer-immutable-types Require function parameters to be typed as certain immutability β˜‘οΈ βœ… πŸ”’ ![badge-noMutations][] ![badge-disableTypeChecked][] πŸ”§ πŸ’‘ πŸ’­
prefer-readonly-type Prefer readonly types over mutable types. ![badge-disableTypeChecked][] πŸ”§ πŸ’­ ❌
type-declaration-immutability Enforce the immutability of types based on patterns. β˜‘οΈ βœ… πŸ”’ ![badge-noMutations][] ![badge-disableTypeChecked][] πŸ”§ πŸ’‘ πŸ’­

No Other Paradigms

NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β  Description πŸ’Ό ⚠️ 🚫 πŸ”§ πŸ’‘ πŸ’­ ❌
no-classes Disallow classes. β˜‘οΈ βœ… πŸ”’ ![badge-noOtherParadigms][]
no-mixed-types Restrict types so that only members of the same kind are allowed in them. β˜‘οΈ βœ… πŸ”’ ![badge-noOtherParadigms][] ![badge-disableTypeChecked][] πŸ’­
no-this-expressions Disallow this access. πŸ”’ ![badge-noOtherParadigms][] β˜‘οΈ βœ…

No Statements

Name Description πŸ’Ό ⚠️ 🚫 πŸ”§ πŸ’‘ πŸ’­ ❌
no-conditional-statements Disallow conditional statements. βœ… πŸ”’ ![badge-noStatements][] β˜‘οΈ ![badge-disableTypeChecked][] πŸ’­
no-expression-statements Disallow expression statements. βœ… πŸ”’ ![badge-noStatements][] β˜‘οΈ ![badge-disableTypeChecked][] πŸ’­
no-loop-statements Disallow imperative loops. β˜‘οΈ βœ… πŸ”’ ![badge-noStatements][]
no-return-void Disallow functions that don't return anything. β˜‘οΈ βœ… πŸ”’ ![badge-noStatements][] ![badge-disableTypeChecked][] πŸ’­

Stylistic

NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  Description πŸ’Ό ⚠️ 🚫 πŸ”§ πŸ’‘ πŸ’­ ❌
prefer-property-signatures Prefer property signatures over method signatures. 🎨 ![badge-disableTypeChecked][] πŸ’­
prefer-tacit Replaces x => f(x) with just f. 🎨 ![badge-disableTypeChecked][] πŸ’‘ πŸ’­
readonly-type Require consistently using either readonly keywords or Readonly<T> 🎨 ![badge-disableTypeChecked][] πŸ”§ πŸ’­

External Recommended Rules

In addition to the above rules, there are a few other rules we recommended.

These rules are what are included in the external recommended rulesets.

Vanilla Rules

  • no-var
    Without this rule, it is still possible to create mutable var variables.

  • no-param-reassign
    Don't allow function parameters to be reassigned, they should be treated as constants.

  • prefer-const
    This rule provides a helpful fixer when converting from an imperative code style to a functional one.

Typescript Rules

Contributing

See our contributing guide.

Prior work

This project started as a port of tslint-immutable which was originally inspired by eslint-plugin-immutable.

eslint-plugin-functional's People

Contributors

rebeccastevens avatar renovate[bot] avatar dependabot[bot] avatar semantic-release-bot avatar jonaskello avatar mtsknn avatar rafaelss95 avatar lo1tuma avatar yosevu avatar foray1010 avatar bmish avatar taylorc93 avatar lorenzhenk avatar martisj avatar matatk avatar davidmaxwaterman avatar robvdl avatar kirill-golovan avatar ulrichb 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.