Skip to content

Using async-await-codemod with putoutΒ #7

@coderaiser

Description

@coderaiser

Hi, thank you, for such a useful codemod :).

I just added support of jscodeshift to a pluggable code transformer putout, and used your codemod for tests.

Putout does something similar to eslint but with more transforms, and it's better then jscodeshift because it supports plugins, and can be used in a day-to-day basis.

Your codemod can be integrated to any project with:

npm i https://github.com/sgilroy/async-await-codemod.git

And updating .putout.json with:

{
    "jscodeshiftPlugins": [
        "async-await-codemod/async-await"
    ]
}

(such a long path, because you don't use main entry of package.json)

Also user can provide custom message with help of such modifications of .putout.json:

{
    "jscodeshiftPlugins": [
        ["async-await-codemod/async-await", "async-await should be used instead of Promises"]
    ]
}  

And then just run putout lib test or putout lib test --fix for fixing.

async-await-codemod already works good, but would be great if you publish it to npm and add main section. And will be amazing if you convert your codemod to putout plugin πŸ˜‰ (it will have ability to report problem parts, and to use a rich babel infrastructure).

Anyways even without converting your codemod already can be used with putout in more pleasant way then with jscodeshift, and here is why:

  • no need to clone the whole repo
  • integrating with eslint and all the IDE that has eslint extensions
  • ability to use in a day-to-day basis, as an addition to lint

Here is how it looks like for such code:

function promise() {
    return hello().then(world);
}
$ putout jscodeshift.js
/home/coderaiser/putout/packages/putout/jscodeshift.js
 2:0   error   async-await should be used instead of Promises            jscodeshift/async-await-codemod/async-await

βœ– 1 errors in 1 files
  fixable with the `--fix` option

By the way, async-await-codemod is in the list of recommended jscodeshift codemods that is recommended to be used with putout πŸ™‚.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions