lib/scss_lint/config.rb in scss_lint-0.40.0 vs lib/scss_lint/config.rb in scss_lint-0.40.1

- old
+ new

@@ -206,21 +206,32 @@ @warnings += config.warnings self end def load_plugins - load_plugins_and_merge_config.tap { ensure_plugins_have_default_options } + previous_linters = LinterRegistry.linters + plugins = SCSSLint::Plugins.new(self).load + new_linters = LinterRegistry.linters - previous_linters + + plugins.each do |plugin| + # Have the plugin options be overrideable by the local configuration + @options = self.class.send(:smart_merge, plugin.config.options, @options) + end + + # We only want to set defaults for linters introduced via plugins, + # otherwise we'll accidentally enable some linters + ensure_linters_have_default_options(new_linters) end def enabled_linters LinterRegistry.extract_linters_from(@options['linters'].keys).select do |linter| linter_options(linter)['enabled'] end end def linter_enabled?(linter) - linter_options(linter)['enabled'] + (linter_options(linter) || {}).fetch('enabled', false) end def enable_linter(linter) linter_options(linter)['enabled'] = true end @@ -234,11 +245,11 @@ linter_config['enabled'] = false end end def linter_options(linter) - @options['linters'][self.class.linter_name(linter)] + @options['linters'].fetch(self.class.linter_name(linter), {}) end def excluded_file?(file_path) abs_path = File.expand_path(file_path) @@ -287,18 +298,11 @@ @warnings << "Linter #{name} does not exist; ignoring" end end end - def load_plugins_and_merge_config - SCSSLint::Plugins.new(self).load.each do |plugin| - # Have the plugin options be overrideable by the local configuration - @options = self.class.send(:smart_merge, plugin.config.options, @options) - end - end - - def ensure_plugins_have_default_options - LinterRegistry.linters.each do |linter| + def ensure_linters_have_default_options(linters) + linters.each do |linter| if linter_options(linter).nil? @options['linters'].merge!(default_plugin_options(linter)) end end end