Skip to content

Commit

Permalink
feat: new StylesPath/config directory
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Dec 18, 2023
1 parent 922da39 commit 4ec4c80
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 2 deletions.
20 changes: 20 additions & 0 deletions internal/core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ import (
"github.com/errata-ai/vale/v2/internal/glob"
)

var (
// ConfigDir is the default location for Vale's configuration files.
//
// This was introduced in v3.0.0 as a means of standardizing the location
// of Vale's configuration files.
//
// This directory is relative to the user's specified `StylesPath`, which
// can be set via the `--config` flag, the `VALE_CONFIG_PATH` environment
// variable, or the default search process.
//
// NOTE: The config pipeline is stored in the top-level `.config`
// directory. See `cmd/vale/sync.go`.
ConfigDir = "config"

VocabDir = filepath.Join(ConfigDir, "vocabularies")
DictDir = filepath.Join(ConfigDir, "dictionaries")
TmplDir = filepath.Join(ConfigDir, "templates")
IgnoreDir = filepath.Join(ConfigDir, "ignorefiles")
)

// CLIFlags holds the values that are defined at runtime by the user.
//
// For example, `vale --minAlertLevel=error`.
Expand Down
5 changes: 3 additions & 2 deletions internal/core/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,16 @@ func validateLevel(key, val string, cfg *Config) bool {
func loadVocab(root string, cfg *Config) error {
target := ""
for _, p := range cfg.Paths {
opt := filepath.Join(p, "Vocab", root)
opt := filepath.Join(p, VocabDir, root)
if IsDir(opt) {
target = opt
break
}
}

if target == "" {
return NewE100("vocab", fmt.Errorf("'%s' does not exist", root))
return NewE100("vocab", fmt.Errorf(

Check failure on line 299 in internal/core/util.go

View workflow job for this annotation

GitHub Actions / lint

ST1005: error strings should not be capitalized (stylecheck)
"The '%s/%s' directory does not exist", VocabDir, root))
}

err := godirwalk.Walk(target, &godirwalk.Options{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 4ec4c80

Please sign in to comment.