-
Notifications
You must be signed in to change notification settings - Fork 61
Expose custom validators then use one for last_modified #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9a93f06
Add models for new rules structure
reidbaker e210211
Added custom rules, documenation and examples
reidbaker 483fee3
formatting
reidbaker 967aa23
formatting
reidbaker 31fd928
Change the structure of flag parsing and rules to use a registry
reidbaker 5bd2c6a
fatal info
reidbaker 91431ed
Fix the windows test error, respond to code review feedback
reidbaker 1601caa
Only build the rule set once rather than for every validate call
reidbaker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,12 @@ | ||
| ## 0.2.0 | ||
|
|
||
| - Refactored validator to a pluggable rule-based architecture. | ||
| - Added support for custom rules via `SkillRule`. | ||
| - Added runtime assertion for duplicate rule names. | ||
| - Added warning when a rule emits an error with severity different from its definition. | ||
| - Updated `README.md` with custom rules documentation. | ||
| - **Breaking Change**: Enabling a rule via CLI flag now sets its severity to `error` instead of `warning`. | ||
|
|
||
| ## 0.1.0 | ||
|
|
||
| - Initial version. | ||
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import 'dart:io'; | ||
| import 'package:yaml/yaml.dart'; | ||
|
|
||
| /// Context provided to [SkillRule]s during validation. | ||
| class SkillContext { | ||
| SkillContext({ | ||
| required this.directory, | ||
| required this.rawContent, | ||
| this.parsedYaml, | ||
| this.yamlParsingError, | ||
| }); | ||
|
reidbaker marked this conversation as resolved.
|
||
|
|
||
| final Directory directory; | ||
|
|
||
| /// Guaranteed to be non-null because we only run rules if SKILL.md exists. | ||
| final String rawContent; | ||
|
|
||
| final YamlMap? parsedYaml; | ||
|
|
||
| final String? yamlParsingError; | ||
| } | ||
|
reidbaker marked this conversation as resolved.
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import 'analysis_severity.dart'; | ||
| import 'skill_context.dart'; | ||
| import 'validation_error.dart'; | ||
|
|
||
| /// Abstract base class for all skill validation rules. | ||
| /// | ||
| /// Custom rules should follow these guidelines to play nice with others: | ||
| /// 1. **Unique Name**: The [name] must be unique to allow for overrides in | ||
| /// configuration. | ||
| /// 2. **Statelessness**: Rules should not maintain state between [validate] calls. | ||
| /// 3. **Use Context**: Prefer using data in [SkillContext] (like [context.parsedYaml]) | ||
| /// rather than reading files manually to avoid duplicate I/O. | ||
| /// 4. **Handle Parsing Errors**: If [context.parsedYaml] is null, check | ||
| /// [context.yamlParsingError]. Rules that require valid YAML should return | ||
| /// quickly if parsing failed. | ||
| /// 5. **Respect Severity**: The rule should use its [severity] when creating | ||
| /// [ValidationError]s unless there is a good reason not to. | ||
| abstract class SkillRule { | ||
| /// The unique name of the rule (e.g., 'check-relative-paths'). | ||
| /// Used in configuration and flags. | ||
| String get name; | ||
|
|
||
| AnalysisSeverity get severity; | ||
|
|
||
| /// Validates the skill provided in [context]. | ||
| Future<List<ValidationError>> validate(SkillContext context); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.