Skip to content

feat(markuplint)!: upgrade markuplint to v5.0.0-rc.7 - #944

Open
YusukeHirao wants to merge 1 commit into
devfrom
worktree-sleepy-inventing-puppy
Open

feat(markuplint)!: upgrade markuplint to v5.0.0-rc.7#944
YusukeHirao wants to merge 1 commit into
devfrom
worktree-sleepy-inventing-puppy

Conversation

@YusukeHirao

Copy link
Copy Markdown
Member

概要

markuplint/@markuplint/pug-parser を v4.18.3 から v5.0.0-rc.7 へアップグレードする。

PR #841(v5.0.0-alpha.3ベース)は base の dev が既に大きく進んでおり(4.14.0→4.18.3)、rc.7 でのルール名変更にも対応していないため、破棄して現在の dev から作り直した。

参考: markuplint v4→v5 migration guide

BREAKING CHANGE

  • markuplint v5 は Node.js >=24 を要求する(engines.node を更新)
  • v4 の一部ルール名が v5 で変更されている。設定を新しいルール名に追従した:
    • required-attrrequire-attr
    • disallowed-elementno-restricted-element
    • invalid-attrallowAttrs)→ no-unknown-attr
    • invalid-attrdisallowAttrs)→ no-restricted-attr
    • character-referenceno-malformed-character-reference / no-unescaped-char
    • no-use-event-handler-attrno-event-handler-attr(後述の理由で明示指定は削除)
    • no-unsupported-featuresno-unsupported-browser-features

変更内容

D-ZERO 独自ルールを v5 Named Rule Groups に変換

nodeRulesname を付与し、トップレベルの br 禁止ルールも d-zero/no-br という Named Rule Group にまとめた。違反メッセージに [d-zero/xxx] のようなラベルが付き、どのルールによる違反か特定しやすくなる。

v5 標準ルールの追加有効化

recommended プリセットに含まれない以下を有効化:

  • attr-order: 属性順序を id > class > role > aria-* > data-* > 要素固有属性 に統一
  • no-boolean-attr-value: boolean 属性の冗長な値を禁止(例: disabled="disabled"
  • no-default-value: デフォルト値と同一の属性値指定を禁止(例: type="text"
  • no-unsupported-browser-features: browserslist 設定に基づくブラウザ未サポート要素・属性の検出(browserslist 設定がないプロジェクトでは影響なし)

head-element-orderno-event-handler-attrmarkuplint:recommended-static-html が拡張する performance/security プリセットで既に有効になっているため、明示的な再指定はしていない(二重指定すると同一違反が2回報告される不具合になるため意図的に外した)。

img の performance/img-aspect-ratio 無効化

img[src]width/height 必須ルールを無効化(ビルド時に自動付与されるため不要)。v4 では nodeRules での上書きだったが、v5 では named rule group をトップレベル rules で直接無効化する形に変更。

テスト

  • 既存フィクスチャを attr-order/no-default-value に準拠するよう属性順序・冗長な type="text" を修正
  • attr-order-test.html / v5-rules-test.html を新規追加し、attr-order と新規有効化ルール(head-element-order/no-boolean-attr-value/no-default-value/no-event-handler-attr)の発火を個別に検証
  • cli.spec.mjs の期待値を実際の v5.0.0-rc.7 出力に合わせて更新

既存バグの修正(今回のPRで触れたついでに修正)

base.jsscript[src^='https://'], script[src^='https://'] セレクタが https:// を2回指定しており http:// が漏れていた(コピペミス)。http:// を対象に含めるよう修正。

テスト計画

  • yarn test(137件)全てパス
  • yarn lint(actionlint含む)全てパス
  • yarn build 全てパス

BREAKING CHANGE: markuplint v5 requires Node.js >=24. Rule config uses
new v5 rule names (require-attr, no-restricted-element, no-unknown-attr,
no-restricted-attr, no-malformed-character-reference, no-unescaped-char)
in place of their deprecated v4 equivalents.

Replaces the stale, alpha.3-based PR #841, whose base had drifted far
from dev and no longer applied cleanly against rc.7's rule renames.

- Convert D-ZERO custom rules to Named Rule Groups for clearer
  violation output (eg. [d-zero/no-br])
- Enable new v5 standard rules not in the recommended preset: attr-order,
  no-boolean-attr-value, no-default-value, no-unsupported-browser-features
  (head-element-order and no-event-handler-attr are already enabled by
  the extended performance/security presets, so they are intentionally
  not re-declared to avoid duplicate violations)
- Update fixtures to comply with attr-order and no-default-value, and
  add dedicated fixtures/tests for attr-order and the new v5 rules
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.

1 participant