Skip to content

Sync languages - #986

Open
jayvdb wants to merge 2 commits into
ast-grep:mainfrom
jayvdb:sync
Open

Sync languages#986
jayvdb wants to merge 2 commits into
ast-grep:mainfrom
jayvdb:sync

Conversation

@jayvdb

@jayvdb jayvdb commented May 23, 2026

Copy link
Copy Markdown

There are some inconsistencies between the various language lists, including Dart not appearing on https://ast-grep.github.io/reference/languages.html

Summary by CodeRabbit

  • New Features

    • Added Haskell language support with parser configuration
    • Added Dart language support for mobile app development
  • Documentation

    • Updated supported languages reference to include Haskell and Dart
    • Expanded Neovim editor integration documentation with additional language support
  • Chores

    • Added language consistency validation tooling

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds Haskell and Dart language support to the ast-grep documentation website and introduces a new consistency validator script. It updates reference tables, guides, and editor configurations to document the new languages, and implements automated checks to keep language definitions synchronized across parser configuration, component mappings, and filesystem assets.

Changes

Language Support Expansion and Consistency Validation

Layer / File(s) Summary
Dart language documentation updates
website/reference/languages.md, website/reference/yaml.md, website/guide/introduction.md, website/guide/tools/editors.md
Dart is added to the language reference table, YAML schema valid values, introduction guide mobile development row, and Neovim editor configuration. Css row is expanded to include scss file extension mapping, and TypeScript/Tsx rows are reordered for consistency.
Haskell language display name registration
website/src/components/astGrep/lang.ts
Haskell display name is registered in the component language mapping.
Language consistency validator script and npm integration
scripts/check-lang-consistency.mjs, package.json
New Node.js CLI script validates that language definitions remain synchronized across markdown documentation (languages.md, yaml.md), TypeScript component configuration, Rust WasmLang enum variants, and filesystem assets (WASM parsers in website/public/parsers and SVG icons in website/public/langs). Script checks alphabetical ordering of languages.md table, alignment of parserPaths and displayNames, presence of required files, and coverage in reference documentation. npm script check-langs is added to run the validator.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • ast-grep/ast-grep.github.io#728: Modifies the same Neovim lspconfig example in website/guide/tools/editors.md by expanding the filetypes list for supported languages.

Suggested reviewers

  • HerringtonDarkholme

Poem

🐰 A new tongue learns to grep with pride,
Dart and Haskell now coincide,
Scripts guard the rules with watchful eyes,
Keeping consistency—our best prize!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Sync languages' directly summarizes the main objective of the pull request, which is to synchronize and fix inconsistencies across language lists on the website.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm-workspace.yaml`:
- Around line 1-3: The allowBuilds map currently uses instructional strings for
the dprint and esbuild keys; replace those string values with boolean literals
(true or false) so the entries become valid booleans under the allowBuilds
key—update the dprint and esbuild values to the intended true/false settings in
pnpm-workspace.yaml.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ae7c7903-195e-4c36-94fe-119934019b94

📥 Commits

Reviewing files that changed from the base of the PR and between c0a1da6 and 36d56f8.

