require-serialized-numeric-data-type
Requires DataType.* instead of raw number in serialization type positions.
Rule details Problem
Section titled “Rule details ”ProblemIn the default type-arguments mode, the rule only checks type arguments passed to selected functions. By default, that
means registerComponent<...>().
It reports raw number and nested uses of number, including unions, intersections, arrays, tuples, type literals,
indexed access types, and generic type arguments. DataType.u8, DataType.i16, DataType.f32, and the other supported
DataType.* variants are allowed.
In all mode, the rule also checks function parameters, return types, properties, type aliases, and variable type
annotations across the file. When strict: true, it uses the TypeScript type checker so aliased number types can be
reported too.
Examples
Section titled “Examples” Incorrect
const Health = registerComponent<number>({ replicated: true });
type Payload = { value: number }; Correct
const Health = registerComponent<DataType.u16>({ replicated: true });
type Payload = { value: DataType.u16 };Options
Section titled “Options”| Option | Type | Default |
|---|---|---|
functionNames | string[] | ["registerComponent"] |
mode | "type-arguments" | "all" | "type-arguments" |
strict | boolean | false |
Example config:
import ceaseNonsense from "eslint-plugin-cease-nonsense";
export default [ { plugins: { "cease-nonsense": ceaseNonsense, }, rules: { "cease-nonsense/require-serialized-numeric-data-type": [ "error", { mode: "type-arguments", functionNames: ["registerComponent", "createEvent"], }, ], }, },];Related rules
Section titled “Related rules” require-module-level-instantiation Another rule aimed at long-lived runtime behavior