Git Product home page Git Product logo

stylist's Introduction

Stylist

build codecov

Stylist aggregates all your code quality tools into a single, fast, and easy to use executable. You define the tools your project uses in .stylist.yml:

---
# A "processor" is a code quality tool (linter, scanner, formatter, etc...)
processors:

  ############################################################
  # Stylist comes with presets for many common tools...
  ############################################################

  - preset: cspell
    includes:
      - "**/*"
    excludes:
      - "problem-file1.txt"
      - "problem-file2.txt"

  - preset: gofmt
    includes:
      - "**/*.go"

  - preset: golangci-lint
    includes:
      - "**/*.go"
    excludes:
      - "gen/*"

  - preset: markdownlint
    includes:
      - "**/*.md"

  ############################################################
  # ... or you can provide custom configuration.
  ############################################################

  - name: custom-tool
    includes:
      - "**/*.{ext1,ext2,ext3}"
    # Processors define check and/or fix commands
    # (check commands report issues, fix commands correct them).
    # See the documentation for more detail.
    check:
      command: "custom-tool lint --output=sarif"
      input: variadic
      output: stdout
      format: sarif
    fix:
      command: "custom-tool lint --auto-fix --output=sarif"
      input: variadic
      output: stdout
      format: sarif

Then run stylist's check and fix commands:

$ stylist check
[cspell] main.go:8:16 Unknown word 'someFunc' (spelling)
[golangci-lint] main.go:8:16 Error return value of `someFunc` is not checked (errcheck)
[markdownlint] README.md:1:9 Trailing punctuation in heading [Punctuation: ':'] (MD026)
[markdownlint] README.md:3:81 Line length [Expected: 80; Actual: 153] (MD013)

$ stylist fix
[markdownlint] README.md

Installation

Using Homebrew

brew install twelvelabs/tap/stylist

Pre-built binary

Download a pre-built binary from the Releases page.

From source

go install "github.com/twelvelabs/stylist@latest"
# or a specific version tag
tag=$(gh release view --json tagName --jq .tagName)
go install "github.com/twelvelabs/stylist@${tag}"

stylist's People

Contributors

dependabot[bot] avatar twelvelabs avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

stylist's Issues

add config option to limit issues by severity

Probably should be done in Pipeline.transform(), as that's where we're currently sorting. Maybe pass the context to that method so we can read the config. Might also want to make the sort order configurable, too.

editor config support

Support reading editorconfig data (if present) and make those values available to pass through to commands.

For example, many formatting tools support configuring indentation via a CLI flag. Stylist could allow for something like:

processors:
  - name: jsonfmt
    includes:
      - "**/*.{json}"
    fix:
      command: "jsonfmt --indent {{ .indent_size }}"
      input: variadic
      output: none

... where indent_size would be read from .editorconfig.

To implement:

  1. We'd need to come up w/ some rules for how we resolve editorconfig values for a given batch of paths. Theoretically you can have values defined in .editorconfig per-file, though in practice most people likely have them defined per-filetype. If we're executing a command for a batch of files, which path do we use to determine the editor config values? Personally I think just using the first file will be fine, but we'd need to validate and document that.

  2. After resolving editorconfig values, we'd need to run the command string through text/template. Might want to think about tools that don't expose flags and only support config files... maybe allow for specifying a config template that we render to /tmp and expose via a {{ .rendered_config_path }} var? Though if we want to do that, should create a separate issue.

unexpected severity level results in error

If a processor returns an unknown severity level, stylist aborts and returns a semi-cryptic error message:

$ stylist check

Error: foo is not a valid ResultLevel

We should just fail gracefully and coerce any unexpected severity to error.

do not collect context info when configured to exclude

Currently we still calculate context lines even when the output.show_context config setting is set false. This can end up taking a huge amount of time in projects with a large amount of issues to report. We should only calculate context when the setting is true.

add config option to show rule URI in output

Something like:

[shellcheck] bin/command.sh:6:6 Double quote to prevent globbing and word splitting. (SC2086) <https://www.shellcheck.net/wiki/SC2086>

On by default, but users can disable if it's too busy.

auto exclude gitignore patterns

If a gitignore file is present, we should auto-exclude any listed patterns.

  • There should be a config option to opt-out of this behavior.
    • We already need to add the context to PathIndexer, could pull the Config out of the context.
  • See: PathIndexer.exclude for where to hook place the logic.
  • See: https://github.com/sabhiram/go-gitignore

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.