Skip to content

Latest commit

 

History

History
103 lines (77 loc) · 2.35 KB

README.md

File metadata and controls

103 lines (77 loc) · 2.35 KB

garou

Do thing what heroes didn't do.

npm github node

Features

A code refactoring tool, fixing what eslint/stylelint shouldn't care about, what prettier didn't care about. Offering better code comparing for git diff.

  • Enforce consistent brace style
  • Handle tsx/jsx/vue self closing
  • Handle text case from css/scss/less
  • Remove vendor prefix from css/scss/less
  • Handle whitespace, empty line between code
  • Sort html/htm attributes
  • Sort jsx/tsx props
  • Sort tsx/ts/mts/cts/jsx/js/mjs/cjs class members
  • Sort tsx/ts/mts/cts/jsx/js/mjs/cjs import / export
  • Sort vue component properties / attributes
  • Dedupe yarn v1 lockfile
  • Remove cnpm cache from yarn v1 lockfile
  • Sort OpenAPI Specification config files (json/yaml/yml)
  • ...other fixing

Installation

npm install garou --save-dev

Usage

npm exec garou .
npm exec garou src
npm exec garou **/foo.js

Run without installation

npx garou .

Configuration

// example: package.json
{
  "garou": {
    "import-groups": [
      // see: https://github.com/lydell/eslint-plugin-simple-import-sort#custom-grouping
      ["react", "react-dom"],
      // shorthand for ["^@external\\/"]
      "^@external\\/",
      "lodash"
    ],
    "ignore": ["fixture/**"]
  }
}

Tips

Using garou with lint-staged

// package.json
{
  "lint-staged": {
    "*": ["garou", "prettier", "eslint --fix"]
  }
}

Using garou might mess up your format, I suggest run garou before run prettier.

Read more at the lint-staged repo.

OpenAPI Specification file sorting

Garou will sort your file when it has openapi properties as 3.x.x.

npm exec garou "**/*.{json,yaml,yml}"

Inspiration

This project is inspired by sortier.

Related