⛔ Files ignored due to path filters (3)
  • website/public/langs/haskell.svg is excluded by !**/*.svg
  • website/public/langs/nix.svg is excluded by !**/*.svg
  • website/public/parsers/tree-sitter-haskell.wasm is excluded by !**/*.wasm
📒 Files selected for processing (9)
  • package.json
  • pnpm-workspace.yaml
  • website/_data/parsers.ts
  • website/check-lang-consistency.mjs
  • website/guide/introduction.md
  • website/guide/tools/editors.md
  • website/reference/languages.md
  • website/reference/yaml.md
  • website/src/components/astGrep/lang.ts

Comment thread pnpm-workspace.yaml Outdated
Comment on lines +1 to +3
allowBuilds:
dprint: set this to true or false
esbuild: set this to true or false

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

For the pnpm version used by this repo, what is the exact pnpm-workspace.yamlschema forallowBuilds (including valid value types and examples)?

💡 Result:

Answer: In a pnpm v11-style pnpm-workspace.yaml, the allowBuilds field uses a YAML map (Record) from package matchers to boolean values. Each entry is true to allow that package’s install/build scripts and false to disallow them. Exact schema (shape) - allowBuilds must be a map/object: allowBuilds: { <package-matcher>: <boolean>, ... } [1] - Value type for each map entry: boolean (true or false) [1] - Keys: “package matchers” (package names and/or version-spec style matchers) used to match dependencies whose build scripts may be run/blocked [1] Valid value examples 1) Simple allow/deny by package name: allowBuilds: esbuild: true core-js: false # disallow ghooks: true fuse-native: true unrs-resolver: true [2] 2) Using matcher expressions that include package name + versions (as shown in the docs): allowBuilds: esbuild: true core-js: false nx@21.6.4 || 21.6.5: true nx@21.6.0: false [1] Notes about behavior (what the booleans mean) - Docs state it is “A map of package matchers to explicitly allow (true) or disallow (false) script execution.” [1] - Packages not listed are disallowed by default, and pnpm’s behavior depends on strictDepBuilds (error vs warning). [1] Repo pnpm version used - Your question asks “For the pnpm version used by this repo…”. I did not receive the repo URL / pnpm version from you, so I can only provide the current authoritative schema from pnpm’s docs for allowBuilds as used in modern pnpm (v10.26+ / v11 docs). If you share the repo link (or its packageManager field / lockfile pnpm version), I can confirm the exact pnpm release and re-check the corresponding documentation for that version.

Citations:


Fix pnpm allowBuilds value types to booleans

allowBuilds in pnpm-workspace.yaml is a map of package matchers to boolean values (true/false). Setting dprint/esbuild to instructional strings makes the config invalid (wrong value type) and will likely be rejected or ignored by pnpm.

Proposed fix
 allowBuilds:
-  dprint: set this to true or false
-  esbuild: set this to true or false
+  dprint: true
+  esbuild: true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
allowBuilds:
dprint: set this to true or false
esbuild: set this to true or false
allowBuilds:
dprint: true
esbuild: true
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm-workspace.yaml` around lines 1 - 3, The allowBuilds map currently uses
instructional strings for the dprint and esbuild keys; replace those string
values with boolean literals (true or false) so the entries become valid
booleans under the allowBuilds key—update the dprint and esbuild values to the
intended true/false settings in pnpm-workspace.yaml.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@website/check-lang-consistency.mjs`:
- Around line 24-30: The code currently uses langTableRe and langsFromTable to
capture the first table cell (display name) with /^\|(\w+)\s*\|/ which excludes
punctuation and returns display names instead of IDs; change the regex to
capture the second column (the language ID) and allow non-word characters (e.g.
/^\|[^|]*\|\s*([^|]+)\s*\|/gm), then replace uses of langTableRe /
langsFromTable (including the other occurrences that parse table rows) so they
push the captured ID (m[1]) and handle trimming; ensure all three locations that
previously used /^\|(\w+)\s*\|/ are updated to the new regex and logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bbb70a89-fe5f-47be-8a1c-b8bb22534fc8

📥 Commits

Reviewing files that changed from the base of the PR and between 36d56f8 and bae2108.

⛔ Files ignored due to path filters (3)
  • website/public/langs/haskell.svg is excluded by !**/*.svg
  • website/public/langs/nix.svg is excluded by !**/*.svg
  • website/public/parsers/tree-sitter-haskell.wasm is excluded by !**/*.wasm
📒 Files selected for processing (8)
  • package.json
  • website/_data/parsers.ts
  • website/check-lang-consistency.mjs
  • website/guide/introduction.md
  • website/guide/tools/editors.md
  • website/reference/languages.md
  • website/reference/yaml.md
  • website/src/components/astGrep/lang.ts
✅ Files skipped from review due to trivial changes (4)
  • website/reference/yaml.md
  • website/guide/introduction.md
  • package.json
  • website/reference/languages.md

