0.0.2
This commit is contained in:
parent
4d2186b8a8
commit
bdb9b28f64
4 changed files with 69 additions and 46 deletions
69
index.ts
69
index.ts
|
|
@ -2,13 +2,16 @@ import Stylelint from "stylelint";
|
|||
// @ts-expect-error -- La dépendance ne dispose pas de types.
|
||||
import { propertyGroups } from "stylelint-config-clean-order";
|
||||
|
||||
// Cérémonie nécessaire au vue de l'absence de types de stylelint-config-clean-order.
|
||||
type GroupesPropriétés = ReadonlyArray<ReadonlyArray<string>>;
|
||||
|
||||
type OrdrePropriétés = Readonly<{
|
||||
emptyLineBefore: string;
|
||||
noEmptyLineBetween: boolean;
|
||||
properties: ReadonlyArray<string>;
|
||||
}>;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Impossible de connaître à l'avance la forme d'une Règle.
|
||||
type Règles = Record<string, Stylelint.ConfigRuleSettings<any, object>>;
|
||||
const ordrePropriétés: ReadonlyArray<OrdrePropriétés> = (propertyGroups as GroupesPropriétés).map(
|
||||
(propriétés: ReadonlyArray<string>): OrdrePropriétés => ({
|
||||
emptyLineBefore: "never",
|
||||
|
|
@ -17,13 +20,42 @@ const ordrePropriétés: ReadonlyArray<OrdrePropriétés> = (propertyGroups as G
|
|||
}),
|
||||
);
|
||||
|
||||
/** Règles liées à l'usage de propriétés de couleur. */
|
||||
const règlesCouleur: Règles = {
|
||||
/**
|
||||
* Force l'utilisation de notations avec canal alpha pour les couleurs.
|
||||
*
|
||||
* @link [color-function-alias-notation](https://stylelint.io/user-guide/rules/color-function-alias-notation)
|
||||
*/
|
||||
"color-function-alias-notation": "with-alpha",
|
||||
/**
|
||||
* Force l'utilisation de notations modernes pour les couleurs.
|
||||
*
|
||||
* @link [color-function-notation](https://stylelint.io/user-guide/rules/color-@function-notation)
|
||||
*/
|
||||
"color-function-notation": "modern",
|
||||
/**
|
||||
* Interdit l'usage de notations hexadécimales pour les couleurs.
|
||||
*
|
||||
* @link [color-no-hex](https://stylelint.io/user-guide/rules/color-no-hex)
|
||||
*/
|
||||
"color-no-hex": true,
|
||||
/**
|
||||
* Émet une erreur si une couleur dépasse l'espace de couleurs sRGB sans être enveloppée dans une requête média pour
|
||||
* le support de l'espace de couleur P3.
|
||||
*
|
||||
* @link [color-no-out-gamut-range](https://github.com/fpetrakov/stylelint-gamut/blob/HEAD/src/README.md)
|
||||
*/
|
||||
"gamut/color-no-out-gamut-range": true,
|
||||
};
|
||||
|
||||
export const configCss: Readonly<Stylelint.Config> = {
|
||||
allowEmptyInput: false,
|
||||
cache: true,
|
||||
extends: ["stylelint-config-clean-order", "stylelint-config-standard"],
|
||||
extends: ["stylelint-config-clean-order", "stylelint-config-standard", "stylelint-config-html"],
|
||||
ignoreFiles: ["node_modules/**", "dist/**", "**/reset.css", "**/*.min.css"],
|
||||
plugins: [
|
||||
"stylelint-declaration-block-no-ignored-properties",
|
||||
/** @link [stylelint-gamut](https://github.com/fpetrakov/stylelint-gamut) */
|
||||
"stylelint-gamut",
|
||||
"stylelint-no-unresolved-module",
|
||||
"stylelint-no-unsupported-browser-features",
|
||||
|
|
@ -35,36 +67,19 @@ export const configCss: Readonly<Stylelint.Config> = {
|
|||
reportNeedlessDisables: true,
|
||||
reportUnscopedDisables: true,
|
||||
rules: {
|
||||
...règlesCouleur,
|
||||
/**
|
||||
* Force l'utilisation de notations avec canal alpha pour les couleurs.
|
||||
* Impose un motif pour le nom des propriétés personnalisées. Ici **désactivé** pour permettre l'usage d'accents.
|
||||
*
|
||||
* @link [color-function-alias-notation](https://stylelint.io/user-guide/rules/color-function-alias-notation)
|
||||
* @link [custom-property-pattern](https://stylelint.io/user-guide/rules/custom-property-pattern).
|
||||
*/
|
||||
"color-function-alias-notation": "with-alpha",
|
||||
/**
|
||||
* Force l'utilisation de notations modernes pour les couleurs.
|
||||
*
|
||||
* @link [color-function-notation](https://stylelint.io/user-guide/rules/color-function-notation)
|
||||
*/
|
||||
"color-function-notation": "modern",
|
||||
/**
|
||||
* Interdit l'usage de notations hexadécimales pour les couleurs.
|
||||
*
|
||||
* @link [color-no-hex](https://stylelint.io/user-guide/rules/color-no-hex)
|
||||
*/
|
||||
"color-no-hex": true,
|
||||
"custom-property-pattern": null,
|
||||
"declaration-block-no-duplicate-custom-properties": true,
|
||||
"declaration-block-no-duplicate-properties": true,
|
||||
"declaration-block-no-redundant-longhand-properties": true,
|
||||
"declaration-block-no-shorthand-property-overrides": true,
|
||||
"font-weight-notation": "numeric",
|
||||
"function-disallowed-list": ["rgba", "hsla", "rgb", "hsl"],
|
||||
"gamut/color-no-out-gamut-range": true,
|
||||
"max-nesting-depth": null,
|
||||
"no-descending-specificity": null,
|
||||
"no-duplicate-selectors": [true, { disallowInList: false }],
|
||||
"order/properties-order": [ordrePropriétés, { severity: "error", unspecified: "bottomAlphabetical" }],
|
||||
"plugin/declaration-block-no-ignored-properties": true,
|
||||
"plugin/no-unresolved-module": true,
|
||||
"plugin/no-unsupported-browser-features": [
|
||||
true,
|
||||
|
|
@ -83,10 +98,6 @@ export const configCss: Readonly<Stylelint.Config> = {
|
|||
],
|
||||
"plugin/use-logical-properties-and-values": [true, { severity: "warning" }],
|
||||
"plugin/use-logical-units": [true, { severity: "warning" }],
|
||||
"selector-class-pattern": null,
|
||||
"selector-id-pattern": null,
|
||||
"selector-max-compound-selectors": null,
|
||||
"selector-max-id": null,
|
||||
"selector-no-qualifying-type": null,
|
||||
"unit-no-unknown": true,
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue