config: anchor ignore patterns to the config file's directory - #418
Merged
Merged
Conversation
…file Anchored, bare-name, leading-slash, negated, user-global-config, subdirectory-config and --ignore-path cases, all red before the fix.
Patterns in `ignore` used to be matched as typed, so `fixtures/**` read like a .gitignore entry and matched nothing. Every pattern is now anchored to the directory of the file that named it: a pattern with a `/` is a path from there, a bare name matches at any depth below it, and a trailing `/**` excludes the named directory itself. `!` negation keeps winning over the plain patterns, anchored to the same directory. This makes the user-global config speak for its own tree and gives --ignore-path files the same rule — patterns in one are relative to that file's own directory — which supersedes the intent of #325 folded into #327's Ignore design. Fixes #25
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.
Summary
ignore = ["fixtures/**"]read like a.gitignoreentry but was matched as typed, so it named "fixtures wherever the invocation's paths happen to lead" — which in practice meant nothing was ever ignored unless the pattern was spelled**/fixtures/**(#25).Every pattern is now anchored to the directory of the file that named it, in the
Ignore{excluded, excepted}design that landed with #327:/is a path from that directory:fixtures/**is the fixtures folder besideslint.toml, however the run was invoked, and a leading/says the same thing again. A trailing/**excludes the named directory itself, the way git stops at the folder./is a name, and matches at any depth below the anchor (the.gitignoreconvention).!negation keeps winning over the plain patterns in whatever order they were written, anchored to the same directory.ignorecannot reach into the projects being linted.--ignore-pathfiles are anchored to their own directory too, soslint --ignore-path tools/my-ignoresspeaks fortools/, not for the tree above it.This supersedes the intent of #325 (which was mutually exclusive with #327 as submitted) folded into the new design. Matching runs against both the paths as walked and their resolved form, so relative, dotted, and symlinked invocations of the same run behave identically.
Fixes #25
Test plan
fixtures/**and/fixtures/**(including a dotted invocation path), bare-name at any depth, subdirectory config that must not leak above itself, user-global config anchored to its own directory,!-negation interplay with anchoring, and--ignore-pathanchored to the ignore file's directory (unit tests inpackages/core/src/skill.rsandpackages/core/src/engine.rs, end-to-end inapps/cli/tests/cli.rs)!-negation and ignore tests pass unchangedcargo test -p slint -p slint-cli, then./scripts/check.sh --no-js)