Socket
Socket
Sign inDemoInstall

eslint-plugin-functional

Package Overview
Dependencies
130
Maintainers
2
Versions
108
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eslint-plugin-functional

ESLint rules to disable mutation and promote fp in TypeScript.


Version published
Weekly downloads
142K
decreased by-3.31%
Maintainers
2
Created
Weekly downloads
 

Changelog

Source

6.0.1 (2024-02-23)

Bug Fixes

  • typos in function names (05b2f9c)

Readme

Source

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 (plugin:functional/strict)
    Enforce recommended rules designed to strictly enforce functional programming.

  • Recommended (plugin:functional/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 (plugin:functional/lite)
    Good if you're new to functional programming or are converting a large codebase.

Categorized:

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

  • No Exceptions (plugin:functional/no-exceptions)
    Functional programming style does not use run-time exceptions. Instead expressions produces values to indicate errors.

  • No Mutations (plugin:functional/no-mutations)
    Prevent mutating any data as that's not functional

  • No Other Paradigms (plugin:functional/no-other-paradigms)
    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 (plugin:functional/no-statements)
    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 (plugin:functional/stylistic)
    Enforce code styles that can be considered to be more functional.

Other:

  • All (plugin:functional/all)
    Enables all rules defined in this plugin.

  • Off (plugin:functional/off)
    Disable all rules defined in this plugin.

  • External Vanilla Recommended (plugin:functional/external-vanilla-recommended)
    Configures recommended vanilla ESLint rules.

  • External Typescript Recommended (plugin:functional/external-typescript-recommended)
    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.
❌ Deprecated.

Currying

NameDescription💼⚠️🚫🔧💡
functional-parametersEnforce functional parameters.☑️ ✅ 🔒 badge-currying

No Exceptions

NameDescription💼⚠️🚫🔧💡
no-promise-rejectDisallow try-catch[-finally] and try-finally patterns.
no-throw-statementsDisallow throwing exceptions.☑️ ✅ 🔒 badge-no-exceptions
no-try-statementsDisallow try-catch[-finally] and try-finally patterns.🔒 badge-no-exceptions☑️ ✅

No Mutations

Name                         Description💼⚠️🚫🔧💡
immutable-dataEnforce treating data as immutable.☑️ ✅ 🔒 badge-no-mutations
no-letDisallow mutable variables.☑️ ✅ 🔒 badge-no-mutations
prefer-immutable-typesRequire function parameters to be typed as certain immutability☑️ ✅ 🔒 badge-no-mutations🔧💡
prefer-readonly-typePrefer readonly types over mutable types.🔧
type-declaration-immutabilityEnforce the immutability of types based on patterns.☑️ ✅ 🔒 badge-no-mutations🔧

No Other Paradigms

Name               Description💼⚠️🚫🔧💡
no-classesDisallow classes.☑️ ✅ 🔒 badge-no-other-paradigms
no-mixed-typesRestrict types so that only members of the same kind are allowed in them.☑️ ✅ 🔒 badge-no-other-paradigms
no-this-expressionsDisallow this access.🔒 badge-no-other-paradigms☑️ ✅

No Statements

NameDescription💼⚠️🚫🔧💡
no-conditional-statementsDisallow conditional statements.✅ 🔒 badge-no-statements☑️
no-expression-statementsDisallow expression statements.✅ 🔒 badge-no-statements☑️
no-loop-statementsDisallow imperative loops.☑️ ✅ 🔒 badge-no-statements
no-return-voidDisallow functions that don't return anything.☑️ ✅ 🔒 badge-no-statements

Stylistic

Name                      Description💼⚠️🚫🔧💡
prefer-property-signaturesPrefer property signatures over method signatures.🎨
prefer-tacitReplaces x => f(x) with just f.🎨💡
readonly-typeRequire consistently using either readonly keywords or Readonly<T>🎨🔧

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 var variables that are mutable.

  • 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 off as a port of tslint-immutable which was originally inspired by eslint-plugin-immutable.

Keywords

FAQs

Last updated on 23 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc