A collection of ESLint rules specifically targeted for roblox-ts.
npm install eslint-plugin-roblox-ts[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href] [![JSDocs][jsdocs-src]][jsdocs-href]
[![License][license-src]][license-href]
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-undeclared-scope | Enforce that only npm scopes listed in typeRoots can be imported | | | π |
| 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 | π§ | | π |
[npm-version-src]:
https://img.shields.io/npm/v/eslint-plugin-roblox-ts?style=flat&colorA=080f12&colorB=1fa669
[npm-version-href]: https://npmjs.com/package/eslint-plugin-roblox-ts
[npm-downloads-src]:
https://img.shields.io/npm/dm/eslint-plugin-roblox-ts?style=flat&colorA=080f12&colorB=1fa669
[npm-downloads-href]: https://npmjs.com/package/eslint-plugin-roblox-ts
[bundle-src]:
https://img.shields.io/bundlephobia/minzip/eslint-plugin-roblox-ts?style=flat&colorA=080f12&colorB=1fa669&label=minzip
[bundle-href]: https://bundlephobia.com/result?p=eslint-plugin-roblox-ts
[license-src]:
https://img.shields.io/github/license/roblox-ts/eslint-plugin-roblox-ts.svg?style=flat&colorA=080f12&colorB=1fa669
[license-href]:
https://github.com/roblox-ts/eslint-plugin-roblox-ts/blob/main/LICENSE
[jsdocs-src]:
https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
[jsdocs-href]: https://www.jsdocs.io/package/eslint-plugin-roblox-ts
You'll first need to install ESLint v8.0.0 or greater:
``sh`
npm install eslint --save-dev
ESLint 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:
`sh`
npm install eslint-plugin-roblox-ts --save-dev
The 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.
`js
import roblox from "eslint-plugin-roblox-ts";
export default [roblox.configs.recommended];
`
`json`
{
"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.
`js
import roblox from "eslint-plugin-roblox-ts";
export default [
{
plugins: {
"roblox-ts": roblox,
},
rules: {
"roblox-ts/no-any": ["error", { fixToUnknown: true }],
},
},
];
`
`json`
{
"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.
`json``
{
"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.