-
-
Notifications
You must be signed in to change notification settings - Fork 60
feat: Lint rule for unsupported js #2299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aleksanderkatan
wants to merge
27
commits into
main
Choose a base branch
from
feat/lint-rule-for-unsupported-js
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
e253963
Implement rule
2bbe811
Update messages and reorder
09f1ff8
Clean up
226a7aa
Report assignment pattern
245154a
Add a rule for private identifiers
d92702f
Add missing tests
096069e
Reorder tests
bd32605
lint
2f38104
Merge branch 'main' into feat/lint-rule-for-unsupported-js
aleksanderkatan c40da2b
Potential fix for pull request finding
aleksanderkatan c55d427
Potential fix for pull request finding
aleksanderkatan e0c6bfb
Merge remote-tracking branch 'origin/main' into feat/lint-rule-for-un…
aleksanderkatan 471e7c2
Merge fixes
aleksanderkatan eba340b
Report eqeq
aleksanderkatan b2a1d91
Move tests
aleksanderkatan ebe784e
Update directiveTracking
aleksanderkatan 46867ea
Report functions
aleksanderkatan d595ca3
Omit reporting object methods
aleksanderkatan 97fbfb4
Update readme
aleksanderkatan 4247655
Report chain expression
aleksanderkatan d268b4b
Report ??
aleksanderkatan 51f780f
Report unsupported unary operators
aleksanderkatan 47cb18c
Update binary and unary operators
aleksanderkatan d264738
Better types
aleksanderkatan d78b9dd
Review fixes
aleksanderkatan a319001
Merge branch 'main' into feat/lint-rule-for-unsupported-js
aleksanderkatan e2a777b
Change from warn to error
aleksanderkatan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/eslint-plugin/docs/rules/no-unsupported-syntax.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # typegpu/no-unsupported-syntax | ||
|
|
||
| 📝 Disallow JS syntax that will not be parsed to correct WGSL. | ||
|
|
||
| 🚨 This rule is enabled in the ⭐ `recommended` config. | ||
|
|
||
| <!-- end auto-generated rule header --> | ||
|
|
||
| ## Rule details | ||
|
|
||
| Examples of **incorrect** code for this rule: | ||
|
|
||
| ```ts | ||
| const fn = () => { | ||
| 'use gpu'; | ||
| const helper = (n) => 2 * n; // ArrowFunctionExpression | ||
| return helper(1); | ||
| } | ||
| ``` | ||
| ```ts | ||
| const fn = () => { | ||
| 'use gpu'; | ||
| const myStruct = Struct({prop: 1}); | ||
| const otherStruct = Struct({...myStruct}); // SpreadElement | ||
| return otherStruct; | ||
| } | ||
| ``` | ||
| ```ts | ||
| const fn = () => { | ||
| 'use gpu'; | ||
| throw new Error(); // ThrowStatement | ||
| } | ||
| ``` | ||
|
|
||
| Examples of **correct** code for this rule: | ||
|
|
||
| ```ts | ||
| const fn = (a) => { | ||
| 'use gpu'; | ||
| let counter = 0; | ||
| let i = a; | ||
| while (i) { | ||
| if (i % 2 === 1) { | ||
| counter += 1; | ||
| } | ||
| i >>= 1; | ||
| } | ||
| return otherFn(counter); | ||
| } | ||
| ``` | ||
| ```ts | ||
| const fn = () => { | ||
| 'use gpu'; | ||
| let a = 0; | ||
| const arr = [1, 2, 3]; | ||
| for (const item of arr) { | ||
| a += item; | ||
| } | ||
| return a; | ||
| } | ||
| ``` | ||
|
|
||
| Note that it is possible that TypeGPU starts/stops supporting JS syntax from version to version. | ||
| Make sure that the minor versions of `typegpu` and `eslint-plugin-typegpu` match. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.