|
| 1 | +export default { |
| 2 | + invalid: [ |
| 3 | + { |
| 4 | + code: 'function foo(bar: "A" | "B") {}', |
| 5 | + errors: [{message: 'All union types must be declared with named type alias.'}] |
| 6 | + }, |
| 7 | + { |
| 8 | + code: 'const foo: "A" | "B" = "A";', |
| 9 | + errors: [{message: 'All union types must be declared with named type alias.'}] |
| 10 | + }, |
| 11 | + { |
| 12 | + code: 'type Foo = { bar: "A" | "B" };', |
| 13 | + errors: [{message: 'All union types must be declared with named type alias.'}] |
| 14 | + }, |
| 15 | + { |
| 16 | + code: 'function foo(bar: { n: number } | { s: string }) {}', |
| 17 | + errors: [{message: 'All union types must be declared with named type alias.'}] |
| 18 | + }, |
| 19 | + { |
| 20 | + code: 'function foo(bar: { n: number } & { s: string }) {}', |
| 21 | + errors: [{message: 'All intersection types must be declared with named type alias.'}] |
| 22 | + }, |
| 23 | + { |
| 24 | + code: 'const foo: { n: number } & { s: string } = { n: 0, s: "" };', |
| 25 | + errors: [{message: 'All intersection types must be declared with named type alias.'}] |
| 26 | + }, |
| 27 | + { |
| 28 | + code: 'type Foo = { bar: { n: number } & { s: string } };', |
| 29 | + errors: [{message: 'All intersection types must be declared with named type alias.'}] |
| 30 | + }, |
| 31 | + { |
| 32 | + code: 'function foo(bar: { n: number } & { s: string }) {}', |
| 33 | + errors: [{message: 'All intersection types must be declared with named type alias.'}] |
| 34 | + } |
| 35 | + ], |
| 36 | + misconfigured: [ |
| 37 | + { |
| 38 | + errors: [ |
| 39 | + { |
| 40 | + data: 'sometimes', |
| 41 | + dataPath: '[0]', |
| 42 | + keyword: 'enum', |
| 43 | + message: 'should be equal to one of the allowed values', |
| 44 | + params: { |
| 45 | + allowedValues: [ |
| 46 | + 'always', |
| 47 | + 'never' |
| 48 | + ] |
| 49 | + }, |
| 50 | + parentSchema: { |
| 51 | + enum: [ |
| 52 | + 'always', |
| 53 | + 'never' |
| 54 | + ], |
| 55 | + type: 'string' |
| 56 | + }, |
| 57 | + schema: [ |
| 58 | + 'always', |
| 59 | + 'never' |
| 60 | + ], |
| 61 | + schemaPath: '#/items/0/enum' |
| 62 | + } |
| 63 | + ], |
| 64 | + options: ['sometimes'] |
| 65 | + } |
| 66 | + ], |
| 67 | + valid: [ |
| 68 | + { |
| 69 | + code: 'type Foo = "A" | "B";' |
| 70 | + }, |
| 71 | + { |
| 72 | + code: 'type Bar = "A" | "B"; function foo(bar: Bar) {}' |
| 73 | + }, |
| 74 | + { |
| 75 | + code: 'type Foo = { disjoint: "A", n: number } | { disjoint: "B", s: string };' |
| 76 | + }, |
| 77 | + { |
| 78 | + code: 'type Foo = { n: number } & { s: string };' |
| 79 | + }, |
| 80 | + { |
| 81 | + code: 'type Bar = { n: number } & { s: string }; function foo(bar: Bar) {}' |
| 82 | + }, |
| 83 | + { |
| 84 | + code: 'function foo(bar: "A" | "B") {}', |
| 85 | + options: ['never'] |
| 86 | + }, |
| 87 | + { |
| 88 | + code: 'function foo(bar: { n: number } & { s: string }) {}', |
| 89 | + options: ['never'] |
| 90 | + } |
| 91 | + ] |
| 92 | +}; |
0 commit comments