Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions docs/guides/linter.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ class NoMissingOwner(Rule):

Place a rule's code in the project's `linter/` directory. SQLMesh will load all subclasses of `Rule` from that directory.

If the rule is specified in the project's [configuration file](#applying-linting-rules), SQLMesh will run it when the project is loaded. All SQLMesh commands will load the project, except for `create_external_models`, `migrate`, `rollback`, `run`, `environments`, and `invalidate`.
If the rule is specified in the project's [configuration file](#applying-linting-rules), SQLMesh will run it when:
- A plan is created during `sqlmesh plan`
- The command `sqlmesh lint` is ran

SQLMesh will error if a model violates the rule, informing you which model(s) violated the rule. In this example, `full_model.sql` violated the `NoMissingOwner` rule:
SQLMesh will error if a model violates the rule, informing you which model(s) violated the rule. In this example, `full_model.sql` violated the `NoMissingOwner` rule, essentially halting execution:

``` bash
$ sqlmesh plan
Expand All @@ -111,6 +113,20 @@ Linter errors for .../models/full_model.sql:
Error: Linter detected errors in the code. Please fix them before proceeding.
```

Or through the standalone command, for faster iterations:

``` bash
$ sqlmesh lint

Linter errors for .../models/full_model.sql:
- nomissingowner: Model owner should always be specified.

Error: Linter detected errors in the code. Please fix them before proceeding.
```

Use `sqlmesh lint --help` for more information.


## Applying linting rules

Specify which linting rules a project should apply in the project's [configuration file](./configuration.md).
Expand Down