TAAFT
Free mode
100% free
Freemium
Free Trial
Deals

google / pre-commit-tool-hooks

Hooks for use with http://pre-commit.com/ tooling

38 5 Language: Python License: Apache-2.0 Updated: 5mo ago

README

pre-commit-tool-hooks

This repository contains hooks for use with pre-commit.

Table of contents

Using pre-commit-tool-hooks with pre-commit

Add this to your .pre-commit-config.yaml:

- repo: https://github.com/google/pre-commit-tool-hooks
  rev: vTODO # Use the rev you want to point at.
  hooks:
      - id: check-copyright
      # - id: ...

Hooks

Verifies that files contain a copyright statement. Looks for a Google Apache 2.0
license by default. To customize, pass --copyright=<text>, using YYYY for
year substitution.

In .pre-commit-config.yaml, put:

- id: check-copyright
  args:
      - --copyright
      - |+
          Copyright YYYY my organization
          with multiple lines

--custom_format overrides copyright formatting for a given path pattern. It
may be specified multiple times to override multiple path patterns. The first
matching --custom_format will be used; if none match, the built-in copyright
defaults will be used.

--custom_format takes four arguments:

  1. PATH_PATTERN: A path regex that must match the input path.
  2. PREFIX: A prefix block for the copyright.
  3. PER_LINE_PREFIX: The per-line prefix for the copyright.
  4. SUFFIX: A suffix block for the copyright.

If a prefix or suffix is not desired, pass an empty string.

For example, to get JavaScript copyright formatting like:

/**
 * Copyright
 */

Do:

- id: check-copyright
  args:
      - --custom_format
      - '\.js$'
      - '/**'
      - ' * '
      - ' */'

To instead get formatting like:

// Copyright

Do:

- id: check-copyright
  args:
      - --custom_format
      - '\.js$'
      - ''
      - '// '
      - ''

Escaping is not generally supported, but \- is required to escape a starting
-. For example, to get HTML-style comments, the closing --> must be escaped:

- id: check-copyright
  args:
      - --custom_format
      - '\.plist$'
      - ''

check-google-doc-style

Checks documentation against the
Google developer documentation style guide,
with a principle of automatically generating fixes over erroring for manual
edits. Note, while no manual fixes are requested today, some may be added in the
future.

This does not handle reformatting of edits. Please use a tool like
Prettier to fix formatting.

In .pre-commit-config.yaml, put:

- id: check-google-doc-style

To disable this on sections of a markdown file, use the ignore/resume comments:

Checked



Ignored



Checked

Checks links for correctness. For example, ensures that markdown links point at
valid anchors within the doc.

--anchors-only may be passed to only validate intra-document anchors. In other
words, cross-document links such as /foo.md#bar will not be validated (even to
see if foo.md exists) while #bar will be validated to ensure a Bar header
exists within the checked document.

In .pre-commit-config.yaml, put:

- id: check-links

markdown-toc

Generates a Prettier-compatible table of contents for
Markdown files.

In a markdown file, put the and markers to
indicate where to put the table of contents:

# Document title




## Header

### Sub-header

This will generate a table of contents based on non-title headers:

# Document title



## Table of contents

-   [Header](#header)
    -   [Sub-header](#sub-header)



## Header

### Sub-header

In .pre-commit-config.yaml, put:

- id: markdown-toc

This generates bullets with a four space indent. When used with Prettier, it's
recommended to specify the tabWidth in .prettierrc.yaml to match:

overrides:
    - files: '*.md'
      options:
          tabWidth: 4
0 AIs selected
Clear selection
#
Name
Task