analyze-css
Version:
CSS selectors complexity and performance analyzer
104 lines (92 loc) • 2.47 kB
TypeScript
/**
* This file defines names of metrics and events.
*/
/**
* Names of metrics. This list is generated by ./scripts/types.js file.
*/
export type MetricsNames =
| "base64Length"
| "colors"
| "comments"
| "commentsLength"
| "complexSelectors"
| "declarations"
| "duplicatedProperties"
| "duplicatedSelectors"
| "emptyRules"
| "expressions"
| "importants"
| "imports"
| "length"
| "mediaQueries"
| "multiClassesSelectors"
| "notMinified"
| "oldIEFixes"
| "oldPropertyPrefixes"
| "parsingErrors"
| "propertyResets"
| "qualifiedSelectors"
| "redundantBodySelectors"
| "redundantChildNodesSelectors"
| "rules"
| "selectorLengthAvg"
| "selectors"
| "selectorsByAttribute"
| "selectorsByClass"
| "selectorsById"
| "selectorsByPseudo"
| "selectorsByTag"
| "specificityClassAvg"
| "specificityClassTotal"
| "specificityIdAvg"
| "specificityIdTotal"
| "specificityTagAvg"
| "specificityTagTotal";
/**
* Names of events. This list is generated by ./scripts/types.js file.
*/
export type EventsNames =
| "comment" /* (comment) */
| "css" /* (css) */
| "declaration" /* (rule, property, value) */
| "error" /* (err) */
| "expression" /* (selector, expression) */
| "font-face" /* (rule) */
| "import" /* (url) */
| "media" /* (query) */
| "mediaEnd" /* (query) */
| "report" /* () */
| "rule" /* (rule) */
| "selector" /* (rule, selector, expressions) */;
/**
* Encapsulates a set of metrics
*/
export type Metrics = { [metric in MetricsNames]: number };
/**
* Encapsulates a set of offenders
*/
import { Position } from "css";
export interface Offender {
message: string;
position: Position;
}
export type Offenders = { [metric in MetricsNames]: Array<Offender> };
/**
* A CSS rule taken from "css" package
*/
import { Rule, AtRule, Declaration } from "css";
declare interface CssDeclaration extends Declaration {
comment?: string | undefined;
}
// Array<Rule | Comment | AtRule> | undefined;
export interface CSSRule extends Rule {
comment?: string | undefined;
/** The part following @import. */
import?: string | undefined;
/** Array of nodes with the types declaration and comment. */
declarations?: Array<CssDeclaration> | undefined;
/** The part following @media. */
media?: string | undefined;
/** Array of nodes with the types rule, comment and any of the at-rule types. */
rules?: Array<Rule | Comment | AtRule> | undefined;
}