Skip to content

Commit

Permalink
fix: add --no-global
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Jan 7, 2024
1 parent 1f22d94 commit 57e9125
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
1 change: 1 addition & 0 deletions cmd/vale/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ func init() {
pflag.BoolVar(&Flags.Sorted, "sort", false, "sort files by their name in output")
pflag.BoolVar(&Flags.Normalize, "normalize", false, "replace each path separator with a slash ('/')")
pflag.BoolVar(&Flags.Relative, "relative", false, "return relative paths")
pflag.BoolVar(&Flags.IgnoreGlobal, "no-global", false, "ignore global configuration")
}
1 change: 1 addition & 0 deletions cmd/vale/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var hidden = []string{
"sources",
"built",
"minAlertLevel",
"no-global",

// API stuff
"tag",
Expand Down
11 changes: 8 additions & 3 deletions internal/check/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ func NewManager(config *core.Config) (*Manager, error) {
// If this rule isn't part of an already-loaded style, we load it
// individually.
fName := parts[1] + ".yml"
path = filepath.Join(mgr.Config.StylesPath, parts[0], fName)
if err = mgr.addRuleFromSource(fName, path); err != nil {
return &mgr, err
for _, p := range mgr.Config.Paths {
path = filepath.Join(p, parts[0], fName)
if !core.FileExists(path) {
continue
}
if err = mgr.addRuleFromSource(fName, path); err != nil {
return &mgr, err
}
}
}
}
Expand Down
37 changes: 19 additions & 18 deletions internal/core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,25 @@ func IgnoreFiles(stylesPath string) ([]string, error) {
//
// For example, `vale --minAlertLevel=error`.
type CLIFlags struct {
AlertLevel string
Built string
Glob string
InExt string
Output string
Path string
Sources string
Filter string
Local bool
NoExit bool
Normalize bool
Relative bool
Remote bool
Simple bool
Sorted bool
Wrap bool
Version bool
Help bool
AlertLevel string
Built string
Glob string
InExt string
Output string
Path string
Sources string
Filter string
Local bool
NoExit bool
Normalize bool
Relative bool
Remote bool
Simple bool
Sorted bool
Wrap bool
Version bool
Help bool
IgnoreGlobal bool
}

// Config holds the configuration values from both the CLI and `.vale.ini`.
Expand Down
2 changes: 1 addition & 1 deletion internal/core/ini.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func loadINI(cfg *Config, dry bool) (*ini.File, error) {
}

defaultCfg := path.Join(configDir, "vale", ".vale.ini")
if FileExists(defaultCfg) {
if FileExists(defaultCfg) && !cfg.Flags.IgnoreGlobal {
err = uCfg.Append(defaultCfg)
if err != nil {
return nil, NewE100("default/ini", err)
Expand Down
2 changes: 1 addition & 1 deletion testdata/features/steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
if OS.windows?
exe += '.exe'
end
cmd = (exe + ' --output=line --sort --normalize --relative')
cmd = (exe + ' --output=line --sort --normalize --relative --no-global')

Given(/^on Unix$/) do
pending unless OS.posix?
Expand Down

0 comments on commit 57e9125

Please sign in to comment.