github.com/yoheimuta/protolint@v0.49.8-0.20240515023657-4ecaebb7575d/internal/linter/config/externalConfig.go (about)

     1  package config
     2  
     3  // Lint represents the lint configuration.
     4  type Lint struct {
     5  	Ignores     Ignores
     6  	Files       Files
     7  	Directories Directories
     8  	Rules       Rules
     9  	RulesOption RulesOption `yaml:"rules_option" json:"rules_option" toml:"rules_option"`
    10  }
    11  
    12  // ExternalConfig represents the external configuration.
    13  type ExternalConfig struct {
    14  	SourcePath string
    15  	Lint       Lint
    16  }
    17  
    18  // ShouldSkipRule checks whether to skip applying the rule to the file.
    19  func (c ExternalConfig) ShouldSkipRule(
    20  	ruleID string,
    21  	displayPath string,
    22  	defaultRuleIDs []string,
    23  ) bool {
    24  	lint := c.Lint
    25  	return lint.Ignores.shouldSkipRule(ruleID, displayPath) ||
    26  		lint.Files.shouldSkipRule(displayPath) ||
    27  		lint.Directories.shouldSkipRule(displayPath) ||
    28  		lint.Rules.shouldSkipRule(ruleID, defaultRuleIDs)
    29  }