|
| 1 | +import type { RuleConfig } from '../rule-config'; |
| 2 | + |
| 3 | +/** |
| 4 | + * Option. |
| 5 | + */ |
| 6 | +export type ConsistentTypeAssertionsOption = |
| 7 | + | { |
| 8 | + /* Empty option */ |
| 9 | + } |
| 10 | + | { |
| 11 | + /** |
| 12 | + * This option defines the expected assertion style. |
| 13 | + * |
| 14 | + * @default 'as' |
| 15 | + * |
| 16 | + * @see [assertionStyle](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-assertions.md#assertionstyle) |
| 17 | + */ |
| 18 | + assertionStyle: 'as' | 'angle-bracket'; |
| 19 | + /** |
| 20 | + * Always prefer `const x: T = { ... };` to `const x = { ... } as T;` (or similar with angle brackets). |
| 21 | + * |
| 22 | + * The type assertion in the latter case is either unnecessary or will probably hide an error. |
| 23 | + * |
| 24 | + * @default 'allow' |
| 25 | + * |
| 26 | + * @see [objectLiteralTypeAssertions](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-assertions.md#objectliteraltypeassertions) |
| 27 | + */ |
| 28 | + objectLiteralTypeAssertions?: 'allow' | 'allow-as-parameter' | 'never'; |
| 29 | + } |
| 30 | + | { |
| 31 | + /** |
| 32 | + * This option defines the expected assertion style. |
| 33 | + * |
| 34 | + * @see [assertionStyle](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-assertions.md#assertionstyle) |
| 35 | + */ |
| 36 | + assertionStyle: 'never'; |
| 37 | + }; |
| 38 | + |
| 39 | +/** |
| 40 | + * Options. |
| 41 | + */ |
| 42 | +export type ConsistentTypeAssertionsOptions = [ConsistentTypeAssertionsOption?]; |
| 43 | + |
| 44 | +/** |
| 45 | + * Enforces consistent usage of type assertions. |
| 46 | + * |
| 47 | + * @see [consistent-type-assertions](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-assertions.md) |
| 48 | + */ |
| 49 | +export type ConsistentTypeAssertionsRuleConfig = RuleConfig<ConsistentTypeAssertionsOptions>; |
| 50 | + |
| 51 | +/** |
| 52 | + * Enforces consistent usage of type assertions. |
| 53 | + * |
| 54 | + * @see [consistent-type-assertions](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-assertions.md) |
| 55 | + */ |
| 56 | +export interface ConsistentTypeAssertionsRule { |
| 57 | + /** |
| 58 | + * Enforces consistent usage of type assertions. |
| 59 | + * |
| 60 | + * @see [consistent-type-assertions](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-assertions.md) |
| 61 | + */ |
| 62 | + '@typescript-eslint/consistent-type-assertions': ConsistentTypeAssertionsRuleConfig; |
| 63 | +} |
0 commit comments