Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ func (c *runCommand) persistentPostRunE(_ *cobra.Command, _ []string) error {
}

func (c *runCommand) preRunE(_ *cobra.Command, args []string) error {
if c.cfg.GetConfigDir() != "" && c.cfg.Version != "2" {
return fmt.Errorf("invalid version of the configuration: %q", c.cfg.Version)
}

dbManager, err := lintersdb.NewManager(c.log.Child(logutils.DebugKeyLintersDB), c.cfg,
lintersdb.NewLinterBuilder(), lintersdb.NewPluginModuleBuilder(c.log), lintersdb.NewPluginGoBuilder(c.log))
if err != nil {
Expand Down
13 changes: 13 additions & 0 deletions pkg/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ func (l *Loader) Load(opts LoadOptions) error {
l.cfg.Linters.Exclusions.Generated = GeneratedModeStrict
}

err = l.checkConfigurationVersion()
if err != nil {
return err
}

if !l.cfg.InternalCmdTest {
for _, n := range slices.Concat(l.cfg.Linters.Enable, l.cfg.Linters.Disable) {
if n == "typecheck" {
Expand Down Expand Up @@ -127,6 +132,14 @@ func (l *Loader) appendStringSlice(name string, current *[]string) {
}
}

func (l *Loader) checkConfigurationVersion() error {
if l.cfg.GetConfigDir() != "" && l.cfg.Version != "2" {
return fmt.Errorf("unsupported version of the configuration: %q (require configuration v2)", l.cfg.Version)
}

return nil
}

func (l *Loader) handleGoVersion() {
if l.cfg.Run.Go == "" {
l.cfg.Run.Go = detectGoVersion(context.Background())
Expand Down
Loading