fix(rules): named dep-dir globs match, inline-paths error names the form, gitignore newline guard, no | in globs
This commit is contained in:
1 parent
7b878b5dc3
commit
89334f2901
4 files changed
+27
-7
No files matched your search
+11
-3
@@ -12,8 +12,11 @@
|
||||
# emit <skeleton> <out> the rule with the matching globs only (rc 1
|
||||
# when none matches, nothing written)
|
||||
# Globs match the WORKING TREE (compgen -G with globstar and dotglob,
|
||||
# through symlinks, no brace expansion: one glob per extension),
|
||||
# dependency dirs excluded: the engine matches the path the model reads,
|
||||
# through symlinks, no brace expansion: one glob per extension;
|
||||
# dotglob makes `*` match dotfiles, which the engine's matcher skips: a
|
||||
# glob that only hits hidden paths passes here but never loads),
|
||||
# dependency dirs excluded (unless the glob names one: `vendor/**` is a
|
||||
# valid rule): the engine matches the path the model reads,
|
||||
# tracked or not; a typo matches nothing either way. A frontmatter line
|
||||
# `# static-check: skip` exempts a rule whose files only exist mid-run. A
|
||||
# rule without frontmatter or without `paths:` is an always-on rule:
|
||||
@@ -42,6 +45,10 @@ _rules_globs() {
|
||||
}
|
||||
|
||||
_rules_hits() { # <glob> → matching paths outside dependency dirs, rc 1 none
|
||||
case "$1" in # a glob that names a dependency dir is not filtered
|
||||
node_modules/*|.venv/*|venv/*|vendor/*|target/*|dist/*|build/*|.git/*)
|
||||
( shopt -s globstar dotglob; compgen -G "$1" ) 2>/dev/null; return ;;
|
||||
esac
|
||||
( shopt -s globstar dotglob; compgen -G "$1" ) 2>/dev/null \
|
||||
| grep -Ev "$_RULES_DEPS"
|
||||
}
|
||||
@@ -62,7 +69,8 @@ _rules_check_file() { # <rule.md> → rc 0 ok or always-on, rc 1 with culprits
|
||||
globs=$(_rules_globs "$fm")
|
||||
case $? in
|
||||
1) echo "$1: always-on (no paths:)"; return 0 ;;
|
||||
2) echo "$1: paths: is not a JSON array of strings"; return 1 ;;
|
||||
2) echo "$1: paths: must be one line:" \
|
||||
"paths: [\"a\", \"b\"]"; return 1 ;;
|
||||
esac
|
||||
printf '%s\n' "$fm" | grep -qx '# static-check: skip' && skip=1
|
||||
while IFS= read -r g; do
|
||||
|
||||
@@ -47,7 +47,7 @@ printf -- '---\npaths: src/**\n---\n\n# Malformed\n' > .claude/rules/nofm.md
|
||||
out=$(bash "$PR" check); rc=$?
|
||||
check T3f-malformed-paths-fails "$rc" 2
|
||||
check T3g-named \
|
||||
"$(printf '%s\n' "$out" | grep -c 'nofm.md: paths: is not a JSON array of strings')" 1
|
||||
"$(printf '%s\n' "$out" | grep -c 'nofm.md: paths: must be one line')" 1
|
||||
rm .claude/rules/nofm.md
|
||||
|
||||
# T4 the skip marker passes an unmatched glob, and only in its own file
|
||||
@@ -88,6 +88,11 @@ bash "$PR" matches 'many/**' >/dev/null; check T5k-many-hits-rc "$?" 0
|
||||
check T5l-three-lines "$(bash "$PR" matches 'many/**' | wc -l | tr -d ' ')" 3
|
||||
bash "$PR" matches 'src/**/*.{ts,tz}' >/dev/null 2>&1
|
||||
check T5m-brace-glob-no-match "$?" 1
|
||||
# T5n a glob that names a dependency dir is a match (vendored area rule)
|
||||
mkdir -p vendor/lib && echo v > vendor/lib/a.js
|
||||
bash "$PR" matches 'vendor/**' >/dev/null; check T5n-named-dep-dir-rc "$?" 0
|
||||
bash "$PR" matches '**/a.js' >/dev/null 2>&1
|
||||
check T5o-unnamed-dep-dir-still-filtered "$?" 1
|
||||
|
||||
# T6 sections lists headings with sizes, fence-aware
|
||||
cat > CLAUDE.md <<'EOF'
|
||||
|
||||
Reference in new issue
Block a user