feat(cli): add [lint.extra] for per-file lint rules#476
Open
feat(cli): add [lint.extra] for per-file lint rules#476
[lint.extra] for per-file lint rules#476Conversation
Enable per-file lint rule sets via a new `[lint.extra]` config section in mops.toml. Each entry maps a file glob to additional rule directories, triggering separate lintoko invocations on matched files alongside the base rules that always run on all files. Made-with: Cursor
…lue test Made-with: Cursor
Replace per-fixture symlinks with relative paths in mops.toml pointing to ../_shared-rules. Symlinks remain only for dirs discovered by convention (lints/, rules/) that can't be configured. Made-with: Cursor
Point new test fixtures to ../lint/lints in mops.toml instead of maintaining a separate _shared-rules directory. Pre-existing test fixtures are restored to their original state (zero diff). Made-with: Cursor
Merge 9 fixture directories into 4. Use snapshot tests to capture verbose lintoko output for the interesting cases (extra fail, edge cases, base+extra, --rules isolation with multi-rules). Made-with: Cursor
- runLintoko returns boolean instead of calling cliError on lint failure; failures accumulate across base + extra runs so users see all errors in a single pass - Fix types-only example query (use @filter allowlist instead of blacklisting individual node kinds) - Add lint-extra-example-rules test fixture with no-types, types-only, and migration-only rules validated against real Motoko files - Make no-match glob warning unconditional (consistent with other warns) - Remove lintoko rule examples from mops docs (lintoko's domain) - Clarify that [lint] args applies to all runs (base + extra) Made-with: Cursor
Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
All lint rules currently apply uniformly to every
.mofile in a project. There's no way to enforce file-specific constraints — e.g. "Types.mo must only contain type declarations" or "migration files must not expose public functions other thanmigration()" — without maintaining separate lintoko invocations outside ofmops lint.Solution
Add a
[lint.extra]section tomops.tomlthat maps file globs to additional rule directories:Each entry triggers a separate
lintokoinvocation on matched files, in addition to the base rules that always run on all files.Design decisions
--rulesCLI flag only affects the base run —[lint.extra]entries always run independently, keeping CLI overrides scoped to the main rule setmops lint <filter>scopes extra runs to the same file set as the base run (no surprising out-of-scope linting)[lint] argsand CLI extra args are forwarded to all runs (base + extra) via a sharedbuildCommonArgshelperTest plan