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
12 changes: 6 additions & 6 deletions .github/renovate-tracked-deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
"packageName": "renovate",
"datasource": "npm"
},
"pipx:codespell": {
"packageName": "codespell",
"datasource": "pypi"
},
"ruff": {
"packageName": "astral-sh/ruff",
"datasource": "github-releases"
Expand All @@ -70,6 +66,10 @@
"taplo": {
"packageName": "tamasfe/taplo",
"datasource": "github-releases"
},
"typos": {
"packageName": "crate-ci/typos",
"datasource": "github-releases"
}
},
"files": {
Expand Down Expand Up @@ -116,14 +116,14 @@
"lychee",
"node",
"npm:renovate",
"pipx:codespell",
"release-plz",
"ruff",
"rumdl",
"rust",
"shellcheck",
"shfmt",
"taplo"
"taplo",
"typos"
]
},
"src/init/scaffold.rs": {
Expand Down
2 changes: 1 addition & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@
"ktlint",
"lychee",
"npm:renovate",
"pipx:codespell",
"ruff",
"rumdl",
"shellcheck",
"shfmt",
"taplo",
"typos",
],
groupName: "linters",
commitMessageTopic: "flint-managed linter updates",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ Click a name in the table below for details. See the
| [`biome-format`](docs/linters.md#biome-format) | Format JS/TS/JSON files | yes |
| [`cargo-clippy`](docs/linters.md#cargo-clippy) | Lint Rust code; runs on all .rs files, not just changed | yes |
| [`cargo-fmt`](docs/linters.md#cargo-fmt) | Format Rust code; runs on all .rs files, not just changed | yes |
| [`codespell`](docs/linters.md#codespell) | Check for common spelling mistakes | yes |
| [`dotnet-format`](docs/linters.md#dotnet-format) | Format C# code | yes |
| [`editorconfig-checker`](docs/linters.md#editorconfig-checker) | Check files comply with EditorConfig settings | — |
| [`flint-setup`](docs/linters.md#flint-setup) | Keep Flint setup current and mise.toml lint tooling canonical | yes |
Expand All @@ -208,6 +207,7 @@ Click a name in the table below for details. See the
| [`shellcheck`](docs/linters.md#shellcheck) | Lint shell scripts for common mistakes | — |
| [`shfmt`](docs/linters.md#shfmt) | Format shell scripts | yes |
| [`taplo`](docs/linters.md#taplo) | Format TOML files | yes |
| [`typos`](docs/linters.md#typos) | Check for common spelling mistakes | yes |
| [`xmllint`](docs/linters.md#xmllint) | Validate XML files are well-formed | — |

<!-- registry-table-end -->
Expand Down
4 changes: 2 additions & 2 deletions default.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
"ktlint",
"lychee",
"npm:renovate",
"pipx:codespell",
"ruff",
"rumdl",
"shellcheck",
"shfmt",
"taplo"
"taplo",
"typos"
],
"groupName": "linters",
"commitMessageTopic": "flint-managed linter updates",
Expand Down
22 changes: 11 additions & 11 deletions docs/linters.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,6 @@ still choose the config directory via `FLINT_CONFIG_DIR` where supported.
| Patterns | `*.rs` |
| Config | `rustfmt.toml` |

## `codespell`

| | |
| ----------- | ---------------------------------- |
| Description | Check for common spelling mistakes |
| Fix | yes |
| Binary | `codespell` |
| Scope | [files](#scope-files) |
| Patterns | `*` |
| Config | `.codespellrc` |

## `dotnet-format`

| | |
Expand Down Expand Up @@ -342,6 +331,17 @@ flint's existing formatter-style checks.
Current caveat: Taplo's published docs currently advertise TOML 1.0.0
support, so treat this check as TOML 1.0-oriented for now.

## `typos`

| | |
| ----------- | ---------------------------------- |
| Description | Check for common spelling mistakes |
| Fix | yes |
| Binary | `typos` |
| Scope | [files](#scope-files) |
| Patterns | `*` |
| Config | `_typos.toml` |

## `xmllint`

| | |
Expand Down
2 changes: 1 addition & 1 deletion mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ hadolint = "2.14.0"
ktlint = "1.8.0"
lychee = "0.22.0"
"npm:renovate" = "43.141.6"
"pipx:codespell" = "2.4.2"
ruff = "0.15.12"
rumdl = "0.1.78"
shellcheck = "0.11.0"
shfmt = "v3.13.1"
taplo = "0.10.0"
typos = "1.46.0"

[tasks."setup:update-super-linter-versions"]
description = "Generate super-linter version mapping from the super-linter repo"
Expand Down
13 changes: 12 additions & 1 deletion src/init/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use anyhow::Result;
use std::collections::HashSet;
use std::path::Path;

use crate::linters::typos::MigrationResult as TyposMigrationResult;
use crate::registry::{Check, EditorconfigDirectiveStyle, EditorconfigLineLengthPolicy, builtin};

use super::config_files::{
Expand All @@ -20,6 +21,7 @@ pub(super) struct RepoMigrationSummary {
legacy_files_removed: Vec<String>,
stale_md013_comments_removed: Vec<String>,
stale_editorconfig_checker_comments_removed: Vec<String>,
typos_migration: TyposMigrationResult,
}

struct MigrationInputs {
Expand All @@ -35,6 +37,7 @@ impl RepoMigrationSummary {
&& self.legacy_files_removed.is_empty()
&& self.stale_md013_comments_removed.is_empty()
&& self.stale_editorconfig_checker_comments_removed.is_empty()
&& !self.typos_migration.changed()
}

pub(super) fn print_messages(&self) {
Expand All @@ -56,6 +59,7 @@ impl RepoMigrationSummary {
for rel in &self.stale_editorconfig_checker_comments_removed {
println!(" removed stale editorconfig-checker directives from <REPO>/{rel}");
}
self.typos_migration.print_messages();
}
}

Expand All @@ -76,19 +80,23 @@ pub(crate) fn apply_setup_migrations(project_root: &Path, config_dir: &Path) ->
&unsupported_keys,
legacy_markdownlint_stack_active(&inputs.tool_keys),
)?;
migration_summary.print_messages();
Ok(!migration_summary.is_noop())
}

pub(crate) fn detect_setup_migrations(project_root: &Path) -> Result<bool> {
let inputs = migration_inputs(project_root)?;
let obsolete_keys = crate::registry::obsolete_keys();
let unsupported_keys = crate::registry::unsupported_keys();
let migration_summary = detect_setup_migrations_with_keys(
let mut migration_summary = detect_setup_migrations_with_keys(
&obsolete_keys,
&unsupported_keys,
&inputs.tool_keys,
&inputs.mise_content,
);
if crate::linters::typos::legacy_config_present(project_root) {
migration_summary.typos_migration.wrote_target = true;
}
Ok(!migration_summary.is_noop())
}

Expand Down Expand Up @@ -219,6 +227,7 @@ fn detect_setup_migrations_with_keys(
legacy_files_removed: vec![],
stale_md013_comments_removed: vec![],
stale_editorconfig_checker_comments_removed: vec![],
typos_migration: TyposMigrationResult::default(),
}
}

Expand Down Expand Up @@ -256,6 +265,7 @@ fn apply_repo_migrations_with_keys(
} else {
vec![]
};
let typos_migration = crate::linters::typos::migrate_legacy_config(project_root, config_dir)?;

Ok(RepoMigrationSummary {
replaced_obsolete,
Expand All @@ -264,6 +274,7 @@ fn apply_repo_migrations_with_keys(
legacy_files_removed,
stale_md013_comments_removed,
stale_editorconfig_checker_comments_removed,
typos_migration,
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const DEFAULT_LINE_LENGTH: u16 = 120;
pub enum Profile {
/// Primary language linters only (ruff, cargo-clippy, golangci-lint, …).
Lang,
/// Lang + supplementary checks + fast general tools (shellcheck, rumdl, codespell, …).
/// Lang + supplementary checks + fast general tools (shellcheck, rumdl, typos, …).
Default,
/// Default + slow linters (renovate-deps).
Comprehensive,
Expand Down Expand Up @@ -206,7 +206,7 @@ fn default_category_items() -> Vec<CategoryItem> {
CategoryItem {
selected: true,
category: Category::Default,
label: "general — general tools (codespell, ec, lychee, …)",
label: "general — general tools (typos, ec, lychee, …)",
},
CategoryItem {
selected: false,
Expand Down
2 changes: 1 addition & 1 deletion src/init/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ fn compute_desired_tools_lang_profile() {
assert!(!tools.contains_key("shellcheck"));
assert!(!tools.contains_key("shfmt"));
assert!(tools.contains_key("rust"));
assert!(!tools.contains_key("pipx:codespell"));
assert!(!tools.contains_key("typos"));
}

#[test]
Expand Down
27 changes: 14 additions & 13 deletions src/linters/flint_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ pub async fn run(fix: bool, project_root: &Path, config_dir: &Path) -> LinterOut
}
}

let setup_migrations_pending = match crate::init::detect_setup_migrations(project_root) {
Ok(pending) => pending,
Err(e) => {
return LinterOutput::setup_err(
SetupOutcome::Fatal,
format!("flint: flint-setup: {e}\n"),
);
}
};
if setup_migrations_pending {
setup_outcome = setup_outcome.at_least(SetupOutcome::Blocking);
errors.push("legacy Flint setup files or config need migration.".to_string());
}

if errors.is_empty() {
return LinterOutput {
ok: true,
Expand All @@ -108,19 +122,6 @@ pub async fn run(fix: bool, project_root: &Path, config_dir: &Path) -> LinterOut
};
}

let setup_migrations_pending = match crate::init::detect_setup_migrations(project_root) {
Ok(pending) => pending,
Err(e) => {
return LinterOutput::setup_err(
SetupOutcome::Fatal,
format!("flint: flint-setup: {e}\n"),
);
}
};
if setup_migrations_pending {
setup_outcome = setup_outcome.at_least(SetupOutcome::Blocking);
}

let _migrations_applied = match crate::init::apply_setup_migrations(project_root, config_dir) {
Ok(applied) => applied,
Err(e) => {
Expand Down
1 change: 1 addition & 0 deletions src/linters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod renovate_deps;
pub mod rumdl;
pub mod rustfmt;
pub mod taplo;
pub mod typos;
pub mod yamllint;

pub use crate::registry::LinterOutput;
Expand Down
2 changes: 1 addition & 1 deletion src/linters/renovate_deps/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ fn not_relevant_for_untracked_change() {
}

#[test]
fn relevant_when_snapshot_is_unparseable() {
fn relevant_when_snapshot_is_unparsable() {
let dir = tempfile::tempdir().unwrap();
std::fs::create_dir_all(dir.path().join(".github")).unwrap();
std::fs::write(
Expand Down
Loading
Loading