bencoveney / barrelsby

Automatic TypeScript barrels (index.ts files) for your entire code base

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Run code formatter after write

vjpr opened this issue · comments

I would like to be able to run prettier on the file output. Maybe a post-write event hook? Or built-in prettier support would be cool.

One way of going about this would be to modify barrelsby's output so that it is easier to feed forward to CLI linting tools.

Inspired by the examples in https://prettier.io/docs/en/precommit.html - rather than running barrelsby on its own you could imagine running:

{
  "scripts": {
    "create-barrels": "barrelsby | xargs ./node_modules/.bin/prettier --ignore-unknown --write"
  }
}

In other words,:

  • Run barrelsby.
  • It outputs the names of:
    -- any/all files modified?
    -- all barrels?
  • Those can then be piped on to any desired tooling.

I suspect that the APIs for various formatters will be different enough that the CLI is probably the easiest common way to support them all.

@vjpr would that work for your use-case?

commented

@vjpr are you trying to run prettier only on the barrel files or are you wanting prettier to run after you create barrel files. If it's the latter, why not just use barrelsby <args> && prettier --write (or however you run prettier) in an npm script?

No activity has been seen recently, marking as stale. If this is a mistake please reach out to a collaborator