Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

eslint-functional/eslint-plugin-functional

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-logo

eslint-plugin-functional

npm versionReleaseCoverage Statussemantic-releasecode style: prettierMIT licenseGitHub Discussions

AnESLint 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 ofeslint-plugin-functional and a growing network of open source maintainersto 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 thestrict preset but a little more lenient, allowing for functional-like coding styles andnicer 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 syntaxshould 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 recommendedvanilla ESLint rules.

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

Thebelow 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 thelite configuration.
✅ Set in therecommended configuration.
🔒 Set in thestrict configuration.
🎨 Set in thestylistic configuration.
🔧 Automatically fixable by the--fix CLI option.
💡 Manually fixable byeditor suggestions.
💭 Requirestype 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-noExceptionsbadge-disableTypeChecked💭
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-tacitReplacesx => f(x) with justf.🎨badge-disableTypeChecked💡💭
readonly-typeRequire consistently using eitherreadonly keywords orReadonly<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 theexternal recommended rulesets.

Vanilla Rules

  • no-var
    Without this rule, it is still possible to create mutablevar 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 oftslint-immutablewhich was originally inspired byeslint-plugin-immutable.

About

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

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors22


[8]ページ先頭

©2009-2025 Movatter.jp