|
| 1 | +export default { |
| 2 | + invalid: [ |
| 3 | + { |
| 4 | + code: 'type X = (?string)[]', |
| 5 | + errors: [{message: 'Use "Array<?string>", not "(?string)[]"'}], |
| 6 | + output: 'type X = Array<?string>' |
| 7 | + }, |
| 8 | + { |
| 9 | + code: 'type X = (?string)[]', |
| 10 | + errors: [{message: 'Use "Array<?string>", not "(?string)[]"'}], |
| 11 | + options: ['verbose'], |
| 12 | + output: 'type X = Array<?string>' |
| 13 | + }, |
| 14 | + { |
| 15 | + code: 'type X = Array<?string>', |
| 16 | + errors: [{message: 'Use "(?string)[]", not "Array<?string>"'}], |
| 17 | + options: ['shorthand'], |
| 18 | + output: 'type X = (?string)[]' |
| 19 | + }, |
| 20 | + { |
| 21 | + code: 'type X = Array<{foo: string}>', |
| 22 | + errors: [{message: 'Use "{foo: string}[]", not "Array<{foo: string}>"'}], |
| 23 | + options: ['shorthand'], |
| 24 | + output: 'type X = {foo: string}[]' |
| 25 | + }, |
| 26 | + { |
| 27 | + code: 'type X = (string | number)[]', |
| 28 | + errors: [{message: 'Use "Array<string | number>", not "(string | number)[]"'}], |
| 29 | + output: 'type X = Array<string | number>' |
| 30 | + }, |
| 31 | + { |
| 32 | + code: 'type X = (string & number)[]', |
| 33 | + errors: [{message: 'Use "Array<string & number>", not "(string & number)[]"'}], |
| 34 | + output: 'type X = Array<string & number>' |
| 35 | + }, |
| 36 | + { |
| 37 | + code: 'type X = [string, number][]', |
| 38 | + errors: [{message: 'Use "Array<[string, number]>", not "[string, number][]"'}], |
| 39 | + output: 'type X = Array<[string, number]>' |
| 40 | + }, |
| 41 | + { |
| 42 | + code: 'type X = {foo: string}[]', |
| 43 | + errors: [{message: 'Use "Array<{foo: string}>", not "{foo: string}[]"'}], |
| 44 | + output: 'type X = Array<{foo: string}>' |
| 45 | + }, |
| 46 | + { |
| 47 | + code: 'type X = (string => number)[]', |
| 48 | + errors: [{message: 'Use "Array<string => number>", not "(string => number)[]"'}], |
| 49 | + output: 'type X = Array<string => number>' |
| 50 | + }, |
| 51 | + { |
| 52 | + code: 'type X = {\n foo: string,\n bar: number\n}[]', |
| 53 | + errors: [{message: 'Use "Array<{ foo: string, bar: number }>", not "{ foo: string, bar: number }[]"'}], |
| 54 | + output: 'type X = Array<{\n foo: string,\n bar: number\n}>' |
| 55 | + }, |
| 56 | + { |
| 57 | + code: 'type X = {\n foo: string,\n bar: number,\n quo: boolean,\n hey: Date\n}[]', |
| 58 | + errors: [{message: 'Use "Array<Type>", not "Type[]"'}], |
| 59 | + output: 'type X = Array<{\n foo: string,\n bar: number,\n quo: boolean,\n hey: Date\n}>' |
| 60 | + } |
| 61 | + ], |
| 62 | + misconfigured: [ |
| 63 | + { |
| 64 | + errors: [ |
| 65 | + { |
| 66 | + data: 'normal', |
| 67 | + dataPath: '[0]', |
| 68 | + keyword: 'enum', |
| 69 | + message: 'should be equal to one of the allowed values', |
| 70 | + params: { |
| 71 | + allowedValues: [ |
| 72 | + 'verbose', |
| 73 | + 'shorthand' |
| 74 | + ] |
| 75 | + }, |
| 76 | + parentSchema: { |
| 77 | + enum: [ |
| 78 | + 'verbose', |
| 79 | + 'shorthand' |
| 80 | + ], |
| 81 | + type: 'string' |
| 82 | + }, |
| 83 | + schema: [ |
| 84 | + 'verbose', |
| 85 | + 'shorthand' |
| 86 | + ], |
| 87 | + schemaPath: '#/items/0/enum' |
| 88 | + } |
| 89 | + ], |
| 90 | + options: ['normal'] |
| 91 | + } |
| 92 | + ], |
| 93 | + valid: [ |
| 94 | + { |
| 95 | + code: 'type X = Array<?string>' |
| 96 | + }, |
| 97 | + { |
| 98 | + code: 'type X = Array<?string>', |
| 99 | + options: ['verbose'] |
| 100 | + }, |
| 101 | + { |
| 102 | + code: 'type X = (?string)[]', |
| 103 | + options: ['shorthand'] |
| 104 | + }, |
| 105 | + { |
| 106 | + code: 'type X = Array<string>', |
| 107 | + options: ['shorthand'] |
| 108 | + }, |
| 109 | + { |
| 110 | + code: 'type X = Array<?string>', |
| 111 | + options: ['shorthand'], |
| 112 | + settings: { |
| 113 | + flowtype: { |
| 114 | + onlyFilesWithFlowAnnotation: true |
| 115 | + } |
| 116 | + } |
| 117 | + } |
| 118 | + ] |
| 119 | +}; |
0 commit comments