Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't repeat global excludes in linter config #325

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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