Home

Awesome

<div align="center">

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.

</div>

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:

Categorized:

Other:

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

Rules

<!-- markdownlint-disable --> <!-- begin auto-generated rules list -->

πŸ’Ό 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

NameDescriptionπŸ’Όβš οΈπŸš«πŸ”§πŸ’‘πŸ’­βŒ
functional-parametersEnforce functional parameters.β˜‘οΈ βœ… πŸ”’ badge-curryingbadge-disableTypeCheckedπŸ’­

No Exceptions

NameDescriptionπŸ’Όβš οΈπŸš«πŸ”§πŸ’‘πŸ’­βŒ
no-promise-rejectDisallow rejecting promises.
no-throw-statementsDisallow throwing exceptions.β˜‘οΈ βœ… πŸ”’ badge-noExceptions
no-try-statementsDisallow try-catch[-finally] and try-finally patterns.πŸ”’ badge-noExceptionsβ˜‘οΈ βœ…

No Mutations

NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β DescriptionπŸ’Όβš οΈπŸš«πŸ”§πŸ’‘πŸ’­βŒ
immutable-dataEnforce treating data as immutable.β˜‘οΈ βœ… πŸ”’ badge-noMutationsbadge-disableTypeCheckedπŸ’­
no-letDisallow mutable variables.β˜‘οΈ βœ… πŸ”’ badge-noMutations
prefer-immutable-typesRequire function parameters to be typed as certain immutabilityβ˜‘οΈ βœ… πŸ”’ badge-noMutationsbadge-disableTypeCheckedπŸ”§πŸ’‘πŸ’­
prefer-readonly-typePrefer readonly types over mutable types.badge-disableTypeCheckedπŸ”§πŸ’­βŒ
type-declaration-immutabilityEnforce the immutability of types based on patterns.β˜‘οΈ βœ… πŸ”’ badge-noMutationsbadge-disableTypeCheckedπŸ”§πŸ’‘πŸ’­

No Other Paradigms

NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β DescriptionπŸ’Όβš οΈπŸš«πŸ”§πŸ’‘πŸ’­βŒ
no-class-inheritanceDisallow inheritance in classes.β˜‘οΈ βœ… πŸ”’ badge-noOtherParadigms
no-classesDisallow classes.βœ… πŸ”’ badge-noOtherParadigmsβ˜‘οΈ
no-mixed-typesRestrict types so that only members of the same kind are allowed in them.β˜‘οΈ βœ… πŸ”’ badge-noOtherParadigmsbadge-disableTypeCheckedπŸ’­
no-this-expressionsDisallow this access.πŸ”’ badge-noOtherParadigmsβ˜‘οΈ βœ…

No Statements

NameDescriptionπŸ’Όβš οΈπŸš«πŸ”§πŸ’‘πŸ’­βŒ
no-conditional-statementsDisallow conditional statements.βœ… πŸ”’ badge-noStatementsβ˜‘οΈ badge-disableTypeCheckedπŸ’­
no-expression-statementsDisallow expression statements.βœ… πŸ”’ badge-noStatementsβ˜‘οΈ badge-disableTypeCheckedπŸ’­
no-loop-statementsDisallow imperative loops.β˜‘οΈ βœ… πŸ”’ badge-noStatements
no-return-voidDisallow functions that don't return anything.β˜‘οΈ βœ… πŸ”’ badge-noStatementsbadge-disableTypeCheckedπŸ’­

Stylistic

NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β DescriptionπŸ’Όβš οΈπŸš«πŸ”§πŸ’‘πŸ’­βŒ
prefer-property-signaturesPrefer property signatures over method signatures.🎨badge-disableTypeCheckedπŸ’­
prefer-tacitReplaces x => f(x) with just f.🎨badge-disableTypeCheckedπŸ’‘πŸ’­
readonly-typeRequire consistently using either readonly keywords or Readonly<T>🎨badge-disableTypeCheckedπŸ”§πŸ’­
<!-- end auto-generated rules list --> <!-- markdownlint-restore -->

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

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.