@stylelint-types/stylelint-order
Version:
TypeScript definitions for stylelint-define-config
181 lines (170 loc) • 7.48 kB
TypeScript
import { RuleConfig, AtRules, StandardPropertiesMap } from 'stylelint-define-config';
type OrderOptions = RuleConfig<
OrderPrimary[],
{
/**
* Default behavior is the same as `"ignore"`: an unspecified element can appear before or after any other property.
*
* With `"top"`, unspecified elements are expected before any specified properties.
*
* With `"bottom"`, unspecified properties are expected after any specified properties.
*
* @default 'ignore'
*/
unspecified?: 'top' | 'bottom' | 'ignore'
}
>
type OrderPrimary = OrderKeyword | OrderRule | OrderAtRule
type OrderKeyword = 'custom-properties' | 'dollar-variables' | 'at-variables' | 'declarations' | 'rules' | 'at-rules' | 'less-mixins'
interface OrderRule {
type: 'rule'
selector?: string | RegExp
name?: string
}
interface OrderAtRule {
type: 'at-rule'
name?: AtRules
parameter?: string | RegExp
hasBlock?: boolean
}
type PropertiesAlphabeticalOrderOptions = RuleConfig<true>
type PropertiesOrderOptions = RuleConfig<
(StandardPropertiesMap | PropertiesGroup)[],
{
/**
* These options only apply if you've defined your own array of properties.
*
* Default behavior is the same as `"ignore"`: an unspecified property can appear before or after any other property.
*
* @default 'ignore'
*/
unspecified?: 'top' | 'bottom' | 'bottomAlphabetical' | 'ignore'
/**
* Default behavior does not enforce the presence of an empty line before an unspecified block of properties (`"ignore"`).
*
* If `"always"`, the unspecified group must be separated from other properties by an empty newline.
*
* If `"never"`, the unspecified group must have no empty lines separating it from other properties.
*
* For `"threshold"`, see the `emptyLineMinimumPropertyThreshold` for more information.
*
* If `emptyLineBeforeUnspecified` specified, regardless of it's value, if the first property in a rule is target of this option, that property would be forced to not have an empty line before it.
*/
emptyLineBeforeUnspecified?: 'always' | 'never' | 'threshold'
/**
* If a group is configured with `emptyLineBefore: "threshold"`, the empty line behaviour toggles based on the number of properties in the rule.
*
* When the configured minimum property threshold is reached, empty lines are inserted. When the number of properties is less than the minimum property threshold, empty lines are __removed__.
*/
emptyLineMinimumPropertyThreshold?: number
}
>
interface PropertiesGroup {
/**
* The properties in this group.
*/
properties: StandardPropertiesMap[]
/**
* If `"always"`, this group must be separated from other properties by an empty newline. If emptyLineBefore is never, the group must have no empty lines separating it from other properties. By default this property isn't set.
*
* Rule will check empty lines between properties _only_. However, shared-line comments ignored by rule. Shared-line comment is a comment on the same line as declaration before this comment.
*
* If `emptyLineBefore` specified, regardless of it's value, the first property in a rule would be forced to not have an empty line before it.
*
* For `threshold`, refer to the [`emptyLineMinimumPropertyThreshold` documentation](#emptyLineMinimumPropertyThreshold).
*
* If this option is not working as expected, make sure you don't have `declaration-empty-line-before` configured in a conflicting way in your Stylelint config or config you're extending (e. g. [`stylelint-config-standard`](https://github.com/stylelint/stylelint-config-standard)).
*
*/
emptyLineBefore?: 'always' | 'never' | 'threshold'
/**
* If `true`, properties within group should not have empty lines between them.
*/
noEmptyLineBetween?: boolean
/**
* An optional name for the group. This will be used in error messages.
*/
groupName?: string
/**
* If property isn't set (the default), the properties in this group must come in the order specified. If `"flexible"`, the properties can be in any order as long as they are grouped correctly.
*/
order?: 'flexible'
}
interface Plugins {
'stylelint-order': void;
}
interface Extends {
'stylelint-config-idiomatic-order': void;
'stylelint-config-hudochenkov/order': void;
'stylelint-config-recess-order': void;
'stylelint-config-property-sort-order-smacss': void;
'stylelint-config-clean-order': void;
}
interface RuleOptions {
/**
* Specify the order of content within declaration blocks.
*
* Within an order array, you can include:
* - keywords:
* - `custom-properties` — Custom properties (e. g., `--property: 10px;`)
* - `dollar-variables` — Dollar variables (e. g., `$variable`)
* - `at-variables` — At-variables (e. g., `@variable` available in Less syntax)
* - `declarations` — CSS declarations (e. g., `display: block`)
* - `rules` — Nested rules (e. g., `a { span {} }`)
* - `at-rules` — Nested at-rules (e. g., `div { \@media () {} }`)
* - `less-mixins` — Mixins in Less syntax (e. g., `.mixin();`)
* - extended at-rule objects:
* ```json
* {
* "type": "at-rule",
* "name": "include",
* "parameter": "hello",
* "hasBlock": true
* }
* ```
* - extended rule objects:
* ```json
* {
* "type": "rule",
* "selector": "div",
* "name": "tag selector"
* }
* ```
*
* **By default, unlisted elements will be ignored.** So if you specify an array and do not include `declarations`, that means that all declarations can be included before or after any other element. _This can be changed with the `unspecified` option (see below)._
*
* @see [order](https://github.com/hudochenkov/stylelint-order/blob/master/rules/order/README.md)
*/
'order/order': OrderOptions;
/**
* Specify the alphabetical order of properties within declaration blocks.
*
* Shorthand properties *must always* precede their longhand counterparts, even if that means they are not alphabetized.
* (See also [`declaration-block-no-shorthand-property-overrides`](https://stylelint.io/user-guide/rules/declaration-block-no-shorthand-property-overrides/).)
*
* Prefixed properties *must always* precede the unprefixed version.
*
* This rule ignores variables (`$sass`, `@less`, `--custom-property`).
*
* @see [properties-alphabetical-order](https://github.com/hudochenkov/stylelint-order/blob/master/rules/properties-alphabetical-order/README.md)
*/
'order/properties-alphabetical-order': PropertiesAlphabeticalOrderOptions;
/**
* Specify the order of properties within declaration blocks.
*
* Prefixed properties *must always* precede the unprefixed version.
*
* This rule ignores variables (`$sass`, `@less`, `--custom-property`).
*
* @see [properties-order](https://github.com/hudochenkov/stylelint-order/blob/master/rules/properties-order/README.md)
*/
'order/properties-order': PropertiesOrderOptions;
}
declare module 'stylelint-define-config' {
interface CustomPlugins extends Plugins {
}
interface CustomExtends extends Extends {
}
interface CustomRuleOptions extends RuleOptions {
}
}