Comment on lines +24 to +30
const langTableRe = /^\|(\w+)\s*\|/gm
const langsFromTable = []
for (const m of langsMd.matchAll(langTableRe)) {
const name = m[1]
if (name === 'Language') continue // header row
langsFromTable.push(name)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Parse language IDs from languages.md, not display names.

The current regex reads the first column (Language display name), then compares it with yaml/parser IDs. This creates false errors (and misses names like C#/C++ because \w+ excludes punctuation).

Suggested fix
-const langTableRe = /^\|(\w+)\s*\|/gm
-const langsFromTable = []
-for (const m of langsMd.matchAll(langTableRe)) {
-  const name = m[1]
-  if (name === 'Language') continue // header row
-  langsFromTable.push(name)
-}
+// Capture the Language Id column and collect all backticked ids/aliases.
+const langTableRe = /^\|\s*[^|]+\|\s*([^|]+)\|/gm
+const langsFromTable = []
+for (const m of langsMd.matchAll(langTableRe)) {
+  const idColumn = m[1]
+  for (const id of idColumn.matchAll(/`([^`]+)`/g)) {
+    langsFromTable.push(id[1])
+  }
+}
-const tableLower = new Set(langsFromTable.map(l => l.toLowerCase()))
+const tableLower = new Set(langsFromTable.map(l => l.toLowerCase()))

Also applies to: 47-55, 145-149

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@website/check-lang-consistency.mjs` around lines 24 - 30, The code currently
uses langTableRe and langsFromTable to capture the first table cell (display
name) with /^\|(\w+)\s*\|/ which excludes punctuation and returns display names
instead of IDs; change the regex to capture the second column (the language ID)
and allow non-word characters (e.g. /^\|[^|]*\|\s*([^|]+)\s*\|/gm), then replace
uses of langTableRe / langsFromTable (including the other occurrences that parse
table rows) so they push the captured ID (m[1]) and handle trimming; ensure all
three locations that previously used /^\|(\w+)\s*\|/ are updated to the new
regex and logic.

Comment thread scripts/check-lang-consistency.mjs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/check-lang-consistency.mjs (1)

40-42: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Guard against null when no backticked values are found.

If yamlMatch[1] contains no backticked values, .match() returns null and calling .map() on it will throw a TypeError.

🛡️ Proposed fix
 const langsFromYaml = yamlMatch
-  ? yamlMatch[1].match(/`(\w+)`/g).map(s => s.replace(/`/g, ''))
+  ? (yamlMatch[1].match(/`(\w+)`/g) || []).map(s => s.replace(/`/g, ''))
   : []
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/check-lang-consistency.mjs` around lines 40 - 42, The code computes
langsFromYaml from yamlMatch[1].match(...).map(...), but if
yamlMatch[1].match(...) returns null the .map call will throw; update the logic
in scripts/check-lang-consistency.mjs (symbols: yamlMatch, langsFromYaml) to
handle a null match by supplying an empty-array fallback before calling .map
(e.g. store the result of yamlMatch[1].match(/`(\w+)`/g) into a variable and use
|| or ?? to default to []), so .map is only invoked on an array and
langsFromYaml becomes [] when no backticked values are found.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@scripts/check-lang-consistency.mjs`:
- Around line 40-42: The code computes langsFromYaml from
yamlMatch[1].match(...).map(...), but if yamlMatch[1].match(...) returns null
the .map call will throw; update the logic in scripts/check-lang-consistency.mjs
(symbols: yamlMatch, langsFromYaml) to handle a null match by supplying an
empty-array fallback before calling .map (e.g. store the result of
yamlMatch[1].match(/`(\w+)`/g) into a variable and use || or ?? to default to
[]), so .map is only invoked on an array and langsFromYaml becomes [] when no
backticked values are found.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ac8cba69-961d-447f-912d-bbf124f11695

📥 Commits

Reviewing files that changed from the base of the PR and between bae2108 and f6ebd66.

📒 Files selected for processing (2)
  • package.json
  • scripts/check-lang-consistency.mjs
✅ Files skipped from review due to trivial changes (1)
  • package.json

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