|
| 1 | +import { typeScriptTester as tester } from '../../../test-utils'; |
| 2 | +import { localCXXCSSRule } from '../index'; |
| 3 | + |
| 4 | +tester.run('local-cx-xcss', localCXXCSSRule, { |
| 5 | + valid: [ |
| 6 | + ` |
| 7 | + import { cx } from '@compiled/react'; |
| 8 | +
|
| 9 | + <Component xcss={cx({})} /> |
| 10 | + `, |
| 11 | + ` |
| 12 | + import { cx } from '@compiled/react'; |
| 13 | +
|
| 14 | + <Component innerXcss={cx({})} /> |
| 15 | + `, |
| 16 | + ` |
| 17 | + import { cx, cssMap } from '@compiled/react'; |
| 18 | +
|
| 19 | + const styles = cssMap({ |
| 20 | + text: { color: 'red' }, |
| 21 | + bg: { background: 'blue' }, |
| 22 | + }); |
| 23 | +
|
| 24 | + <Button innerXcss={cx(styles.text, styles.bg)} />; |
| 25 | + `, |
| 26 | + ` |
| 27 | + // Ignore cx usage not from compiled |
| 28 | + const styles = cssMap({ |
| 29 | + text: { color: 'red' }, |
| 30 | + bg: { background: 'blue' }, |
| 31 | + }); |
| 32 | +
|
| 33 | + const joinedStyles = cx(styles.text, styles.bg); |
| 34 | +
|
| 35 | + <Button xcss={joinedStyles} />; |
| 36 | + `, |
| 37 | + ` |
| 38 | + // Ignore cx usage not from compiled |
| 39 | + const styles = cx({}); |
| 40 | +
|
| 41 | + <Component xcss={styles} /> |
| 42 | + `, |
| 43 | + ], |
| 44 | + invalid: [ |
| 45 | + { |
| 46 | + code: ` |
| 47 | + import { cx } from '@compiled/react'; |
| 48 | + const styles = cx({}); |
| 49 | +
|
| 50 | + <Component xcss={styles} /> |
| 51 | + `, |
| 52 | + errors: [{ messageId: 'local-cx-xcss' }], |
| 53 | + }, |
| 54 | + { |
| 55 | + code: ` |
| 56 | + import { cx, cssMap } from '@compiled/react'; |
| 57 | +
|
| 58 | + const styles = cssMap({ |
| 59 | + text: { color: 'red' }, |
| 60 | + bg: { background: 'blue' }, |
| 61 | + }); |
| 62 | +
|
| 63 | + const joinedStyles = cx(styles.text, styles.bg); |
| 64 | +
|
| 65 | + <Button xcss={joinedStyles} />; |
| 66 | + `, |
| 67 | + errors: [{ messageId: 'local-cx-xcss' }], |
| 68 | + }, |
| 69 | + { |
| 70 | + code: ` |
| 71 | + import { cx } from '@compiled/react'; |
| 72 | + const styles = cx({}); |
| 73 | +
|
| 74 | + <Component innerXcss={styles} /> |
| 75 | + `, |
| 76 | + errors: [{ messageId: 'local-cx-xcss' }], |
| 77 | + }, |
| 78 | + { |
| 79 | + code: ` |
| 80 | + import { cx, cssMap} from '@compiled/react'; |
| 81 | +
|
| 82 | + const styles = cssMap({ |
| 83 | + text: { color: 'red' }, |
| 84 | + bg: { background: 'blue' }, |
| 85 | + }); |
| 86 | +
|
| 87 | + const joinedStyles = cx(styles.text, styles.bg); |
| 88 | +
|
| 89 | + <Button innerXcss={joinedStyles} />; |
| 90 | + `, |
| 91 | + errors: [{ messageId: 'local-cx-xcss' }], |
| 92 | + }, |
| 93 | + ], |
| 94 | +}); |
0 commit comments