Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 1.04 KB

File metadata and controls

34 lines (22 loc) · 1.04 KB

Enforce use of .size() instead of .length or .size property

🔧 This rule is automatically fixable by the --fix CLI option.

💭 This rule requires type information.

Rule details

This rule automatically replaces .length and .size property accesses on arrays, strings, Set, Map, WeakSet, and WeakMap with a .size() method call. This is necessary for Roblox compatibility, as these properties do not exist in roblox-ts.

Examples

const n = arr.length; // ❌
const n = arr.size(); // ✅

const n = str.length; // ❌
const n = str.size(); // ✅

const n = set.size; // ❌
const n = set.size(); // ✅

const n = map.size; // ❌
const n = map.size(); // ✅

const n = weakSet.size; // ❌
const n = weakSet.size(); // ✅

const n = weakMap.size; // ❌
const n = weakMap.size(); // ✅