fix(muya): unbreak lint:css (stylelint 17 compatibility) by Jocs · Pull Request #4388 · marktext/marktext · GitHub
Skip to content

fix(muya): unbreak lint:css (stylelint 17 compatibility) - #4388

Merged
Jocs merged 1 commit into
developfrom
fix/muya-lint-css
Jun 8, 2026
Merged

Jocs merged 1 commit into
developfrom
fix/muya-lint-css

Conversation

@Jocs

@Jocs Jocs commented Jun 8, 2026

Copy link
Copy Markdown
Member

Problem

On a clean develop checkout, pnpm -C packages/muya lint:css crashes:

TypeError: Cannot read properties of undefined (reading 'unprefixed')
    at .../packages/muya/src/assets/styles/blockSyntax.css:1:1
    at getNodeData (.../stylelint-order@2.2.1_stylelint@9.10.1/.../getNodeData.js:11:43)

This blocks CSS linting entirely (the run aborts before reaching any file), which matters ahead of the upcoming theme-CSS migration.

Root cause

packages/muya/.stylelintrc extended stylelint-config-rational-order/plugin. stylelint-config-rational-order@0.1.2 bundles its own stylelint-order@2.2.1, which targets stylelint@^9. The repo actually runs stylelint@17, whose AST shape differs, so the old properties-order rule reads an undefined node and throws — taking down the whole lint run.

Note the repo already declared the maintained stylelint-order@^8.1.1 (stylelint-17-compatible) as a devDep; it just wasn't doing the property-ordering work — the broken bundled plugin was.

Fix (chosen approach)

Replace the unmaintained plugin/rational-order with a direct, maintained stylelint-order@8 setup, preserving the exact ordering intent:

  • Removed stylelint-config-rational-order/plugin from plugins and deleted the plugin/rational-order rule.
  • Populated the native order/properties-order rule with the exact group list the old plugin generated for this repo's options (border-in-box-model: false, empty-line-between-groups: true) — same property order, same 7 groups, same empty-line-between-groups behavior.
  • Kept severity: "warning" (matching the prior config, where both order rules were warnings) and added unspecified: "bottomAlphabetical" so unlisted properties don't error.
  • Removed the now-unused stylelint-config-rational-order devDep. This prunes its old stylelint@9 / postcss@7 subtree from the lockfile (the large pnpm-lock.yaml deletion is entirely that dead subtree).

This is config-only for ordering — no CSS rule behavior changes.

One trivial pre-existing fix

With the tool finally able to run end-to-end, it surfaced one genuine pre-existing error (from stylelint-config-standard's font-family-name-quotes, unrelated to the ordering migration) in the vendored sequence-diagram.css:

-    font-family: 'danielbd';
+    font-family: danielbd;

This is exactly what stylelint --fix produces and is rendering-identical in @font-face.

Verification

All run from the repo root against packages/muya:

Command Result
lint:css completes, 0 errors (2 ordering warnings, as intended)
lint 0 errors
lint:types pass
check-circular pass
test 403 passed
test:spec 1347 passed

The 2 remaining lint:css warnings are pre-existing property-order nits (now visible because the rule actually runs); left as warnings to keep this PR about unbreaking the tool, not restyling CSS.

🤖 Generated with Claude Code

`pnpm -C packages/muya lint:css` crashed on a clean checkout with
`TypeError: Cannot read properties of undefined (reading 'unprefixed')`.

Root cause: `.stylelintrc` extended `stylelint-config-rational-order/plugin`,
whose v0.1.2 bundles its own `stylelint-order@2.2.1` built for `stylelint@^9`.
That old rule reads a v9-shaped AST node and breaks on the `stylelint@17`
AST the repo actually runs, aborting the whole lint run before it reached
any file.

Fix: drop the unmaintained `plugin/rational-order` plugin and instead drive
the same property ordering through the maintained `stylelint-order@8`
(already a devDep) via the native `order/properties-order` rule. The rule's
group list is the exact rational-order expectation the old plugin generated
for this repo's options (`border-in-box-model: false`,
`empty-line-between-groups: true`), so the ordering intent is preserved with
no change to any CSS behavior. Ordering stays `severity: warning`, matching
the prior config. Removed the now-unused
`stylelint-config-rational-order` devDep (prunes its old stylelint@9 /
postcss@7 subtree from the lockfile).

Also fixed one pre-existing genuine error the working tool finally surfaced:
`font-family: 'danielbd'` -> `font-family: danielbd` in the vendored
sequence-diagram `@font-face` (the standard `font-family-name-quotes` fix;
identical rendering).

`pnpm -C packages/muya lint:css` now completes with 0 errors. lint,
lint:types, check-circular, test, and test:spec all still pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 8, 2026 04:34

Copilot AI left a comment

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.

Pull request overview

This PR fixes packages/muya CSS linting on stylelint@17 by removing the incompatible stylelint-config-rational-order plugin (which pulled in an old stylelint-order@2 targeting stylelint@9) and replacing it with an explicit stylelint-order@8 order/properties-order configuration that preserves the intended property grouping/order. It also removes the now-unused dependency and trims the lockfile subtree that was only present to satisfy the old plugin, plus applies one stylelint --fix-equivalent correction in a vendored CSS file.

Changes:

  • Replace stylelint-config-rational-order/plugin usage with a direct stylelint-order order/properties-order group list compatible with stylelint@17.
  • Remove stylelint-config-rational-order from packages/muya devDependencies and prune its lockfile subtree.
  • Fix a font-family-name-quotes error in sequence-diagram.css (rendering-identical in @font-face).

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
packages/muya/.stylelintrc Drops the incompatible rational-order plugin and defines explicit order/properties-order groups/options for stylelint-order v8.
packages/muya/package.json Removes stylelint-config-rational-order devDependency (stylelint 9-era).
pnpm-lock.yaml Removes the unused dependency subtree pulled in by stylelint-config-rational-order.
packages/muya/src/utils/diagram/sequence/sequence-diagram.css Applies a stylelint auto-fix for font-family quoting in @font-face.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Website preview ready: https://pr-4388-marktext-website.ransixi.workers.dev

Built from 8dbb55a37087d74048ac9103df6bff4690c16017 · Worker: marktext-website · Version: d1f2a558-b89e-424b-ad40-e8c1fb43065c · Alias: pr-4388

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Build artifacts for PR #4388:

Run: https://github.com/marktext/marktext/actions/runs/27116231267

Artifact Size Link
marktext-windows-arm64 249.6 MB Download
marktext-linux 540.7 MB Download
marktext-macos-x64 249.2 MB Download
marktext-windows-x64 250.9 MB Download
marktext-macos-arm64 238.9 MB Download

@Jocs
Jocs merged commit 312182f into develop Jun 8, 2026
19 checks passed
@Jocs
Jocs deleted the fix/muya-lint-css branch June 10, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants