Skip to content

AlexeyDuybo/effector-alt-api

Repository files navigation

Effector alt api

Install

Works with TS 5.x.x and above

npm i --save-dev effector-alt-api eslint-plugin-effector-alt-api

effector-alt-api

This package contains alternative types for Effector operators. (atm only sample available).

See examples and explanation: TS Playground

eslint-plugin-effector-alt-api

This package constains eslint plugin that transforms original operators to alternative and vice verse.

Plugin setup

  • Add "eslint-plugin-effector-alt-api" to the "plugins" array in your .eslintrc.* file, and extend recommended config.
{
    "extends": ["plugin:effector-alt-api/recommended"],
    "parser": "@typescript-eslint/parser",
    "plugins": ["effector-alt-api"]
}
  • Enable code fixing on save in IDE. VSCode example.
{
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": "always"
    },
}

Transformation

To transform original operators to alternative and vice verse just add exclamation point to the end of the operator, then save the file and your code editor will have to transform the code.

    sample({
        clock: clock,
        source: source,
        target: target
    })!;

    // will transform to 

    ({} as import('effector-alt-api').Sample)
        .clock(clock)
        .source(source, target);

and

    ({} as import('effector-alt-api').Sample)
        .clock(clock)
        .source(source, target)!;
    
    // will transform to

       sample({
        clock: clock,
        source: source,
        target: target
    });

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published