This repository centralises the code style configuration files used across alienlebarge.ch projects.
.prettierrc/prettier.config.json— code formattingstylelint.config.json— CSS/SCSS rules
Both files (.prettierrc and prettier.config.json) share the same formatting rules:
| Option | Value | Description |
|---|---|---|
printWidth |
80 |
Maximum line length of 80 characters. |
tabWidth |
2 |
Indentation of 2 spaces. |
useTabs |
false |
Spaces are used instead of tabs. |
semi |
true |
Semicolons are required at the end of statements. |
singleQuote |
true |
Single quotes for strings. |
trailingComma |
"none" |
No trailing commas. |
bracketSpacing |
true |
Spaces inside object braces { foo: bar }. |
endOfLine |
"lf" |
Unix-style line endings (LF). |
htmlWhitespaceSensitivity |
"ignore" |
Whitespace in HTML is ignored during formatting. |
jsxBracketSameLine |
false |
The closing > of a JSX component is placed on a new line. |
proseWrap |
"preserve" |
Prose text (Markdown) is not reformatted. |
.prettierrcadditionally includes the@prettier/plugin-phpplugin for PHP support.
These rules aim to keep CSS specificity low and predictable.
selector-max-id: 0— ID selectors are forbidden. Use classes only.selector-max-compound-selectors: 3— A selector may not be composed of more than 3 combined selectors.selector-no-qualifying-type— Type selectors may not be qualified with a class or attribute (e.g.a.linkis forbidden;.linkis correct). Exceptions: attributes and classes are allowed.selector-max-universal: 2— The universal selector*is limited to 2 occurrences per selector.selector-max-specificity: "0,3,0"— Maximum allowed specificity is0,3,0(three classes maximum, no IDs).selector-class-pattern— Classes must follow the BEM kebab-case convention:.block,.block__element,.block--modifier.
declaration-no-important: true— The use of!importantis strictly forbidden.
declaration-block-no-duplicate-properties— Duplicate properties within a block are forbidden, unless they are consecutive with different values (useful for fallbacks).block-no-empty: true— Empty blocks are forbidden.declaration-block-no-shorthand-property-overrides: true— A shorthand property may not override a longhand property declared after it in the same block.unit-no-unknown: true— Unknown units are forbidden.property-no-unknown: true— Unknown CSS properties are forbidden.selector-pseudo-class-no-unknown: true— Unknown pseudo-classes are forbidden.selector-pseudo-element-no-unknown: true— Unknown pseudo-elements are forbidden.function-no-unknown: null— Checking for unknown CSS functions is disabled (to allow custom functions).
color-function-notation: "modern"— Modern color function notation is required:rgb(255 0 0)instead ofrgb(255, 0, 0).alpha-value-notation: "percentage"— Alpha values must be expressed as percentages:50%instead of0.5.color-no-invalid-hex: true— Invalid hex color values are forbidden.color-named: "never"— Named colors (red,blue, etc.) are forbidden.
length-zero-no-unit: true— Zero-length values must not have a unit:0instead of0px.
font-family-name-quotes: "always-where-recommended"— Quotes around font family names are required where recommended.font-family-no-duplicate-names: true— Duplicate font family names within afont-familydeclaration are forbidden.
custom-property-pattern— Custom properties must follow kebab-case naming, or the Utopia naming convention:--step-0,--step-1,--step--1… (Utopia type scale)--space-s,--space-2xl,--space-s-l… (Utopia space tokens & pairs)--grid-max-width,--grid-gutter… (Utopia grid tokens)--any-kebab-case-property(custom tokens)
no-duplicate-selectors: true— Duplicate selectors across the stylesheet are forbidden.
The stylelint-order plugin enforces a strict order for CSS properties, grouping declarations logically. Logical CSS properties (e.g. margin-inline) are always placed before their physical equivalents (e.g. margin-left). The group order is as follows:
- Positioning —
position,inset,top,right,bottom,left,z-index - Box model / Layout —
display, flex, grid,float,clear - Sizing — logical first (
inline-size,block-size), then physical (width,height),aspect-ratio - Margin — logical first (
margin-block,margin-inline), then physical - Padding — logical first (
padding-block,padding-inline), then physical - Overflow —
overflow,overscroll-behavior - Box —
box-sizing,visibility,clip,clip-path - Borders — logical first, then physical; width, style, colour, then
border-radius,outline - Typography —
font-*,line-height,text-*,letter-spacing,white-space,direction,writing-mode - Appearance / Skin —
color,background-*,box-shadow,filter,opacity,cursor,appearance - Transitions & animations —
transition-*,animation-*,will-change,transform-* - Container queries —
container,container-name,container-type - Scroll —
scroll-behavior,scroll-snap-*,scroll-margin,scroll-padding
Unlisted properties are placed at the bottom of the block (
"unspecified": "bottom").