A collection of ESLint rules specifically targeted to flag common issues when using roblox-ts. These rules are nearly all designed to help avoid compiler errors for features that are not supported by the roblox-ts compiler, despite being valid TypeScript.
These rules should help users learn roblox-ts when coming from Lua, as well as guiding users who already know TypeScript to avoid unsupported features.
🔧 Automatically fixable by the
--fix CLI option.
💡
Manually fixable by
editor suggestions.
💭
Requires type information.
| Name | Description | 🔧 | 💡 | 💭 |
|---|---|---|---|---|
| lua-truthiness | Enforces the use of lua truthiness | 💭 | ||
| misleading-lua-tuple-checks | Disallow the use of LuaTuple in conditional expressions | 🔧 | 💭 | |
| no-any | Disallow values of type any. Use unknown instead |
🔧 | 💡 | |
| no-array-pairs | Disallow usage of pairs() and ipairs() with Array | 💭 | ||
| no-enum-merging | Disallow merging enum declarations | |||
| no-export-assignment-let | Disallow using export = on a let variable |
|||
| no-for-in | Disallow iterating with a for-in loop | 🔧 | ||
| no-function-expression-name | Disallow the use of function expression names | 🔧 | ||
| no-get-set | Disallow getters and setters | 🔧 | ||
| no-implicit-self | Enforce the use of . instead of : for method calls |
🔧 | ||
| no-invalid-identifier | Disallow the use of Luau reserved keywords as identifiers | |||
| no-namespace-merging | Disallow merging namespace declarations | |||
| no-null | Disallow usage of the null keyword |
🔧 | ||
| no-object-math | Enforce DataType math methods over operators | 🔧 | 💭 | |
| no-post-fix-new | Disallow .new() on objects without a .new() method | 🔧 | 💭 | |
| no-preceding-spread-element | Disallow spread elements not last in a list of arguments | 💭 | ||
| no-private-identifier | Disallow the use of private identifiers (#) |
🔧 | ||
| no-unsupported-syntax | Disallow unsupported syntax in roblox-ts | |||
| no-user-defined-lua-tuple | Disallow usage of LuaTuple type keyword and $tuple() calls | 🔧 | ||
| no-value-typeof | Disallow using typeof to check for value types |
|||
| prefer-get-players | Enforces the use of Players.GetPlayers() instead of Players.GetChildren() | 🔧 | ||
| prefer-task-library | Enforce use of task library alternatives | 🔧 | ||
| size-method | Enforce use of .size() instead of .length or .size property | 🔧 | 💭 |
You'll first need to install ESLint v8.0.0 or greater:
npm install eslint --save-devESLint Version Support:
- ESLint v8.x: ✅ Fully supported
- ESLint v9.x: ✅ Fully supported
ESLint Version Support:
- ESLint v8.x: ✅ Fully supported
- ESLint v9.x: ✅ Fully supported
Next, install eslint-plugin-roblox-ts:
npm install eslint-plugin-roblox-ts --save-devThe easiest way to use eslint-plugin-roblox-ts is to use the ready-made
config. Config files use all the rules of the current plugin, but you can
override them.
Flat Config (eslint.config.ts)
import roblox from "eslint-plugin-roblox-ts";
export default [roblox.configs.recommended];Legacy Config (.eslintrc)
{
"extends": ["plugin:roblox-ts/recommended-legacy"]
}Altertatively, add eslint-plugin-roblox-ts to the plugins section of the
ESLint configuration file and define the list of rules you will use.
import roblox from "eslint-plugin-roblox-ts";
export default [
{
plugins: {
"roblox-ts": roblox,
},
rules: {
"roblox-ts/no-any": ["error", { fixToUnknown: true }],
},
},
];Legacy Config (.eslintrc)
{
"extends": ["plugin:roblox-ts/recommended-legacy"]
}Alternatively, add eslint-plugin-roblox-ts to the plugins section of your
.eslintrc configuration file and configure the rules you want to use.
{
"plugins": [
"roblox-ts"
],
"rules": {
"roblox-ts/no-any": ["error", { "fixToUnknown": true }],
"roblox-ts/no-null": "error",
"roblox-ts/no-object-math": "error"
}
}This plugin is following Semantic Versioning and ESLint's Semantic Versioning Policy.
See Contributing Guide.