Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using async-await-codemod with putout #7

Open
coderaiser opened this issue Aug 7, 2019 · 0 comments
Open

Using async-await-codemod with putout #7

coderaiser opened this issue Aug 7, 2019 · 0 comments

Comments

@coderaiser
Copy link

coderaiser commented Aug 7, 2019

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 🙂.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant