|
| 1 | +import { typeScriptTester as tester } from '../../../test-utils'; |
| 2 | +import { noSuppressXCSS } from '../index'; |
| 3 | + |
| 4 | +tester.run('no-styled-tagged-template-expression', noSuppressXCSS, { |
| 5 | + valid: [ |
| 6 | + ` |
| 7 | + <Component xcss={{ fill: 'red' }} /> |
| 8 | + `, |
| 9 | + ` |
| 10 | + <Component innerXcss={{ fill: 'red' }} /> |
| 11 | + `, |
| 12 | + ` |
| 13 | + // @ts-expect-error |
| 14 | + function Foo() { |
| 15 | + // @ts-ignore |
| 16 | + return ( |
| 17 | + <> |
| 18 | + <Component xcss={{ fill: 'red' }} /> |
| 19 | + </> |
| 20 | + ); |
| 21 | + } |
| 22 | + `, |
| 23 | + ], |
| 24 | + invalid: [ |
| 25 | + { |
| 26 | + code: ` |
| 27 | + <Component |
| 28 | + xcss={{ |
| 29 | + // @ts-expect-error |
| 30 | + fill: 'red' |
| 31 | + }} |
| 32 | + /> |
| 33 | + `, |
| 34 | + errors: [{ messageId: 'no-suppress-xcss' }], |
| 35 | + }, |
| 36 | + { |
| 37 | + code: ` |
| 38 | + <Component |
| 39 | + xcss={{ |
| 40 | + // @ts-ignore |
| 41 | + fill: 'red' |
| 42 | + }} |
| 43 | + /> |
| 44 | + `, |
| 45 | + errors: [{ messageId: 'no-suppress-xcss' }], |
| 46 | + }, |
| 47 | + { |
| 48 | + code: ` |
| 49 | + <Component |
| 50 | + xcss={{ |
| 51 | + // @ts-nocheck |
| 52 | + fill: 'red' |
| 53 | + }} |
| 54 | + /> |
| 55 | + `, |
| 56 | + errors: [{ messageId: 'no-suppress-xcss' }], |
| 57 | + }, |
| 58 | + { |
| 59 | + code: ` |
| 60 | + // @ts-expect-error |
| 61 | + <Component xcss={{ fill: 'red' }} /> |
| 62 | + `, |
| 63 | + errors: [{ messageId: 'no-suppress-xcss' }], |
| 64 | + }, |
| 65 | + { |
| 66 | + code: ` |
| 67 | + // @ts-expect-error |
| 68 | + <Component innerXcss={{ fill: 'red' }} /> |
| 69 | + `, |
| 70 | + errors: [{ messageId: 'no-suppress-xcss' }], |
| 71 | + }, |
| 72 | + { |
| 73 | + code: ` |
| 74 | + // @ts-ignore |
| 75 | + <Component xcss={{ fill: 'red' }} /> |
| 76 | + `, |
| 77 | + errors: [{ messageId: 'no-suppress-xcss' }], |
| 78 | + }, |
| 79 | + { |
| 80 | + code: ` |
| 81 | +
|
| 82 | + <Component |
| 83 | + // @ts-expect-error |
| 84 | + innerXcss={{ fill: 'red' }} |
| 85 | + /> |
| 86 | + `, |
| 87 | + errors: [{ messageId: 'no-suppress-xcss' }], |
| 88 | + }, |
| 89 | + { |
| 90 | + code: ` |
| 91 | +
|
| 92 | + <Component |
| 93 | + // @ts-ignore |
| 94 | + xcss={{ fill: 'red' }} |
| 95 | + /> |
| 96 | + `, |
| 97 | + errors: [{ messageId: 'no-suppress-xcss' }], |
| 98 | + }, |
| 99 | + { |
| 100 | + code: ` |
| 101 | +
|
| 102 | + <Component |
| 103 | + // @ts-nocheck |
| 104 | + xcss={{ fill: 'red' }} |
| 105 | + /> |
| 106 | + `, |
| 107 | + errors: [{ messageId: 'no-suppress-xcss' }], |
| 108 | + }, |
| 109 | + { |
| 110 | + code: ` |
| 111 | + // @ts-ignore |
| 112 | + <Component innerXcss={{ fill: 'red' }} /> |
| 113 | + `, |
| 114 | + errors: [{ messageId: 'no-suppress-xcss' }], |
| 115 | + }, |
| 116 | + { |
| 117 | + code: ` |
| 118 | + function Foo() { |
| 119 | + return ( |
| 120 | + <> |
| 121 | + {/* @ts-ignore */} |
| 122 | + <Component xcss={{ fill: 'red' }} /> |
| 123 | + </> |
| 124 | + ); |
| 125 | + } |
| 126 | + `, |
| 127 | + errors: [{ messageId: 'no-suppress-xcss' }], |
| 128 | + }, |
| 129 | + { |
| 130 | + code: ` |
| 131 | + function Foo() { |
| 132 | + return ( |
| 133 | + <> |
| 134 | + {/* @ts-expect-error */} |
| 135 | + <Component xcss={{ fill: 'red' }} /> |
| 136 | + </> |
| 137 | + ); |
| 138 | + } |
| 139 | + `, |
| 140 | + errors: [{ messageId: 'no-suppress-xcss' }], |
| 141 | + }, |
| 142 | + ], |
| 143 | +}); |
0 commit comments