Skip to content

require-serialized-numeric-data-type

errorType-aware

Requires DataType.* instead of raw number in serialization type positions.

In 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.

Incorrect
const Health = registerComponent<number>({ replicated: true });
type Payload = { value: number };
Correct
const Health = registerComponent<DataType.u16>({ replicated: true });
type Payload = { value: DataType.u16 };
Option Type Default
functionNames string[] ["registerComponent"]
mode "type-arguments" | "all" "type-arguments"
strict boolean false

Example config:

import ceaseNonsense from "@pobammer-ts/eslint-cease-nonsense-rules";
export default [
{
plugins: {
"cease-nonsense": ceaseNonsense,
},
rules: {
"cease-nonsense/require-serialized-numeric-data-type": [
"error",
{
mode: "type-arguments",
functionNames: ["registerComponent", "createEvent"],
},
],
},
},
];