npm.io
6.0.4 • Published 3 years ago

@types/css-declaration-sorter

Licence
MIT
Version
6.0.4
Deps
1
Size
6 kB
Vulns
0
Weekly
0
Stars
51.5K

Installation

npm install --save @types/css-declaration-sorter

Summary

This package contains type definitions for css-declaration-sorter (https://github.com/Siilwyn/css-declaration-sorter#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/css-declaration-sorter.

index.d.ts

import { PluginCreator } from "postcss";

/**
 * A Node.js module and PostCSS plugin to sort CSS, SCSS or Less declarations based on their property names.
 */
declare namespace cssDeclarationSorter {
    /**
     * Default, order in a simple alphabetical manner from a - z.
     */
    type Alphabetical = "alphabetical";

    /**
     * Order from most important, flow affecting properties, to least important properties.
     * ```
     * 1. Box
     * 2. Border
     * 3. Background
     * 4. Text
     * 5. Other
     * ```
     */
    type SMACSS = "smacss";

    /**
     * Order properties applying outside the box model, moving inward to intrinsic changes.
     * ```
     * 1. Positioning
     * 2. Visibility
     * 3. Box model
     * 4. Dimensions
     * 5. Text
     * ```
     */
    type ConcentricCSS = "concentric-css";

    type SortOrder = Alphabetical | SMACSS | ConcentricCSS;

    /**
     * This function receives two declaration names and is expected
     * to return -1, 0 or 1 depending on the wanted order.
     */
    type SortFunction = (aProp: string, bProp: string) => -1 | 0 | 1;

    interface Options {
        /**
         * Provide the name of one of the built-in sort orders or a comparison function that is passed to `Array.sort`.
         * @default 'alphabetical'
         */
        order?: SortOrder | SortFunction | undefined;
        /**
         * To prevent breaking legacy CSS where shorthand declarations override longhand declarations
         * (also taking into account vendor prefixes) this option can enabled.
         * For example `animation-name: some; animation: greeting;` will be kept in this order when `keepOverrides` is `true`.
         */
        keepOverrides?: boolean | undefined;
    }

    type CssDeclarationSorter = PluginCreator<Options>;
}

declare const cssDeclarationSorter: cssDeclarationSorter.CssDeclarationSorter;
export = cssDeclarationSorter;

Additional Details

  • Last updated: Mon, 06 Nov 2023 2205 GMT
  • Dependencies: postcss

Credits

These definitions were written by Piotr Błażejewicz.