|
| 1 | +/** |
| 2 | + * @author Yosuke Ota |
| 3 | + * See LICENSE file in root directory for full license. |
| 4 | + */ |
| 5 | +'use strict' |
| 6 | + |
| 7 | +const RuleTester = require('eslint').RuleTester |
| 8 | +const rule = require('../../../lib/rules/object-shorthand') |
| 9 | + |
| 10 | +const tester = new RuleTester({ |
| 11 | + parser: require.resolve('vue-eslint-parser'), |
| 12 | + parserOptions: { |
| 13 | + ecmaVersion: 2020, |
| 14 | + sourceType: 'module' |
| 15 | + } |
| 16 | +}) |
| 17 | + |
| 18 | +tester.run('object-shorthand', rule, { |
| 19 | + valid: [ |
| 20 | + { |
| 21 | + filename: 'test.vue', |
| 22 | + code: ` |
| 23 | + <template> |
| 24 | + <div :style="{height}"></div> |
| 25 | + </template> |
| 26 | + ` |
| 27 | + }, |
| 28 | + { |
| 29 | + filename: 'test.vue', |
| 30 | + code: ` |
| 31 | + <template> |
| 32 | + <div :style="{height: height}"></div> |
| 33 | + </template> |
| 34 | + `, |
| 35 | + options: ['never'] |
| 36 | + } |
| 37 | + ], |
| 38 | + invalid: [ |
| 39 | + { |
| 40 | + filename: 'test.vue', |
| 41 | + code: ` |
| 42 | + <template> |
| 43 | + <div :style="{height: height}"></div> |
| 44 | + </template> |
| 45 | + `, |
| 46 | + output: ` |
| 47 | + <template> |
| 48 | + <div :style="{height}"></div> |
| 49 | + </template> |
| 50 | + `, |
| 51 | + errors: [ |
| 52 | + { |
| 53 | + message: 'Expected property shorthand.', |
| 54 | + line: 3, |
| 55 | + column: 23 |
| 56 | + } |
| 57 | + ] |
| 58 | + }, |
| 59 | + { |
| 60 | + filename: 'test.vue', |
| 61 | + code: ` |
| 62 | + <template> |
| 63 | + <div :style="{height}"></div> |
| 64 | + </template> |
| 65 | + `, |
| 66 | + output: ` |
| 67 | + <template> |
| 68 | + <div :style="{height: height}"></div> |
| 69 | + </template> |
| 70 | + `, |
| 71 | + options: ['never'], |
| 72 | + errors: [ |
| 73 | + { |
| 74 | + message: 'Expected longform property syntax.', |
| 75 | + line: 3, |
| 76 | + column: 23 |
| 77 | + } |
| 78 | + ] |
| 79 | + } |
| 80 | + ] |
| 81 | +}) |
0 commit comments