|
| 1 | +import type { RuleConfig } from '../rule-config'; |
| 2 | + |
| 3 | +/** Signature. */ |
| 4 | +export type Signature = 'signature'; |
| 5 | +/** Visibility. */ |
| 6 | +export type Visibility = 'public' | 'protected' | 'private'; |
| 7 | +/** Static. */ |
| 8 | +export type Static = 'static'; |
| 9 | +/** Decorated. */ |
| 10 | +export type Decorated = 'decorated'; |
| 11 | +/** Instance. */ |
| 12 | +export type Instance = 'instance'; |
| 13 | +/** Abstract. */ |
| 14 | +export type Abstract = 'abstract'; |
| 15 | +/** Field. */ |
| 16 | +export type Field = 'field'; |
| 17 | +/** Constructor. */ |
| 18 | +export type Constructor = 'constructor'; |
| 19 | +/** Method. */ |
| 20 | +export type Method = 'method'; |
| 21 | + |
| 22 | +/** |
| 23 | + * @see [Member types (granular form)](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-ordering.md#member-types-granular-form) |
| 24 | + */ |
| 25 | +export type MemberTypes = |
| 26 | + // Index signature |
| 27 | + | Signature |
| 28 | + |
| 29 | + // Fields |
| 30 | + | `${Visibility}-${Static}-${Field}` |
| 31 | + | `${Visibility}-${Decorated}-${Field}` |
| 32 | + | `${Visibility}-${Instance}-${Field}` |
| 33 | + | `${Visibility}-${Abstract}-${Field}` |
| 34 | + | `${Visibility}-${Field}` |
| 35 | + | `${Static}-${Field}` |
| 36 | + | `${Instance}-${Field}` |
| 37 | + | `${Decorated}-${Field}` |
| 38 | + | `${Abstract}-${Field}` |
| 39 | + | Field |
| 40 | + |
| 41 | + // Constructors |
| 42 | + | `${Visibility}-${Constructor}` |
| 43 | + | Constructor |
| 44 | + |
| 45 | + // Methods |
| 46 | + | `${Visibility}-${Static}-${Method}` |
| 47 | + | `${Visibility}-${Decorated}-${Method}` |
| 48 | + | `${Visibility}-${Instance}-${Method}` |
| 49 | + | `${Visibility}-${Abstract}-${Method}` |
| 50 | + | `${Visibility}-${Method}` |
| 51 | + | `${Static}-${Method}` |
| 52 | + | `${Decorated}-${Method}` |
| 53 | + | `${Instance}-${Method}` |
| 54 | + | `${Abstract}-${Method}` |
| 55 | + | Method; |
| 56 | + |
| 57 | +/** |
| 58 | + * @see [TypeOptions](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-ordering.md#options) |
| 59 | + */ |
| 60 | +export type TypeOptions<T extends MemberTypes> = |
| 61 | + | MemberTypes[] |
| 62 | + | { memberTypes: Array<T> | 'never'; order?: 'alphabetically' | 'as-written' } |
| 63 | + | { order: 'alphabetically' }; |
| 64 | + |
| 65 | +/** |
| 66 | + * Option. |
| 67 | + */ |
| 68 | +export type MemberOrderingOption = { |
| 69 | + default?: TypeOptions<MemberTypes>; |
| 70 | + |
| 71 | + classes?: TypeOptions<MemberTypes>; |
| 72 | + classExpressions?: TypeOptions<MemberTypes>; |
| 73 | + |
| 74 | + interfaces?: TypeOptions<Signature | Field | Method | Constructor>; |
| 75 | + typeLiterals?: TypeOptions<Signature | Field | Method | Constructor>; |
| 76 | +}; |
| 77 | + |
| 78 | +/** |
| 79 | + * Options. |
| 80 | + */ |
| 81 | +export type MemberOrderingOptions = [MemberOrderingOption?]; |
| 82 | + |
| 83 | +/** |
| 84 | + * Require a consistent member declaration order. |
| 85 | + * |
| 86 | + * @see [member-ordering](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-ordering.md) |
| 87 | + */ |
| 88 | +export type MemberOrderingRuleConfig = RuleConfig<MemberOrderingOptions>; |
| 89 | + |
| 90 | +/** |
| 91 | + * Require a consistent member declaration order. |
| 92 | + * |
| 93 | + * @see [member-ordering](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-ordering.md) |
| 94 | + */ |
| 95 | +export interface MemberOrderingRule { |
| 96 | + /** |
| 97 | + * Require a consistent member declaration order. |
| 98 | + * |
| 99 | + * @see [member-ordering](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-ordering.md) |
| 100 | + */ |
| 101 | + '@typescript-eslint/member-ordering': MemberOrderingRuleConfig; |
| 102 | +} |
0 commit comments