Skip to content

No Unsupported Syntax

ErrorRoblox
small-rules/no-unsupported-syntax

Disallow syntax that roblox-ts cannot compile to Luau.

Rationale

This is a port from the official roblox-ts ESLint plugin. It bans you from writing TypeScript that roblox-ts cannot turn into Luau, like globalThis, labeled statements, .prototype, regex literals, and (sometimes) rest elements in destructuring patterns all get flagged on by default.

Every check is individually configurable, though, because not every Roblox-side compiler shares the same limits. The one that matters to me is spreadDestructuring: sloptor supports it, so running this rule with the default settings against sloptor code is wrong.

This is valid with sloptor!

const array = [1, 2, 3, 4, 5];
const [a, , ...rest] = array;
-- Compiled with sloptor v2.3.3
local array = { 1, 2, 3, 4, 5 }
local a = array[1]
local rest = table.move(array, 3, #array, 1, {})
return nil

Even the hole in the middle survives, the rest is table.move’d to a fresh table, starting after the skipped element. If you’re on sloptor, turn that check off:

{
"rules": {
"small-rules/no-unsupported-syntax": ["error", { "spreadDestructuring": false }]
}
}

The other four stay on. If your compiler ever grows support for one of them (somehow), toggle need to disable the whole rule.

Diagnostic Messages

globalThis
`globalThis` is not supported in roblox-ts.
label
`label` is not supported in roblox-ts.
prototype
`.prototype` is not supported in roblox-ts.
regexLiteral
Regex literals are not supported in roblox-ts.
spreadDestructuring
Operator `...` is not supported for destructuring!

Configuration

This rule accepts one options object after the severity.

globalThisOptional

Disallow the globalThis identifier.

labelsOptional

Disallow labeled statements.

prototypeOptional

Disallow `.prototype` member access.

regexLiteralsOptional

Disallow regular expression literals.

spreadDestructuringOptional

Disallow rest elements in destructuring patterns.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-unsupported-syntax": [
"error",
{
"globalThis": true,
"labels": true,
"prototype": true,
"regexLiterals": true,
"spreadDestructuring": true
}
]
}
}

Examples

Rest element in object destructuring
const { a, ...rest } = obj;
Explicit properties
const { a, b } = obj;