Skip to content

Latest commit

 

History

History
91 lines (65 loc) · 3.5 KB

finnish.md

File metadata and controls

91 lines (65 loc) · 3.5 KB

Enforce Finnish notation (rxjs-x/finnish)

💭 This rule requires type information.

This rule enforces the use of Finnish notation - i.e. the $ suffix.

Rule details

Examples of incorrect code for this rule:

const answers = of(42, 54);

Examples of correct code for this rule:

const answer$ = of(42, 54);

Options

Name Description Type
functions Require for functions. Boolean
methods Require for methods. Boolean
names Enforce for specific names. Keys are a RegExp, values are a boolean. Object
parameters Require for parameters. Boolean
properties Require for properties. Boolean
strict Disallow Finnish notation for non-Observables. Boolean
types Enforce for specific types. Keys are a RegExp, values are a boolean. Object
variables Require for variables. Boolean

This rule accepts a single option which is an object with properties that determine whether Finnish notation is enforced for functions, methods, parameters, properties and variables. It also contains:

  • names and types properties that determine whether or not Finnish notation is to be enforced for specific names or types.
  • a strict property that, if true, allows the $ suffix to be used only with identifiers that have an Observable type.

The default (Angular-friendly) configuration looks like this:

{
    "rxjs-x/finnish": [
        "error",
        {
            "functions": true,
            "methods": true,
            "names": {
                "^(canActivate|canActivateChild|canDeactivate|canLoad|intercept|resolve|validate)$": false
            },
            "parameters": true,
            "properties": true,
            "strict": false,
            "types": {
                "^EventEmitter$": false
            },
            "variables": true
        }
    ]
}

The properties in the options object are themselves optional; they do not all have to be specified.

When Not To Use It

If you don't use Finnish notation in your project or don't care about enforcing Finnish notation in your project, you don't need this rule. However, keep in mind that inconsistent style can harm readability in a project; consider using no-finnish to ban Finnish notation if you don't use it in your project.

Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.

Further reading

Related To

Resources