1.2.0 • Published 2 years ago

@bentinata/fmt v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

@bentinata/fmt

Main goal is to have formatting without hassle like rustfmt/cargo fmt or gofmt/go fmt.

Installation & Usage

fmt [PATTERN ...]

With PATTERN being:

  • file
  • directory
  • glob

Running without specifying PATTERN would run as if PATTERN is . (fmt .), and would run recursively on all file within current directories.

Example:

fmt index.js src lib/*.js

This would format index.js, all supported files inside src/, and all .js files inside lib/.

Install it with:

npm install --save-dev @bentinata/fmt

Then use it:

./node_modules/.bin/fmt [PATTERN ...]

You can also put it in package.json scripts:

{
  "scripts": {
    "fmt": "@bentinata/fmt"
  }
}

And run it like:

npm run fmt [PATTERN ...]

Note: npx cannot be used because eslint require plugin to be installed. Read more about it here.

Running eslint yourself / Extending (Optional)

fmt job is just to format. If you want to know what the eslint error is, you need to run it yourself.

eslint:

You need to use JS config instead of JSON/YAML. Put this in your .eslintrc.js:

module.exports = require("@bentinata/fmt").eslint;

Or, if you want to extend it with your own config:

module.exports = {
  ...require("@bentinata/fmt").eslint,
};

prettier:

Same as eslint. You need to use JS config instead of JSON/YAML. Put this in your .prettierrc.js:

module.exports = require("@bentinata/fmt").prettier;