astral-sh / ruff-pre-commit

A pre-commit hook for Ruff.
Apache License 2.0
802 stars 38 forks source link

Can ruff-pre-commit be configured to replace pre-commit-hooks like trailing-whitespace, end-of-file-fixer and check-ast? #80

Closed mcarans closed 3 months ago

mcarans commented 3 months ago

I am using some pre-commit-hooks along with ruff. Can ruff already do what those pre-commit hooks (trailing-whitespace, end-of-file-fixer and check-ast) do? If so, how do I configure the ruff pre-commit to replace any or all of those hooks?

- repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-ast
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.3.2
    hooks:
      # Run the linter.
      - id: ruff
        args: [--config, .config/ruff.toml, --fix]
      # Run the formatter.
      - id: ruff-format
        args: [--config, .config/ruff.toml]
woctezuma commented 3 months ago

ruff is a "Python linter and code formatter", so I doubt that it would try to format your text files, etc.

dhruvmanila commented 3 months ago

Hey, thanks for using Ruff!

I believe those hooks work on any type of files while Ruff is primarily focused on Python files. I don't think this is in our current scope.