Skip to content

Commit

Permalink
Always convert CSS classes to system arguments in linters (primer#2445)
Browse files Browse the repository at this point in the history
  • Loading branch information
camertron authored Dec 13, 2023
1 parent 87e03ea commit da60c73
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-shrimps-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': minor
---

Always convert CSS classes to system arguments in linters
3 changes: 0 additions & 3 deletions lib/primer/classify/utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ def mappings(key)

# Extract hash from classes ie. "mr-1 mb-2 foo" => { mr: 1, mb: 2, classes: "foo" }
def classes_to_hash(classes)
# This method is too slow to run in production
return { classes: classes } unless validate_class_names?

obj = {}
classes = classes.split
# Loop through all classes supplied and reject ones we find a match for
Expand Down
6 changes: 0 additions & 6 deletions test/lib/classify/utilities_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,4 @@ def test_hash_to_args
assert_equal('mr: [1, 2], classes: "baz bin"', Primer::Classify::Utilities.hash_to_args({ mr: [1, 2], classes: "baz bin" }))
assert_equal('mr: [1, nil, 2], classes: "foo bar"', Primer::Classify::Utilities.hash_to_args({ mr: [1, nil, 2], classes: "foo bar" }))
end

def test_classes_to_hash_returns_classes_when_run_with_validation_disabled
with_validate_class_names(false) do
assert_equal({ classes: "mr-1 mr-md-2 foo bar" }, Primer::Classify::Utilities.classes_to_hash("mr-1 mr-md-2 foo bar"))
end
end
end

0 comments on commit da60c73

Please sign in to comment.