-
-
Notifications
You must be signed in to change notification settings - Fork 669
/
script-setup.js
49 lines (43 loc) · 1.25 KB
/
script-setup.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
/**
* @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 parser = require('vue-eslint-parser')
const assert = require('assert')
const experimentalScriptSetupVars = require('../../lib/rules/experimental-script-setup-vars')
const baseConfig = {
parser: 'vue-eslint-parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module'
}
}
describe('script-setup test cases', () => {
const linter = new Linter()
linter.defineParser('vue-eslint-parser', parser)
linter.defineRule(
'vue/experimental-script-setup-vars',
experimentalScriptSetupVars
)
describe('temporary supports.', () => {
const config = Object.assign({}, baseConfig, {
globals: { console: false },
rules: {
'vue/experimental-script-setup-vars': 'error',
'no-undef': 'error'
}
})
it('should not be marked.', () => {
const code = `
<script setup="props, { emit }">
import { watchEffect } from 'vue'
watchEffect(() => console.log(props.msg))
emit('foo')
</script>`
const messages = linter.verify(code, config, 'test.vue')
assert.deepStrictEqual(messages, [])
})
})
})