Skip to content

Commit

Permalink
Reword deprecation message and add test to check that it warns
Browse files Browse the repository at this point in the history
  • Loading branch information
george-ma committed Sep 6, 2024
1 parent 69cb011 commit 024cf7e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/erb_lint/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ def load_config
config = RunnerConfig.new(file_loader.yaml(config_filename), file_loader)
@config = RunnerConfig.default_for(config)
elsif File.exist?(DEPRECATED_CONFIG_FILENAME)
warn(Rainbow("#{DEPRECATED_CONFIG_FILENAME} is deprecated. Rename your config to `erb_lint.yml`.").yellow)
deprecation_message = "The config file has been renamed to `#{DEFAULT_CONFIG_FILENAME}` and " \
"`#{DEPRECATED_CONFIG_FILENAME}` is deprecated. " \
"Please rename your config file to `#{DEFAULT_CONFIG_FILENAME}`."
warn(Rainbow(deprecation_message).yellow)
config = RunnerConfig.new(file_loader.yaml(DEPRECATED_CONFIG_FILENAME), file_loader)
@config = RunnerConfig.default_for(config)
else
Expand Down
16 changes: 16 additions & 0 deletions spec/erb_lint/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ def run(processed_source)
end
end

context "with deprecated config file" do
let(:deprecated_config_filename) { ".erb-lint.yml" }
let(:config_file_content) { "---\nEnableDefaultLinters: true\n" }

before do
FileUtils.mkdir_p(File.dirname(deprecated_config_filename))
File.write(deprecated_config_filename, config_file_content)
end

it "shows a warning but loads the deprecated config file" do
expect { subject }.to(output(/`#{Regexp.escape(deprecated_config_filename)}` is deprecated/).to_stderr)
config = cli.instance_variable_get(:@config)
expect(config).to(be_an_instance_of(ERBLint::RunnerConfig))
end
end

context "with --disable-inline-configs" do
module ERBLint
module Linters
Expand Down

0 comments on commit 024cf7e

Please sign in to comment.