Skip to content

Commit 7edac53

Browse files
committed
fix: only use on-disk file extension for config-matching
1 parent 1db9a5e commit 7edac53

File tree

3 files changed

+4
-23
lines changed

3 files changed

+4
-23
lines changed

internal/core/file.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,9 @@ func NewFile(src string, config *Config) (*File, error) {
6767
src = "stdin" + config.Flags.InExt
6868
lookup = true
6969
}
70-
filepaths := []string{src}
7170

71+
filepaths := []string{src}
7272
normed := system.ReplaceFileExt(src, config.Formats)
73-
if normed != src {
74-
// NOTE: In retrospect, this was a mistake: we should NOT normalize
75-
// the extension with respect to the `.vale.ini` file.
76-
//
77-
// The `.vale.ini` file should reflect the actual file extensions (as
78-
// they appear on disk). Unfortunately, changing this behavior entirely
79-
// would break backwards compatibility with many configurations.
80-
//
81-
// So, as a workaround, we check both cases. This means that there are
82-
// two cases:
83-
//
84-
// - No assigned format: No change (no normed path).
85-
//
86-
// - Assigned format: We can reference the file using the normed path
87-
// (old behavior) or the actual path (desired behavior).
88-
//
89-
// See also `Linter.skip`.
90-
filepaths = append(filepaths, normed)
91-
}
9273

9374
baseStyles := config.GBaseStyles
9475
checks := make(map[string]bool)

testdata/fixtures/formats/subdir3/.vale.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ MinAlertLevel = suggestion
44
[formats]
55
mdx = md
66

7-
[*.md]
7+
[*.mdx]
88
vale.Annotations = YES

testdata/fixtures/patterns/_vale

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ mdx = md
1010
[*]
1111
BasedOnStyles = Vale
1212

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

17-
vale.Redundancy = warning
17+
vale.Redundancy = warning

0 commit comments

Comments
 (0)