Skip to content
Merged
Show file tree
Hide file tree
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
56 changes: 44 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,21 @@ Then wire up top-level `lint` and `fix` tasks that reference whichever tasks
you adopted (add any project-specific subtasks to the `depends` list):

```toml
[tasks."lint:fast"]
description = "Run fast lints (no Renovate)"
depends = ["lint:super-linter", "lint:links"]

[tasks.lint]
description = "Run all lints"
depends = ["lint:super-linter", "lint:links", "lint:renovate-deps"]
depends = ["lint:fast", "lint:renovate-deps"]

[tasks.fix]
description = "Auto-fix lint issues and regenerate tracked deps"
run = "AUTOFIX=true mise run lint"

[tasks.native-lint]
description = "Run lints natively (no container)"
run = "NATIVE=true mise run lint:fast"
```

Finally, extend the flint [Renovate preset](#automatic-version-updates-with-renovate)
Expand Down Expand Up @@ -160,6 +168,11 @@ Docker versioning).
| `--native` | Run linters natively instead of via container |
| `--full` | Lint all files instead of only changed files |

`--autofix` and `--native` can also be set via the `AUTOFIX=true`
and `NATIVE=true` environment variables respectively. This is how
the `fix` and `native-lint` meta-tasks propagate them through the
`depends` chain.

When autofix is not enabled, all `FIX_*` lines are filtered out of
the env file before running Super-Linter.

Expand Down Expand Up @@ -405,11 +418,14 @@ committed `.github/renovate-tracked-deps.json`:
scans, the linter will detect the change and require
regeneration.

## How AUTOFIX Works
## How AUTOFIX and NATIVE Work

Lint scripts that support fixing accept an `--autofix` flag. Autofix
can also be enabled via the `AUTOFIX=true` environment variable, which
is how the `fix` meta-task propagates it through the dependency chain.
`lint:super-linter` accepts `--autofix` and `--native` flags.
Both can also be set as environment variables (`AUTOFIX=true`,
`NATIVE=true`), which is how the `fix` and `native-lint`
meta-tasks propagate them — mise's `depends` cannot forward CLI
flags, but env vars flow through naturally. Tasks that don't
recognize these variables simply ignore them.

**Check mode** (default):

Expand All @@ -431,27 +447,43 @@ mise run lint:renovate-deps --autofix # Regenerate tracked deps
Linters that don't support autofix (like lychee link checker)
silently ignore the `AUTOFIX` environment variable.

**Native mode:**

```bash
mise run native-lint # Fast lints, natively (no container)
# Or run directly:
NATIVE=true mise run lint:fast # Same effect
mise run lint:super-linter --native # Single task with CLI flag
```

Native mode is useful in environments where Docker/Podman is
unavailable (e.g., inside containers, CI hooks). `native-lint`
targets `lint:fast` (super-linter + links), skipping
`lint:renovate-deps` which requires the Renovate CLI. Tasks
that don't use a container (like `lint:links`) ignore the
`NATIVE` variable.

## Pre-commit hook

Flint provides a `pre-commit` task that runs native linters with
autofix on every commit — fast feedback without the container
overhead. To set it up:
Flint provides a `pre-commit` task that runs native linters on
every commit — fast feedback without the container overhead. To
set it up:

```bash
mise run setup:pre-commit-hook
```

This generates a `.git/hooks/pre-commit` that runs
`mise run pre-commit`, which uses `--native --autofix` to fix
formatting issues before the commit completes.
`mise run pre-commit`, which uses native mode for fast checks
without requiring a container.

**For consuming repos**, add these tasks to your `mise.toml`:

```toml
[tasks.pre-commit]
description = "Pre-commit hook: native lint with autofix"
description = "Pre-commit hook: native lint"
depends = ["setup:native-lint-tools"]
run = "mise run lint:super-linter -- --native --autofix"
run = "NATIVE=true mise run lint:fast"

[tasks."setup:pre-commit-hook"]
description = "Install git pre-commit hook"
Expand Down
16 changes: 12 additions & 4 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ file = "tasks/lint/super-linter.sh"
[tasks."lint:super-linter-native"]
description = "Run linters natively (fast, for local dev)"
depends = ["setup:native-lint-tools"]
run = "mise run lint:super-linter -- --native"
run = [{ task = "lint:super-linter", env = { NATIVE = "true" } }]

[tasks."setup:native-lint-tools"]
description = "Install native lint tools matching the pinned super-linter version"
Expand All @@ -34,18 +34,26 @@ file = "tasks/lint/links.sh"
description = "Verify renovate-tracked-deps.json is up to date"
file = "tasks/lint/renovate-deps.py"

[tasks."lint:fast"]
description = "Run fast lints (no Renovate)"
depends = ["lint:super-linter", "lint:links"]

[tasks."lint"]
description = "Run all lints"
depends = ["lint:super-linter", "lint:links", "lint:renovate-deps"]
depends = ["lint:fast", "lint:renovate-deps"]

[tasks.fix]
description = "Auto-fix lint issues and regenerate tracked deps"
run = "AUTOFIX=true mise run lint"

[tasks.native-lint]
description = "Run lints natively (no container)"
run = "NATIVE=true mise run lint:fast"

[tasks.pre-commit]
description = "Pre-commit hook: native lint with autofix"
description = "Pre-commit hook: native lint"
depends = ["setup:native-lint-tools"]
run = "mise run lint:super-linter -- --native --autofix"
run = "NATIVE=true mise run lint:fast"

[tasks."setup:pre-commit-hook"]
description = "Install git pre-commit hook that runs native linting"
Expand Down
5 changes: 4 additions & 1 deletion tasks/lint/super-linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ if [ "${usage_autofix:-}" = "true" ]; then
fi

# shellcheck disable=SC2154 # usage_native is set by mise
NATIVE="${usage_native:-false}"
if [ "${usage_native:-}" = "true" ]; then
NATIVE=true
fi
NATIVE="${NATIVE:-false}"

# shellcheck disable=SC2154 # usage_full is set by mise
LINT_ALL="${usage_full:-false}"
Expand Down
Loading