Skip to content

Commit

Permalink
fix: only use on-disk file extension for config-matching
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Jan 20, 2025
1 parent 1db9a5e commit 7edac53
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
21 changes: 1 addition & 20 deletions internal/core/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,9 @@ func NewFile(src string, config *Config) (*File, error) {
src = "stdin" + config.Flags.InExt
lookup = true
}
filepaths := []string{src}

filepaths := []string{src}
normed := system.ReplaceFileExt(src, config.Formats)
if normed != src {
// NOTE: In retrospect, this was a mistake: we should NOT normalize
// the extension with respect to the `.vale.ini` file.
//
// The `.vale.ini` file should reflect the actual file extensions (as
// they appear on disk). Unfortunately, changing this behavior entirely
// would break backwards compatibility with many configurations.
//
// So, as a workaround, we check both cases. This means that there are
// two cases:
//
// - No assigned format: No change (no normed path).
//
// - Assigned format: We can reference the file using the normed path
// (old behavior) or the actual path (desired behavior).
//
// See also `Linter.skip`.
filepaths = append(filepaths, normed)
}

baseStyles := config.GBaseStyles
checks := make(map[string]bool)
Expand Down
2 changes: 1 addition & 1 deletion testdata/fixtures/formats/subdir3/.vale.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ MinAlertLevel = suggestion
[formats]
mdx = md

[*.md]
[*.mdx]
vale.Annotations = YES
4 changes: 2 additions & 2 deletions testdata/fixtures/patterns/_vale
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ mdx = md
[*]
BasedOnStyles = Vale

[*.{md,rst,adoc,org}]
[*.{md,rst,adoc,org,mdx}]
TokenIgnores = (\$+?[^\d][^\n$]+\$+?), (<http[^\n]+>+?)
IgnorePatterns = (?s) *({{< ?file(?:-excerpt)? [^>]* ?>}}.*?{{< ?/file(?:-excerpt)? ?>}})

vale.Redundancy = warning
vale.Redundancy = warning

0 comments on commit 7edac53

Please sign in to comment.