Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
lint: Don’t auto-fix with remark unless requested.
Anders Kaseorg6615756437b0
diff --git a/package.json b/package.jsonindex a3ac0f2dafc..1f3b1f74f3f 100644--- a/package.json+++ b/package.json@@ -154,6 +154,7 @@"prettier": "~3.5.3","prettier-plugin-astro": "^0.14.1","puppeteer": "^24.1.1",+ "remark-cli": "^12.0.1","source-map": "npm:source-map-js@^1.2.1","stylelint": "^16.2.0","stylelint-config-standard": "^39.0.0",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 2da7be940f0..b05f971759f 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -482,6 +482,9 @@ importers:puppeteer:specifier: ^24.1.1version: 24.16.2([email protected])+ remark-cli:+ specifier: ^12.0.1+ version: 12.0.1source-map:specifier: npm:source-map-js@^1.2.1version: [email protected]@@ -570,9 +573,9 @@ importers:specifier: ^22.1.0version: 22.2.0devDependencies:- remark-cli:- specifier: ^12.0.1- version: 12.0.1+ mdast-util-to-markdown:+ specifier: ^2.1.2+ version: 2.1.2remark-frontmatter:specifier: ^5.0.0version: 5.0.0@@ -627,6 +630,9 @@ importers:unified:specifier: ^11.0.5version: 11.0.5+ unified-lint-rule:+ specifier: ^3.0.1+ version: 3.0.1packages:diff --git a/starlight_help/package.json b/starlight_help/package.jsonindex 27ebd11a57b..767cc42e57a 100644--- a/starlight_help/package.json+++ b/starlight_help/package.json@@ -7,9 +7,7 @@"start": "astro dev","build": "astro check && astro build","preview": "astro preview",- "astro": "astro",- "format": "remark --ext mdx --frail --output --quiet -- .",- "format-silent": "remark --ext mdx --output --silent -- ."+ "astro": "astro"},"dependencies": {"@astrojs/check": "^0.9.3",@@ -29,7 +27,7 @@"unplugin-icons": "^22.1.0"},"devDependencies": {- "remark-cli": "^12.0.1",+ "mdast-util-to-markdown": "^2.1.2","remark-frontmatter": "^5.0.0","remark-gfm": "^4.0.1","remark-lint-fenced-code-flag": "^4.2.0",@@ -47,6 +45,7 @@"remark-preset-lint-markdown-style-guide": "^6.0.1","remark-preset-lint-recommended": "^7.0.1","remark-stringify": "^11.0.0",- "unified": "^11.0.5"+ "unified": "^11.0.5",+ "unified-lint-rule": "^3.0.1"}}diff --git a/starlight_help/src/.remarkrc.js b/starlight_help/src/.remarkrc.jsindex 23a105bb559..04b207fe640 100644--- a/starlight_help/src/.remarkrc.js+++ b/starlight_help/src/.remarkrc.js@@ -9,6 +9,7 @@* @import {Preset} from 'unified'*/+import {toMarkdown} from "mdast-util-to-markdown";import remarkFrontmatter from "remark-frontmatter";import remarkGfm from "remark-gfm";import remarkLintFencedCodeFlag from "remark-lint-fenced-code-flag";@@ -27,6 +28,32 @@ import remarkMdx from "remark-mdx";import remarkPresetLintMarkdownStyleGuide from "remark-preset-lint-markdown-style-guide";import remarkPresetLintRecommended from "remark-preset-lint-recommended";import remarkStringify from "remark-stringify";+import {lintRule} from "unified-lint-rule";++const stringifyOptions = {+ // Number all list items as 1, for compatibility with+ // remark-lint-ordered-list-marker-value.+ incrementListMarker: false,+};++// Make sure the linter fails if files need to be reformatted. (The other rules+// catch some but not all formatting issues, so this is needed to be sure we+// don't silently ignore changes that would be made with --fix.)+function remarkLintNeedsReformatting(...args) {+ if (!this.data("settings").checkReformatting) {+ return undefined;+ }+ return lintRule("needs-reformatting", async (tree, file) => {+ const formatted = toMarkdown(tree, {+ ...this.data("settings"),+ ...stringifyOptions,+ extensions: this.data("toMarkdownExtensions") || [],+ });+ if (formatted !== file.value) {+ file.message("Would be reformatted");+ }+ })(...args);+}const remarkLintRules = {plugins: [@@ -44,6 +71,7 @@ const remarkLintRules = {[remarkLintNoDuplicateHeadings, false],[remarkLintHeadingIncrement, false],[remarkLintUnorderedListMarkerStyle, "*"],+ remarkLintNeedsReformatting,],};@@ -54,13 +82,7 @@ const config = {remarkMdx,[remarkFrontmatter, ["yaml"]],remarkLintRules,- // The format step was converting our ordered list items to have- // incremental numbering instead of using 1. for every list item. This- // was not because of any remark-lint rule, but because of- // remark-stringify which auto increments any lists it processes. We- // followed the recommended fix from- // https://github.com/remarkjs/remark-lint/blob/ae2f941d88551d0a1103e586495dec0f55469720/packages/remark-lint-ordered-list-marker-value/readme.md?plain=1#L185- [remarkStringify, {incrementListMarker: false}],+ [remarkStringify, stringifyOptions],],};diff --git a/tools/format-mdx b/tools/format-mdxdeleted file mode 100755index cbf9d91f6be..00000000000--- a/tools/format-mdx+++ /dev/null@@ -1,9 +0,0 @@-#!/usr/bin/env python3--import subprocess--subprocess.check_call(- ["/usr/local/bin/corepack", "pnpm", "run", "format"],- cwd="starlight_help",- stdout=subprocess.DEVNULL,-)diff --git a/tools/lint b/tools/lintindex a2d496a9fcc..844e67ab22f 100755--- a/tools/lint+++ b/tools/lint@@ -221,9 +221,11 @@ def run() -> None:description="Check docs/THIRDPARTY copyright file syntax",)linter_config.external_linter(- "format-mdx",- ["tools/format-mdx"],+ "remark",+ ["node_modules/.bin/remark", "--frail", "--quiet", "--no-stdout"],["mdx"],+ check_arg=['--setting="checkReformatting": true', "--"],+ fix_arg=["--output", "--"],description="Lint and format MDX files",)diff --git a/version.py b/version.pyindex d5c670d8ab7..c5ac6d38454 100644--- a/version.py+++ b/version.py@@ -49,4 +49,4 @@ API_FEATURE_LEVEL = 425# historical commits sharing the same major version, in which case a# minor version bump suffices.-PROVISION_VERSION = (346, 0) # bumped 2025-09-04 to remove remark-lint-list-item-indent+PROVISION_VERSION = (346, 1) # bumped 2025-09-04 to add remark-cli and friends