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-currying![badge-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-noMutations][]![badge-disableTypeChecked][]πŸ’­
no-letDisallow mutable variables.β˜‘οΈ βœ… πŸ”’ ![badge-noMutations][]
prefer-immutable-typesRequire function parameters to be typed as certain immutabilityβ˜‘οΈ βœ… πŸ”’ ![badge-noMutations][]![badge-disableTypeChecked][]πŸ”§πŸ’‘πŸ’­
prefer-readonly-typePrefer readonly types over mutable types.![badge-disableTypeChecked][]πŸ”§πŸ’­βŒ
type-declaration-immutabilityEnforce the immutability of types based on patterns.β˜‘οΈ βœ… πŸ”’ ![badge-noMutations][]![badge-disableTypeChecked][]πŸ”§πŸ’‘πŸ’­

No Other Paradigms

NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β DescriptionπŸ’Όβš οΈπŸš«πŸ”§πŸ’‘πŸ’­βŒ
no-classesDisallow classes.β˜‘οΈ βœ… πŸ”’ ![badge-noOtherParadigms][]
no-mixed-typesRestrict types so that only members of the same kind are allowed in them.β˜‘οΈ βœ… πŸ”’ ![badge-noOtherParadigms][]![badge-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-noStatements][]![badge-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.