All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rules.scsslint.PropertySortOrder.html Maven / Gradle / Ivy

Details

Sort properties in a strict order. By default, will require properties be sorted in alphabetical order, as it's brain dead simple (highlight lines and execute :sort in vim), and it can benefit gzip compression.

You can also specify an explicit ordering via the order option, which allows you to specify an explicit array of properties representing the preferred order, or the name of a preset order. If a property is not in your explicit list, it will be placed at the bottom of the list, disregarding its order relative to other unspecified properties.

For example, to define a custom sort order, you can write:

linters:
PropertySortOrder:
order:
- display
- margin
- etc...

Or you can use a preset order by writing:

linters:
PropertySortOrder:
order: concentric

You can enforce that "groups" of properties be visually separated by setting the separate_groups option to true. When specifying a custom order, you can indicate that you want two groups of properties to be visually separate by inserting an empty item, e.g.

linters:
PropertySortOrder:
order:
- display
- position
- # This empty element signals a visual separation
- margin
- padding
separate_groups: true

This would result in the following separation being enforced:

p {
display: block;
position: absolute;

margin: 0;
padding: 0;
}

Note that separate_groups is only enforced if a custom order is specified via the order option. Also note that if ignore_unspecified is true then properties which are "ignored" are considered as visual separators.

If you need to write vendor-prefixed properties, the linter will allow you to order the vendor-prefixed properties before the standard CSS property they apply to. For example:

border: 0;
-moz-border-radius: 3px;
-o-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
color: #ccc;
margin: 5px;

In this case, this is usually avoided by using mixins from a framework like Compass or Bourbon so vendor-specific properties rarely need to be explicitly written by hand.

If you are specifying an explicit order for properties, note that vendor-prefixed properties will still be ordered based on the example above (i.e. you only need to specify normal properties in your list).

Configuration Option Description
ignore_unspecified Whether to ignore properties that are not explicitly specified in order (default false)
min_properties Minimum number of sortable properties (i.e. properties which are defined by the given order) present in the rule set before linting takes place (default 2)
order Array of properties, or the name of a preset order (default is nil, resulting in alphabetical ordering)
separate_groups Whether gaps between groups of properties should be enforced.




© 2015 - 2024 Weber Informatics LLC | Privacy Policy