Skip to content

Comments

Format and lint CSS files using Stylelint#2304

Merged
siddharthvp merged 2 commits intomasterfrom
stylelint
Feb 8, 2026
Merged

Format and lint CSS files using Stylelint#2304
siddharthvp merged 2 commits intomasterfrom
stylelint

Conversation

@siddharthvp
Copy link
Member

Use stylelint with stylelint-config-wikimedia, specifically the support-modern preset which targets grade A browsers. This is in preparation for #2300 which will introduce some involved CSS.

Rule customisations used:

  • @stylistic/*-space-inside: "never", per repo code style of not putting spaces in parens
  • selector-attribute-quotes: "never".
  • selector-max-id: 1. MediaWiki uses 0 which disallows ids in CSS completely! That leads to a lot of errors for us.
  • declaration-no-important: null. Disabled temporarily. Ideally, we should remove this.

All CSS changes are no-op, mainly:

  • Changed hex codes to use lowercase letters instead of uppercase
  • Consistently used tabs
  • Consistently put opening brace on same line as the selector
  • The two blocks for .morebits-ui-tooltip in morebits.css are combined
  • prefers-color-scheme: dark isn't supported in Safari 11 which still happens to be Grade A, so we have to use per-line stylelint-disable. In practise, Safari 11 isn't much used, and per CSS spec unsupported rules and media queries are just ignored - they don't cause the stylesheet to fail.
  • stylelint-config-wikimedia disallows px units in font-size and line-height for accessibility reasons, which is probably something we should also fix. Temporarily disabled inline as fixes won't be no-op.
  • stylelint-config-wikimedia disallows border: none. It is replaced with border: 0 which has the same effect.

@github-actions github-actions bot added Module: morebits The morebits.js library dependencies Pull requests that update a dependency file, likely through dependabot Module: twinkle The twinkle.js global gadget file labels Jan 27, 2026
@NovemLinguae
Copy link
Member

Nice! Consider adding a CI job for this too

@siddharthvp
Copy link
Member Author

It's part of the linter job (since it gets run by npm run lint)

@NovemLinguae
Copy link
Member

Oh duh. "lint": "eslint . --max-warnings=0 && stylelint src/*.css",

Use stylelint with stylelint-config-wikimedia, specifically the support-modern preset which targets grade A browsers. This is in preparation for #2300 which will introduce some involved CSS.

Rule customisations used:
* @stylistic/*-space-inside: "never", per repo code style of not putting spaces in parens
* selector-attribute-quotes: "never".
* selector-max-id: 1. MediaWiki uses 0 which disallows ids in selectors completely! That would lead to a lot of errors for us.
* declaration-no-important: null. Disabled temporarily. Ideally, we should remove this.

All CSS changes are no-op (mostly done via auto-fixes,) mainly:
* Changed hex codes to use lowercase letters instead of uppercase
* Consistently used tabs
* Consistently put opening brace on same line as the selector
* Combined the two blocks for .morebits-ui-tooltip in morebits.css
* prefers-color-scheme: dark isn't supported in Safari 11 which still happens to be Grade A, so used a per-line stylelint-disable. In practise, Safari 11 isn't much used, and per CSS spec unsupported rules and media queries are just ignored - they don't cause the stylesheet to fail.
* stylelint-config-wikimedia disallows px unit in font-size and line-height for accessibility reasons, which is probably something we should also fix. Temporarily disabled inline as fixes won't be no-op.
* stylelint-config-wikimedia disallows `border: none`. Replaced it with `border: 0` which has the same effect.
Variables defined by morebits or Twinkle itself will always be available – the fallbacks are redundant. Fallbacks in var() only need to be used while using Codex design tokens, since they aren't defined in all skins.
@siddharthvp siddharthvp merged commit 3aa8601 into master Feb 8, 2026
9 checks passed
@siddharthvp siddharthvp deleted the stylelint branch February 8, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file, likely through dependabot Module: arv Module: morebits The morebits.js library Module: twinkle The twinkle.js global gadget file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants