-
-
Notifications
You must be signed in to change notification settings - Fork 681
/
Copy pathautofix.js
87 lines (81 loc) · 2.02 KB
/
autofix.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* @author Yosuke Ota <https://github.com/ota-meshi>
* See LICENSE file in root directory for full license.
*/
'use strict'
const Linter = require('eslint').Linter
const chai = require('chai')
const rules = require('../..').rules
const assert = chai.assert
const baseConfig = {
parser: 'vue-eslint-parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true
}
}
}
describe('Complex autofix test cases', () => {
const linter = new Linter()
for (const key of Object.keys(rules)) {
const ruleId = `vue/${key}`
linter.defineRule(ruleId, rules[key])
}
// https://github.com/vuejs/eslint-plugin-vue/issues/566
describe('Autofix of `vue/order-in-components` and `comma-dangle` should not conflict.', () => {
const config = Object.assign({}, baseConfig, { 'rules': {
'vue/order-in-components': ['error'],
'comma-dangle': ['error', 'always']
}})
it('Even if set comma-dangle:always, the output should be as expected.', () => {
const code = `
<script>
export default {
data() {
},
name: 'burger'
};
</script>`
const output = `
<script>
export default {
name: 'burger',
data() {
},
};
</script>`
assert.equal(
linter.verifyAndFix(code, config, 'test.vue').output,
output
)
})
it('Even if include comments, the output should be as expected.', () => {
const code = `
<script>
export default {
/**data*/
data() {
}/*after data*/,
/**name*/
name: 'burger'/*after name*/
};
</script>`
const output = `
<script>
export default {
/**name*/
name: 'burger',
/**data*/
data() {
},/*after data*//*after name*/
};
</script>`
assert.equal(
linter.verifyAndFix(code, config, 'test.vue').output,
output
)
})
})
})