Disallow returning a value with type any from a function.
This rule applies only to .js and .ts files.
// code-linter.json5
{
"rules": {
"@typescript-eslint/no-unsafe-return": "error"
}
} export function foo1(): string {
return '1';
}
export function foo2(): object {
return Object.create(null) as Record<string, unknown>;
}
export const foo3 = (): object[] => [];
export const foo4 = (): string[] => ['a'];
export function assignability1(): Set<string> {
return new Set<string>(['foo']);
} export function foo1(): string {
return '1' as any;
}
export function foo2(): string {
return Object.create(null) as any;
}
export const foo3 = (): object[] => [] as any;
export const foo4 = (): string[] => ['a'] as any;
export function assignability1(): Set<string> {
return new Set<string>(['foo']) as any;
} plugin:@typescript-eslint/recommended plugin:@typescript-eslint/all
For details about how to configure Code Linter check rules, see Code Linter.