Skip to content

[BOOKINGSG-9317][GZ] include linaria css in stylelint#1157

Draft
ghazwan-gt wants to merge 18 commits into
pre-release/v4from
BOOKINGSG-9317/styelint-linaria
Draft

[BOOKINGSG-9317][GZ] include linaria css in stylelint#1157
ghazwan-gt wants to merge 18 commits into
pre-release/v4from
BOOKINGSG-9317/styelint-linaria

Conversation

@ghazwan-gt
Copy link
Copy Markdown

@ghazwan-gt ghazwan-gt commented May 6, 2026

Summary

  • Migrated Stylelint config from JSON to JS config and added Linaria PostCSS custom syntax with Linaria-related rule adjustments.
  • Expanded Stylelint execution scope to include *.styles.ts files across NPM scripts and lint-staged.
  • Updated VS Code Stylelint settings so IDE linting uses the new config.
  • Introduced new local ESLint rule to prevent negative interpolation usage.

Comment thread eslint-local-rules/import-path-preferences.mjs Outdated
Comment thread stylelint.config.mjs
Comment thread stylelint.config.mjs
],
"no-invalid-double-slash-comments": true,

// Ignore Linaria placeholder values like pcss-lin0 and -pcss-lin1.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how this works. where are these placeholder values introduced?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is part of @linaria/postcss-linaria where they turn expression into those placeholders during parsing. Will take a look at the flow of having this custom sytax with stylelint

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay after taking a look of how stylelint works and the linaria postcss custom syntax, basically this is how it works

  1. File matching phase where we're looking for which files match the one where we want the syntax to be applied
  2. Parse phase where stylelint loads the linaria's syntax and parse it into a postcss AST. And during this phase, linaria replaced all string interpolation into those placeholders
  3. Validation phase where stylelint checks all the rules applied
  4. Fix/Stringify phase where all the fix takes place (with --fix) and serialize the output back using the linaria's syntax stringify behavior, which replacing those placeholders back

Comment thread stylelint.config.mjs
overrides: [
{
/*
Taken from linaria's stylelint-config-standard-linaria package,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be the same, but using the one from npm keeps throwing error even when the resulted config is the same

@ghazwan-gt ghazwan-gt marked this pull request as ready for review May 7, 2026 07:29
Copy link
Copy Markdown

@ziggyzet ziggyzet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some attributes went missing, will check the rest as well

Comment thread src/accordion/accordion-item.styles.ts Outdated
export const iconContainer = css`
transform: rotate(180deg);
transition: transform ${Motion["duration-250"]}${Motion["ease-default"]};
transition: transform ${Motion["duration-250"]};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhh why was this part deleted here? is this intentional?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one already resolved through 142cdd8

Comment thread src/alert/alert.styles.ts

max-height: var(${tokens.maxCollapsedHeight});
overflow: hidden;
-webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is removed as well

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also resolved through 142cdd8

Comment thread src/badge/badge.styles.ts
var(${tokens.wrapper.offsetX}, 0px),
var(${tokens.wrapper.offsetY}, 0px)
);
transform: translate(50%, -25%) translate(var(${tokens.wrapper.offsetX}), var(${tokens.wrapper.offsetY}));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change to suggest us to reinitialize the variables instead of using fallbacks?

export const labelText = css`
${Font["heading-sm-semibold"]}
color: ${Colour["text"]};
word-wrap: break-word;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

word-wrap is gone here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have overflow-wrap: anywhere just below it which means the word-wrap is not being applied at all

@qroll qroll added the type: chore For technical improvements or refactoring. label May 7, 2026
Comment thread package.json Outdated
Comment on lines +39 to +40
"lint:css": "stylelint --config stylelint.config.mjs '**/*.css' '**/*.styles.ts'",
"lint:css:fix": "stylelint --config stylelint.config.mjs '**/*.css' '**/*.styles.ts' --fix",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to specify --config explicitly and in the vscode settings? I assumed stylelint would pick up this filename by default

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With cjs it needs the flag, but let me try with mjs

Comment thread .prettierrc
Comment on lines +10 to +13
"files": "**/*.styles.ts",
"options": {
"printWidth": 120
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to help us preventing the linaria's postcss which wrongly process interpolation when it is on multiple lines

@ghazwan-gt ghazwan-gt force-pushed the BOOKINGSG-9317/styelint-linaria branch from f0265d0 to 820c14b Compare May 8, 2026 02:22
@ghazwan-gt ghazwan-gt marked this pull request as draft May 8, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: chore For technical improvements or refactoring.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants