Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e253963
Implement rule
Mar 19, 2026
2bbe811
Update messages and reorder
Mar 19, 2026
09f1ff8
Clean up
Mar 19, 2026
226a7aa
Report assignment pattern
Mar 19, 2026
245154a
Add a rule for private identifiers
Mar 19, 2026
d92702f
Add missing tests
Mar 19, 2026
096069e
Reorder tests
Mar 19, 2026
bd32605
lint
Mar 19, 2026
2f38104
Merge branch 'main' into feat/lint-rule-for-unsupported-js
aleksanderkatan Mar 19, 2026
c40da2b
Potential fix for pull request finding
aleksanderkatan Mar 19, 2026
c55d427
Potential fix for pull request finding
aleksanderkatan Mar 19, 2026
e0c6bfb
Merge remote-tracking branch 'origin/main' into feat/lint-rule-for-un…
aleksanderkatan Apr 1, 2026
471e7c2
Merge fixes
aleksanderkatan Apr 1, 2026
eba340b
Report eqeq
aleksanderkatan Apr 1, 2026
b2a1d91
Move tests
aleksanderkatan Apr 1, 2026
ebe784e
Update directiveTracking
aleksanderkatan Apr 1, 2026
46867ea
Report functions
aleksanderkatan Apr 1, 2026
d595ca3
Omit reporting object methods
aleksanderkatan Apr 2, 2026
97fbfb4
Update readme
aleksanderkatan Apr 2, 2026
4247655
Report chain expression
aleksanderkatan Apr 2, 2026
d268b4b
Report ??
aleksanderkatan Apr 2, 2026
51f780f
Report unsupported unary operators
aleksanderkatan Apr 2, 2026
47cb18c
Update binary and unary operators
aleksanderkatan Apr 2, 2026
d264738
Better types
aleksanderkatan Apr 2, 2026
d78b9dd
Review fixes
aleksanderkatan Apr 2, 2026
a319001
Merge branch 'main' into feat/lint-rule-for-unsupported-js
aleksanderkatan Apr 2, 2026
e2a777b
Change from warn to error
aleksanderkatan Apr 2, 2026
415579a
Merge remote-tracking branch 'origin/main' into feat/lint-rule-for-un…
aleksanderkatan Apr 14, 2026
31b2905
Less getDirectiveStack calls
aleksanderkatan Apr 14, 2026
bda87f2
Review fixes
aleksanderkatan Apr 14, 2026
0e39bd3
Report unsupported assignment expressions
aleksanderkatan Apr 14, 2026
483b984
Merge branch 'main' into feat/lint-rule-for-unsupported-js
aleksanderkatan Apr 14, 2026
8760085
Review fixes
aleksanderkatan Apr 14, 2026
3c5f586
Merge branch 'main' into feat/lint-rule-for-unsupported-js
aleksanderkatan Apr 15, 2026
788c52c
Merge branch 'main' into feat/lint-rule-for-unsupported-js
aleksanderkatan Apr 20, 2026
7b5a9f2
Merge branch 'main' into feat/lint-rule-for-unsupported-js
aleksanderkatan Apr 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/eslint-plugin/src/configs.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import type { TSESLint } from '@typescript-eslint/utils';
import { integerDivision } from './rules/integerDivision.ts';
import { unwrappedPojos } from './rules/unwrappedPojos.ts';
import { noUnsupportedSyntax } from './rules/noUnsupportedSyntax.ts';

export const rules = {
'integer-division': integerDivision,
'unwrapped-pojo': unwrappedPojos,
'no-unsupported-syntax': noUnsupportedSyntax,
} as const;

type Rules = Record<`typegpu/${keyof typeof rules}`, TSESLint.FlatConfig.RuleEntry>;

export const recommendedRules: Rules = {
'typegpu/integer-division': 'warn',
'typegpu/unwrapped-pojo': 'warn',
'typegpu/no-unsupported-syntax': 'warn',
};

export const allRules: Rules = {
'typegpu/integer-division': 'error',
'typegpu/unwrapped-pojo': 'error',
'typegpu/no-unsupported-syntax': 'error',
};
202 changes: 202 additions & 0 deletions packages/eslint-plugin/src/rules/noUnsupportedSyntax.ts
Comment thread
aleksanderkatan marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
import { TSESTree } from '@typescript-eslint/utils';
Comment thread
aleksanderkatan marked this conversation as resolved.
Outdated
import { enhanceRule } from '../enhanceRule.ts';
import { directiveTracking } from '../enhancers/directiveTracking.ts';
import { createRule } from '../ruleCreator.ts';

export const noUnsupportedSyntax = createRule({
name: 'no-unsupported-syntax',
meta: {
type: 'problem',
docs: {
description: `Disallow JS syntax that will not be parsed to correct WGSL.`,
},
messages: {
unsupportedSyntax:
"'{{snippet}}' will not parse to correct WGSL because it uses unsupported syntax: {{syntax}}.",
},
schema: [],
},
defaultOptions: [],

create: enhanceRule({ directives: directiveTracking }, (context, state) => {
const { directives } = state;

function report(node: TSESTree.Node, syntax: string) {
context.report({
node,
messageId: 'unsupportedSyntax',
data: { snippet: context.sourceCode.getText(node), syntax },
});
}

return {
ArrowFunctionExpression() {
// TODO: needs to know if parent is inside useGpu
},

Comment thread
aleksanderkatan marked this conversation as resolved.
Outdated
AssignmentPattern(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'assignment pattern (default parameter)');
},

AwaitExpression(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'await expression');
},

ClassDeclaration(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'class declaration');
},

ClassExpression(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'class expression');
},

DoWhileStatement(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'do-while loop');
},

ForInStatement(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'for-in loop');
},

FunctionDeclaration() {
// TODO: needs to know if parent is inside useGpu
},
Comment thread
aleksanderkatan marked this conversation as resolved.
Outdated

FunctionExpression() {
// TODO: needs to know if parent is inside useGpu
},
Comment thread
aleksanderkatan marked this conversation as resolved.
Outdated

Literal(node) {
if (!directives.insideUseGpu()) {
return;
}
if ('regex' in node && node.regex) {
report(node, 'regular expression literal');
}
},

NewExpression(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, `'new' expression`);
},

PrivateIdentifier(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'private identifier');
},

Property(node) {
if (!directives.insideUseGpu()) {
return;
}
if (node.method) {
report(node, 'object method shorthand');
}
if (node.computed) {
report(node, 'computed property key');
}
},

SequenceExpression(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'sequence expression (comma operator)');
},

SpreadElement(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'spread element');
},

SwitchStatement(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'switch statement');
},

TemplateLiteral(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'template literal');
},

ThrowStatement(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'throw statement');
},

TryStatement(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'try-catch statement');
},

UpdateExpression(node) {
if (!directives.insideUseGpu()) {
return;
}
if (node.prefix) {
report(node, 'prefix update expression');
}
},

VariableDeclaration(node) {
if (!directives.insideUseGpu()) {
return;
}
if (node.kind === 'var') {
report(node, `'var' declaration`);
}
if (node.declarations.length > 1) {
report(node, 'Multiple variable declarations in one statement');
Comment thread
aleksanderkatan marked this conversation as resolved.
Outdated
}
},

VariableDeclarator(node) {
if (!directives.insideUseGpu()) {
return;
}
if (node.id.type !== 'Identifier') {
report(node, 'variable declaration using destructuring');
}
},

YieldExpression(node) {
if (!directives.insideUseGpu()) {
return;
}
report(node, 'yield expression');
},
};
}),
});
Loading
Loading