|
| 1 | +/** |
| 2 | + * @author Yosuke Ota |
| 3 | + */ |
| 4 | +'use strict' |
| 5 | + |
| 6 | +const RuleTester = require('eslint').RuleTester |
| 7 | +const rule = require('../../../lib/rules/no-sparse-arrays') |
| 8 | + |
| 9 | +const tester = new RuleTester({ |
| 10 | + parser: require.resolve('vue-eslint-parser'), |
| 11 | + parserOptions: { ecmaVersion: 2015 } |
| 12 | +}) |
| 13 | + |
| 14 | +tester.run('no-sparse-arrays', rule, { |
| 15 | + valid: [ |
| 16 | + `<template> |
| 17 | + <div :class="['foo', 'bar']" /> |
| 18 | + </template>`, |
| 19 | + `<template> |
| 20 | + <div v-bind:[['foo'][0]]="bar" /> |
| 21 | + </template>` |
| 22 | + ], |
| 23 | + invalid: [ |
| 24 | + { |
| 25 | + code: ` |
| 26 | + <template> |
| 27 | + <div :class="[, 'foo', 'bar']" /> |
| 28 | + </template>`, |
| 29 | + errors: [ |
| 30 | + { |
| 31 | + message: 'Unexpected comma in middle of array.', |
| 32 | + line: 3, |
| 33 | + column: 22, |
| 34 | + endLine: 3, |
| 35 | + endColumn: 38 |
| 36 | + } |
| 37 | + ] |
| 38 | + }, |
| 39 | + { |
| 40 | + code: ` |
| 41 | + <template> |
| 42 | + <div v-bind:[[,'foo'][1]]="bar" /> |
| 43 | + </template>`, |
| 44 | + errors: [ |
| 45 | + { |
| 46 | + message: 'Unexpected comma in middle of array.', |
| 47 | + line: 3, |
| 48 | + column: 22, |
| 49 | + endLine: 3, |
| 50 | + endColumn: 30 |
| 51 | + } |
| 52 | + ] |
| 53 | + } |
| 54 | + ] |
| 55 | +}) |
0 commit comments