eslint-plugin-functional

  • Version 7.1.0
  • Published
  • 197 kB
  • 6 dependencies
  • MIT license

Install

npm i eslint-plugin-functional
yarn add eslint-plugin-functional
pnpm add eslint-plugin-functional

Overview

ESLint rules to promote functional programming in TypeScript.

Index

Variables

variable _default

const _default: any;

    variable configs

    const configs: Readonly<{
    all: FlatConfig.Config;
    lite: FlatConfig.Config;
    recommended: FlatConfig.Config;
    strict: FlatConfig.Config;
    off: FlatConfig.Config;
    disableTypeChecked: FlatConfig.Config;
    externalVanillaRecommended: FlatConfig.Config;
    externalTypeScriptRecommended: FlatConfig.Config;
    currying: FlatConfig.Config;
    noExceptions: FlatConfig.Config;
    noMutations: FlatConfig.Config;
    noOtherParadigms: FlatConfig.Config;
    noStatements: FlatConfig.Config;
    stylistic: FlatConfig.Config;
    }>;

      variable errorMessages

      const errorMessages: {
      readonly restParam: 'Unexpected rest parameter. Use a regular parameter of type array instead.';
      readonly arguments: 'Unexpected use of `arguments`. Use regular function arguments instead.';
      readonly paramCountAtLeastOne: 'Functions must have at least one parameter.';
      readonly paramCountExactlyOne: 'Functions must have exactly one parameter.';
      };

        variable errorMessages$1

        const errorMessages$1: {
        readonly generic: 'Modifying an existing object/array is not allowed.';
        readonly object: 'Modifying properties of existing object not allowed.';
        readonly array: 'Modifying an array is not allowed.';
        };

          variable errorMessages$10

          const errorMessages$10: { readonly generic: 'Function must return a value.' };

            variable errorMessages$11

            const errorMessages$11: {
            readonly generic: 'Unexpected this, use functions not classes.';
            };

              variable errorMessages$12

              const errorMessages$12: {
              readonly generic: 'Unexpected throw, throwing exceptions is not functional.';
              };

                variable errorMessages$13

                const errorMessages$13: {
                readonly catch: 'Unexpected try-catch, this pattern is not functional.';
                readonly finally: 'Unexpected try-finally, this pattern is not functional.';
                };

                  variable errorMessages$14

                  const errorMessages$14: {
                  readonly parameter: 'Parameter should have an immutability of at least "{{ expected }}" (actual: "{{ actual }}").';
                  readonly returnType: 'Return type should have an immutability of at least "{{ expected }}" (actual: "{{ actual }}").';
                  readonly variable: 'Variable should have an immutability of at least "{{ expected }}" (actual: "{{ actual }}").';
                  readonly propertyImmutability: 'Property should have an immutability of at least "{{ expected }}" (actual: "{{ actual }}").';
                  readonly propertyModifier: 'Property should have a readonly modifier.';
                  readonly propertyModifierSuggestion: 'Add readonly modifier.';
                  readonly userDefined: '{{ message }}';
                  };

                    variable errorMessages$15

                    const errorMessages$15: {
                    readonly generic: 'Use a property signature instead of a method signature';
                    };

                      variable errorMessages$16

                      const errorMessages$16: {
                      readonly array: 'Only readonly arrays allowed.';
                      readonly implicit: 'Implicitly a mutable array. Only readonly arrays allowed.';
                      readonly property: 'A readonly modifier is required.';
                      readonly tuple: 'Only readonly tuples allowed.';
                      readonly type: 'Only readonly types allowed.';
                      };

                        variable errorMessages$17

                        const errorMessages$17: {
                        readonly generic: 'Potentially unnecessary function wrapper.';
                        };

                          variable errorMessages$18

                          const errorMessages$18: {
                          readonly generic: "Readonly type using 'readonly' keyword is forbidden. Use 'Readonly<T>' instead.";
                          readonly keyword: "Readonly type using 'Readonly<T>' is forbidden. Use 'readonly' keyword instead.";
                          };

                            variable errorMessages$19

                            const errorMessages$19: {
                            readonly Less: 'This type is declare to have an immutability less than "{{ expected }}" (actual: "{{ actual }}").';
                            readonly AtLeast: 'This type is declare to have an immutability of at least "{{ expected }}" (actual: "{{ actual }}").';
                            readonly Exactly: 'This type is declare to have an immutability of exactly "{{ expected }}" (actual: "{{ actual }}").';
                            readonly AtMost: 'This type is declare to have an immutability of at most "{{ expected }}" (actual: "{{ actual }}").';
                            readonly More: 'This type is declare to have an immutability more than "{{ expected }}" (actual: "{{ actual }}").';
                            };

                              variable errorMessages$2

                              const errorMessages$2: {
                              readonly abstract: 'Unexpected abstract class.';
                              readonly extends: 'Unexpected inheritance, use composition instead.';
                              };

                                variable errorMessages$3

                                const errorMessages$3: {
                                readonly generic: 'Unexpected class, use functions not classes.';
                                };

                                  variable errorMessages$4

                                  const errorMessages$4: {
                                  readonly incompleteBranch: 'Incomplete branch, every branch in a conditional statement must contain a return statement.';
                                  readonly incompleteIf: 'Incomplete if, it must have an else statement and every branch must contain a return statement.';
                                  readonly incompleteSwitch: 'Incomplete switch, it must be exhaustive or have an default case and every case must contain a return statement.';
                                  readonly unexpectedIf: 'Unexpected if, use a conditional expression (ternary operator) instead.';
                                  readonly unexpectedSwitch: 'Unexpected switch, use a conditional expression (ternary operator) instead.';
                                  };

                                    variable errorMessages$5

                                    const errorMessages$5: {
                                    readonly generic: 'Using expressions to cause side-effects not allowed.';
                                    };

                                      variable errorMessages$6

                                      const errorMessages$6: { readonly generic: 'Unexpected let, use const instead.' };

                                        variable errorMessages$7

                                        const errorMessages$7: {
                                        readonly generic: 'Unexpected loop, use map or reduce instead.';
                                        };

                                          variable errorMessages$8

                                          const errorMessages$8: {
                                          readonly generic: 'Only the same kind of members allowed in types.';
                                          };

                                            variable errorMessages$9

                                            const errorMessages$9: {
                                            readonly generic: 'Unexpected rejection, resolve an error instead.';
                                            };

                                              variable fullName

                                              const fullName: string;

                                                variable fullName$1

                                                const fullName$1: string;

                                                  variable fullName$10

                                                  const fullName$10: string;

                                                    variable fullName$11

                                                    const fullName$11: string;

                                                      variable fullName$12

                                                      const fullName$12: string;

                                                        variable fullName$13

                                                        const fullName$13: string;

                                                          variable fullName$14

                                                          const fullName$14: string;

                                                            variable fullName$15

                                                            const fullName$15: string;

                                                              variable fullName$16

                                                              const fullName$16: string;

                                                                variable fullName$17

                                                                const fullName$17: string;

                                                                  variable fullName$18

                                                                  const fullName$18: string;

                                                                    variable fullName$19

                                                                    const fullName$19: string;

                                                                      variable fullName$2

                                                                      const fullName$2: string;

                                                                        variable fullName$3

                                                                        const fullName$3: string;

                                                                          variable fullName$4

                                                                          const fullName$4: string;

                                                                            variable fullName$5

                                                                            const fullName$5: string;

                                                                              variable fullName$6

                                                                              const fullName$6: string;

                                                                                variable fullName$7

                                                                                const fullName$7: string;

                                                                                  variable fullName$8

                                                                                  const fullName$8: string;

                                                                                    variable fullName$9

                                                                                    const fullName$9: string;

                                                                                      variable meta

                                                                                      const meta: { readonly name: 'eslint-plugin-functional'; readonly version: string };

                                                                                        variable name

                                                                                        const name: string;

                                                                                          variable name$1

                                                                                          const name$1: string;

                                                                                            variable name$10

                                                                                            const name$10: string;

                                                                                              variable name$11

                                                                                              const name$11: string;

                                                                                                variable name$12

                                                                                                const name$12: string;

                                                                                                  variable name$13

                                                                                                  const name$13: string;

                                                                                                    variable name$14

                                                                                                    const name$14: string;

                                                                                                      variable name$15

                                                                                                      const name$15: string;

                                                                                                        variable name$16

                                                                                                        const name$16: string;

                                                                                                          variable name$17

                                                                                                          const name$17: string;

                                                                                                            variable name$18

                                                                                                            const name$18: string;

                                                                                                              variable name$19

                                                                                                              const name$19: string;

                                                                                                                variable name$2

                                                                                                                const name$2: string;

                                                                                                                  variable name$3

                                                                                                                  const name$3: string;

                                                                                                                    variable name$4

                                                                                                                    const name$4: string;

                                                                                                                      variable name$5

                                                                                                                      const name$5: string;

                                                                                                                        variable name$6

                                                                                                                        const name$6: string;

                                                                                                                          variable name$7

                                                                                                                          const name$7: string;

                                                                                                                            variable name$8

                                                                                                                            const name$8: string;

                                                                                                                              variable name$9

                                                                                                                              const name$9: string;

                                                                                                                                variable rule

                                                                                                                                const rule: any;

                                                                                                                                  variable rule$1

                                                                                                                                  const rule$1: any;

                                                                                                                                    variable rule$10

                                                                                                                                    const rule$10: any;

                                                                                                                                      variable rule$11

                                                                                                                                      const rule$11: any;

                                                                                                                                        variable rule$12

                                                                                                                                        const rule$12: any;

                                                                                                                                          variable rule$13

                                                                                                                                          const rule$13: any;

                                                                                                                                            variable rule$14

                                                                                                                                            const rule$14: any;

                                                                                                                                              variable rule$15

                                                                                                                                              const rule$15: any;

                                                                                                                                                variable rule$16

                                                                                                                                                const rule$16: any;

                                                                                                                                                  variable rule$17

                                                                                                                                                  const rule$17: any;

                                                                                                                                                    variable rule$18

                                                                                                                                                    const rule$18: any;

                                                                                                                                                      variable rule$19

                                                                                                                                                      const rule$19: any;

                                                                                                                                                        variable rule$2

                                                                                                                                                        const rule$2: any;

                                                                                                                                                          variable rule$3

                                                                                                                                                          const rule$3: any;

                                                                                                                                                            variable rule$4

                                                                                                                                                            const rule$4: any;

                                                                                                                                                              variable rule$5

                                                                                                                                                              const rule$5: any;

                                                                                                                                                                variable rule$6

                                                                                                                                                                const rule$6: any;

                                                                                                                                                                  variable rule$7

                                                                                                                                                                  const rule$7: any;

                                                                                                                                                                    variable rule$8

                                                                                                                                                                    const rule$8: any;

                                                                                                                                                                      variable rule$9

                                                                                                                                                                      const rule$9: any;

                                                                                                                                                                        variable ruleNameScope

                                                                                                                                                                        const ruleNameScope: string;

                                                                                                                                                                          variable rules

                                                                                                                                                                          const rules: Readonly<{
                                                                                                                                                                          'functional-parameters': typeof rule;
                                                                                                                                                                          'immutable-data': typeof rule$1;
                                                                                                                                                                          'no-classes': typeof rule$3;
                                                                                                                                                                          'no-class-inheritance': typeof rule$2;
                                                                                                                                                                          'no-conditional-statements': typeof rule$4;
                                                                                                                                                                          'no-expression-statements': typeof rule$5;
                                                                                                                                                                          'no-let': typeof rule$6;
                                                                                                                                                                          'no-loop-statements': typeof rule$7;
                                                                                                                                                                          'no-mixed-types': typeof rule$8;
                                                                                                                                                                          'no-promise-reject': typeof rule$9;
                                                                                                                                                                          'no-return-void': typeof rule$10;
                                                                                                                                                                          'no-this-expressions': typeof rule$11;
                                                                                                                                                                          'no-throw-statements': typeof rule$12;
                                                                                                                                                                          'no-try-statements': typeof rule$13;
                                                                                                                                                                          'prefer-immutable-types': typeof rule$14;
                                                                                                                                                                          'prefer-property-signatures': typeof rule$15;
                                                                                                                                                                          'prefer-readonly-type': typeof rule$16;
                                                                                                                                                                          'prefer-tacit': typeof rule$17;
                                                                                                                                                                          'readonly-type': typeof rule$18;
                                                                                                                                                                          'type-declaration-immutability': typeof typeDeclarationImmutability.rule;
                                                                                                                                                                          }>;

                                                                                                                                                                            Type Aliases

                                                                                                                                                                            type CoreOptions

                                                                                                                                                                            type CoreOptions = IgnoreIdentifierPatternOption &
                                                                                                                                                                            IgnorePrefixSelectorOption & {
                                                                                                                                                                            allowRestParameter: boolean;
                                                                                                                                                                            allowArgumentsKeyword: boolean;
                                                                                                                                                                            enforceParameterCount:
                                                                                                                                                                            | ParameterCountOptions
                                                                                                                                                                            | false
                                                                                                                                                                            | {
                                                                                                                                                                            count: ParameterCountOptions;
                                                                                                                                                                            ignoreLambdaExpression: boolean;
                                                                                                                                                                            ignoreIIFE: boolean;
                                                                                                                                                                            ignoreGettersAndSetters: boolean;
                                                                                                                                                                            };
                                                                                                                                                                            };

                                                                                                                                                                              type Docs

                                                                                                                                                                              type Docs = {
                                                                                                                                                                              /**
                                                                                                                                                                              * Used for creating category configs and splitting the README rules list into sub-lists.
                                                                                                                                                                              */
                                                                                                                                                                              category:
                                                                                                                                                                              | 'Currying'
                                                                                                                                                                              | 'No Exceptions'
                                                                                                                                                                              | 'No Mutations'
                                                                                                                                                                              | 'No Other Paradigms'
                                                                                                                                                                              | 'No Statements'
                                                                                                                                                                              | 'Stylistic';
                                                                                                                                                                              recommended: 'recommended' | 'strict' | false;
                                                                                                                                                                              recommendedSeverity: 'error' | 'warn';
                                                                                                                                                                              requiresTypeChecking: boolean;
                                                                                                                                                                              url?: never;
                                                                                                                                                                              };

                                                                                                                                                                                type EslintPluginFunctional

                                                                                                                                                                                type EslintPluginFunctional = FlatConfig.Plugin & {
                                                                                                                                                                                meta: typeof meta;
                                                                                                                                                                                rules: typeof rules;
                                                                                                                                                                                configs: typeof configs;
                                                                                                                                                                                };

                                                                                                                                                                                  type FixerConfig

                                                                                                                                                                                  type FixerConfig = {
                                                                                                                                                                                  pattern: RegExp;
                                                                                                                                                                                  replace: string;
                                                                                                                                                                                  };

                                                                                                                                                                                    type FixerConfigRaw

                                                                                                                                                                                    type FixerConfigRaw = {
                                                                                                                                                                                    pattern: string;
                                                                                                                                                                                    replace: string;
                                                                                                                                                                                    };

                                                                                                                                                                                      type FixerConfigRawMap

                                                                                                                                                                                      type FixerConfigRawMap = Partial<
                                                                                                                                                                                      Record<
                                                                                                                                                                                      'ReadonlyShallow' | 'ReadonlyDeep' | 'Immutable',
                                                                                                                                                                                      FixerConfigRaw | FixerConfigRaw[] | undefined
                                                                                                                                                                                      >
                                                                                                                                                                                      >;

                                                                                                                                                                                        type IgnoreAccessorPatternOption

                                                                                                                                                                                        type IgnoreAccessorPatternOption = Readonly<{
                                                                                                                                                                                        ignoreAccessorPattern?: ReadonlyArray<string> | string;
                                                                                                                                                                                        }>;
                                                                                                                                                                                        • The option to ignore accessor patterns.

                                                                                                                                                                                        type IgnoreClassesOption

                                                                                                                                                                                        type IgnoreClassesOption = Readonly<{
                                                                                                                                                                                        ignoreClasses: boolean | 'fieldsOnly';
                                                                                                                                                                                        }>;
                                                                                                                                                                                        • The option to ignore classes.

                                                                                                                                                                                        type IgnoreCodePatternOption

                                                                                                                                                                                        type IgnoreCodePatternOption = Readonly<{
                                                                                                                                                                                        ignoreCodePattern?: ReadonlyArray<string> | string;
                                                                                                                                                                                        }>;
                                                                                                                                                                                        • The option to ignore patterns.

                                                                                                                                                                                        type IgnoreIdentifierPatternOption

                                                                                                                                                                                        type IgnoreIdentifierPatternOption = Readonly<{
                                                                                                                                                                                        ignoreIdentifierPattern?: ReadonlyArray<string> | string;
                                                                                                                                                                                        }>;
                                                                                                                                                                                        • The option to ignore patterns.

                                                                                                                                                                                        type IgnorePrefixSelectorOption

                                                                                                                                                                                        type IgnorePrefixSelectorOption = Readonly<{
                                                                                                                                                                                        ignorePrefixSelector?: ReadonlyArray<string> | string;
                                                                                                                                                                                        }>;
                                                                                                                                                                                        • The option to ignore prefix selector.

                                                                                                                                                                                        type ImmutabilityRule

                                                                                                                                                                                        type ImmutabilityRule = {
                                                                                                                                                                                        identifiers: RegExp[];
                                                                                                                                                                                        immutability: Immutability;
                                                                                                                                                                                        comparator: RuleEnforcementComparator;
                                                                                                                                                                                        fixers: FixerConfig[] | false;
                                                                                                                                                                                        suggestions: SuggestionsConfig | false;
                                                                                                                                                                                        };
                                                                                                                                                                                        • A rule given by the user after being upgraded.

                                                                                                                                                                                        type NamedCreateRuleCustomMeta

                                                                                                                                                                                        type NamedCreateRuleCustomMeta<T extends string> = NamedCreateRuleMeta<T, Docs>;
                                                                                                                                                                                        • Any custom rule meta properties.

                                                                                                                                                                                        type Option

                                                                                                                                                                                        type Option = IgnoreClassesOption & {
                                                                                                                                                                                        enforcement: RawEnforcement;
                                                                                                                                                                                        ignoreInferredTypes: boolean;
                                                                                                                                                                                        ignoreNamePattern?: string[] | string;
                                                                                                                                                                                        ignoreTypePattern?: string[] | string;
                                                                                                                                                                                        };

                                                                                                                                                                                          type Options

                                                                                                                                                                                          type Options = [IgnoreIdentifierPatternOption & IgnoreCodePatternOption];
                                                                                                                                                                                          • The options this rule can take.

                                                                                                                                                                                          type ParameterCountOptions

                                                                                                                                                                                          type ParameterCountOptions = 'atLeastOne' | 'exactlyOne';
                                                                                                                                                                                          • The parameter count options this rule can take.

                                                                                                                                                                                          type RawEnforcement

                                                                                                                                                                                          type RawEnforcement =
                                                                                                                                                                                          | Exclude<Immutability | keyof typeof Immutability, 'Unknown' | 'Mutable'>
                                                                                                                                                                                          | 'None'
                                                                                                                                                                                          | false
                                                                                                                                                                                          | undefined;

                                                                                                                                                                                            type RawOptions

                                                                                                                                                                                            type RawOptions = [RawOverridableOptions<CoreOptions>];
                                                                                                                                                                                            • The options this rule can take.

                                                                                                                                                                                            type RawOverridableOptions

                                                                                                                                                                                            type RawOverridableOptions<CoreOptions> = CoreOptions & {
                                                                                                                                                                                            overrides?: Array<{
                                                                                                                                                                                            specifiers?: RawTypeSpecifier | RawTypeSpecifier[];
                                                                                                                                                                                            options?: CoreOptions;
                                                                                                                                                                                            inherit?: boolean;
                                                                                                                                                                                            disable?: boolean;
                                                                                                                                                                                            }>;
                                                                                                                                                                                            };

                                                                                                                                                                                              type RawTypeSpecifier

                                                                                                                                                                                              type RawTypeSpecifier = {
                                                                                                                                                                                              name?: string | string[];
                                                                                                                                                                                              pattern?: string | string[];
                                                                                                                                                                                              ignoreName?: string | string[];
                                                                                                                                                                                              ignorePattern?: string | string[];
                                                                                                                                                                                              } & TypeDeclarationSpecifier;

                                                                                                                                                                                                type Rule

                                                                                                                                                                                                type Rule<
                                                                                                                                                                                                MessageIds extends string,
                                                                                                                                                                                                Options extends ReadonlyArray<unknown>
                                                                                                                                                                                                > = RuleModule<MessageIds, Options, Docs> & {
                                                                                                                                                                                                meta: NamedCreateRuleCustomMeta<MessageIds>;
                                                                                                                                                                                                };
                                                                                                                                                                                                • The definition of a rule.

                                                                                                                                                                                                type SuggestionConfigRawMap

                                                                                                                                                                                                type SuggestionConfigRawMap = Partial<
                                                                                                                                                                                                Record<
                                                                                                                                                                                                'ReadonlyShallow' | 'ReadonlyDeep' | 'Immutable',
                                                                                                                                                                                                SuggestionsConfigRaw[] | undefined
                                                                                                                                                                                                >
                                                                                                                                                                                                >;

                                                                                                                                                                                                  type SuggestionsConfig

                                                                                                                                                                                                  type SuggestionsConfig = FixerConfig[];

                                                                                                                                                                                                    type SuggestionsConfigRaw

                                                                                                                                                                                                    type SuggestionsConfigRaw = Array<
                                                                                                                                                                                                    FixerConfigRaw & {
                                                                                                                                                                                                    message?: string;
                                                                                                                                                                                                    }
                                                                                                                                                                                                    >;

                                                                                                                                                                                                      Namespaces

                                                                                                                                                                                                      namespace typeDeclarationImmutability

                                                                                                                                                                                                      namespace typeDeclarationImmutability {}

                                                                                                                                                                                                        variable fullName

                                                                                                                                                                                                        const fullName: string;

                                                                                                                                                                                                          variable name

                                                                                                                                                                                                          const name: string;

                                                                                                                                                                                                            variable rule

                                                                                                                                                                                                            const rule: any;

                                                                                                                                                                                                              enum RuleEnforcementComparator

                                                                                                                                                                                                              enum RuleEnforcementComparator {
                                                                                                                                                                                                              Less = -2,
                                                                                                                                                                                                              AtMost = -1,
                                                                                                                                                                                                              Exactly = 0,
                                                                                                                                                                                                              AtLeast = 1,
                                                                                                                                                                                                              More = 2,
                                                                                                                                                                                                              }

                                                                                                                                                                                                                member AtLeast

                                                                                                                                                                                                                AtLeast = 1

                                                                                                                                                                                                                  member AtMost

                                                                                                                                                                                                                  AtMost = -1

                                                                                                                                                                                                                    member Exactly

                                                                                                                                                                                                                    Exactly = 0

                                                                                                                                                                                                                      member Less

                                                                                                                                                                                                                      Less = -2

                                                                                                                                                                                                                        member More

                                                                                                                                                                                                                        More = 2

                                                                                                                                                                                                                          type ImmutabilityRule

                                                                                                                                                                                                                          type ImmutabilityRule = {
                                                                                                                                                                                                                          identifiers: RegExp[];
                                                                                                                                                                                                                          immutability: Immutability;
                                                                                                                                                                                                                          comparator: RuleEnforcementComparator;
                                                                                                                                                                                                                          fixers: FixerConfig[] | false;
                                                                                                                                                                                                                          suggestions: SuggestionsConfig | false;
                                                                                                                                                                                                                          };
                                                                                                                                                                                                                          • A rule given by the user after being upgraded.

                                                                                                                                                                                                                          Package Files (1)

                                                                                                                                                                                                                          Dependencies (6)

                                                                                                                                                                                                                          Dev Dependencies (64)

                                                                                                                                                                                                                          Peer Dependencies (2)

                                                                                                                                                                                                                          Badge

                                                                                                                                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/eslint-plugin-functional.

                                                                                                                                                                                                                          • Markdown
                                                                                                                                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/eslint-plugin-functional)
                                                                                                                                                                                                                          • HTML
                                                                                                                                                                                                                            <a href="https://www.jsdocs.io/package/eslint-plugin-functional"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>