Skip to content

Commit

Permalink
Adds TOML example of custom rule definition to custom category desc…
Browse files Browse the repository at this point in the history
…ription
  • Loading branch information
bvobart committed Jul 16, 2021
1 parent 117ca38 commit 2648009
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions categories/categories.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ Custom rules may also be useful for creating 'plugins' to ` + "`mllint`" + `, th
that ` + "`mllint`" + ` does not yet have built-in rules for.
` + "`mllint`" + ` will pick up these custom rules from your configuration and automatically run their checks during its analysis.
It is also possible to use the ` + "`mllint describe`" + ` command with custom rules. Similarly, ` + "`mllint list all`" + `
It is also possible to use the ` + "`mllint describe`" + ` command with custom rules. Similarly, ` + "`mllint list all`" + ` also lists all custom linting rules.
---
To create such a custom rule, write a script or program that checks whether your project adheres to a certain practice and prints a simple YAML or JSON object
containing the score for this rule, possibly along with some detail text. Then, add the rule's name, slug, details and run command
to your project's ` + "`mllint`" + ` config.
Expand All @@ -192,13 +194,24 @@ See the table below for more details about each of the custom rule definition's
` + "```yaml" + `
rules:
custom:
- name: Project contains a LICENSE file.
- name: Project contains a LICENSE file
slug: custom/is-licensed
details: This rule checks whether the project contains a LICENSE or LICENSE.md file at the project's root.
weight: 1
run: bash ./scripts/mllint/check-license.sh
` + "```" + `
The equivalent configuration in TOML syntax (for ` + "`pyproject.toml`" + ` files) is as follows. Multiple of these snippets can be repeated for defining more rules.
` + "```toml" + `
[[tool.mllint.rules.custom]]
name = "Project contains a LICENSE file"
slug = "custom/is-licensed"
details = "This rule checks whether the project contains a LICENSE or LICENSE.md file at the project's root."
weight = 1.0
run = "bash ./scripts/mllint/check-license.sh"
` + "```" + `
Property | Type | Description
---------|------|-------------
` + "`name`" + ` | string | A short and concise sentence on what this rule expects of a project / what the rule enforces on the project. Feel free to take inspiration from the names given to ` + "`mllint`'s" + ` built-in rules.
Expand Down

0 comments on commit 2648009

Please sign in to comment.