feat: Lint rule for unsupported js#2299
Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:No major changes. 📋 All resultsClick to reveal the results table (350 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
There was a problem hiding this comment.
Pull request overview
Adds a new typegpu/no-unsupported-syntax ESLint rule to flag JavaScript constructs that can’t be translated into valid WGSL inside 'use gpu' functions, and wires it into the plugin’s shipped configs.
Changes:
- Introduce
no-unsupported-syntaxrule with targeted reports for a set of unsupported ESTree node types when inside'use gpu'. - Add a comprehensive RuleTester suite for the new rule.
- Register the rule in
recommendedandallconfigs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| packages/eslint-plugin/src/rules/noUnsupportedSyntax.ts | New rule implementation using directiveTracking to conditionally report unsupported syntax inside 'use gpu'. |
| packages/eslint-plugin/tests/noUnsupportedSyntax.test.ts | New unit tests covering valid/invalid syntax cases and expected diagnostics. |
| packages/eslint-plugin/src/configs.ts | Registers the new rule and enables it in recommended (warn) and all (error). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
== |
There was a problem hiding this comment.
Pull request overview
Adds a new ESLint rule to help TypeGPU users avoid JavaScript syntax that can’t be reliably translated into WGSL, integrating it into the plugin’s configs and documentation.
Changes:
- Introduce
typegpu/no-unsupported-syntaxrule that reports various unsupported/conditionally-supported AST node types inside'use gpu'functions. - Extend the
directiveTrackingenhancer API to expose the current directive stack for nested-function detection. - Add comprehensive rule tests and user-facing documentation, and wire the rule into
recommended/allconfigs + README rule list.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/eslint-plugin/src/rules/noUnsupportedSyntax.ts | New rule implementation using directive tracking to scope reports to TypeGPU functions (and nested functions within them). |
| packages/eslint-plugin/src/enhancers/directiveTracking.ts | Exposes directive stack to consumers (used for nested-function detection). |
| packages/eslint-plugin/tests/rules/noUnsupportedSyntax.test.ts | New RuleTester suite covering valid/invalid syntax cases. |
| packages/eslint-plugin/src/configs.ts | Registers the new rule and enables it in recommended (warn) and all (error). |
| packages/eslint-plugin/README.md | Adds the new rule to the auto-generated rules list table. |
| packages/eslint-plugin/docs/rules/no-unsupported-syntax.md | New documentation page with examples and config note. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.98, 1.88, 4.11, 6.24, 7.16, 11.40, 22.47, 21.39]
line [0.93, 1.92, 4.38, 6.47, 7.46, 11.66, 21.94, 24.12]
line [0.96, 1.83, 4.00, 6.33, 7.29, 10.57, 22.16, 23.89]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.29, 0.56, 0.70, 0.84, 1.13, 1.30, 1.42, 1.64]
line [0.30, 0.53, 0.72, 0.84, 1.14, 1.22, 1.49, 1.64]
line [0.33, 0.56, 0.73, 0.89, 1.17, 1.18, 1.44, 1.62]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.89, 1.96, 3.47, 6.27, 12.42, 24.96, 53.91, 112.61]
line [0.84, 1.91, 3.83, 6.17, 12.36, 25.80, 56.78, 114.84]
line [0.80, 1.96, 4.24, 6.13, 12.36, 25.40, 54.80, 110.89]
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Blocked by #2235 since both PRs need to update directive tracking enhancer.I tried to be thorough because this may be beneficial for agents writing typegpu functions.
I went through all possible node types, here is the current state of things.
Valid:
Reported:
Conditionally reported:
!=or other unsupported)==or other unsupported)??)var)const [a] = ...,const { a } = ...)Skipped because there is no need to report:
Skipped because I don't think we care: