Skip to content

Commit

Permalink
Don't repeat global excludes in linter config (#325)
Browse files Browse the repository at this point in the history
This caused the config to keep growing which affected the file caching fingerprinting which relies on the config hash.
  • Loading branch information
ianfleeton committed Aug 25, 2023
1 parent 38a143d commit 5d18947
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/erb_lint/runner_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def linters_config
def config_hash_for_linter(klass_name)
config_hash = linters_config[klass_name] || {}
config_hash["exclude"] ||= []
config_hash["exclude"].concat(global_exclude) if config_hash["exclude"].is_a?(Array)
config_hash["exclude"].concat(global_exclude).uniq! if config_hash["exclude"].is_a?(Array)
config_hash
end

Expand Down
18 changes: 15 additions & 3 deletions spec/erb_lint/runner_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,28 @@ class MySchema < ERBLint::LinterConfig
let(:config_hash) do
{
linters: {
"MyCustomLinter" => { exclude: ["foo/bar.rb"] },
"MyCustomLinter" => { exclude: linter_excludes },
},
exclude: [
"**/node_modules/**",
],
}
end

it "excluded files are merged" do
expect(subject.exclude).to(eq(["foo/bar.rb", "**/node_modules/**"]))
context "when linter excludes do not contain global excludes" do
let(:linter_excludes) { ["foo/bar.rb"] }

it "excluded files are merged" do
expect(subject.exclude).to(eq(["foo/bar.rb", "**/node_modules/**"]))
end
end

context "when linter excludes already contain global excludes" do
let(:linter_excludes) { ["foo/bar.rb", "**/node_modules/**"] }

it "does not duplicate the global excluded files" do
expect(subject.exclude).to(eq(["foo/bar.rb", "**/node_modules/**"]))
end
end
end
end
Expand Down

0 comments on commit 5d18947

Please sign in to comment.