-
-
Notifications
You must be signed in to change notification settings - Fork 681
/
Copy pathkey-spacing.js
41 lines (38 loc) · 1.1 KB
/
key-spacing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* @author Toru Nagashima
*/
'use strict'
const RuleTester = require('../../eslint-compat').RuleTester
const rule = require('../../../lib/rules/key-spacing')
const tester = new RuleTester({
languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 2015 }
})
tester.run('key-spacing', rule, {
valid: [
'<template><div :attr="{a: 1}" /></template>',
'<template><div :[{a:1}[`a`]]="a" /></template>',
{
code: '<template><div :[{a:1}[`a`]]="a" /></template>',
options: [{ beforeColon: true }]
}
],
invalid: [
{
code: '<template><div :attr="{a :1}" /></template>',
output: '<template><div :attr="{a: 1}" /></template>',
errors: [
"Extra space after key 'a'.",
"Missing space before value for key 'a'."
]
},
{
code: '<template><div :[{a:1}[`a`]]="{a:1}[`a`]" /></template>',
output: '<template><div :[{a:1}[`a`]]="{a : 1}[`a`]" /></template>',
options: [{ beforeColon: true }],
errors: [
"Missing space after key 'a'.",
"Missing space before value for key 'a'."
]
}
]
})