Class: RuboCop::Cop::Tailwindcss::ClassOrder
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Tailwindcss::ClassOrder
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/tailwindcss/class_order.rb
Overview
Keeps Tailwind CSS classes in the official sort order - the same order
prettier-plugin-tailwindcss produces - wherever Ruby carries them:
class: / classes: string keywords (Phlex components, tag helpers)
and the string literals inside class-merging functions like cn and
cva.
Constant Summary collapse
- MSG =
"Sort Tailwind CSS classes in the official order"
Instance Method Summary collapse
Instance Method Details
#on_pair(node) ⇒ Object
25 26 27 28 29 |
# File 'lib/rubocop/cop/tailwindcss/class_order.rb', line 25 def on_pair(node) if target_attribute?(node) && sortable?(node.value) check node.value end end |
#on_send(node) ⇒ Object
31 32 33 34 35 |
# File 'lib/rubocop/cop/tailwindcss/class_order.rb', line 31 def on_send(node) if class_function?(node) node.arguments.each { |argument| sort_within argument } end end |