File tree 4 files changed +83
-0
lines changed
tests/lib/rules/no-unsupported-features
4 files changed +83
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ The `"ignores"` option accepts an array of the following strings.
32
32
- Vue.js 3.1.0+
33
33
- ` "is-attribute-with-vue-prefix" ` ... [ ` is ` attribute with ` vue: ` prefix] ( https://v3.vuejs.org/api/special-attributes.html#is )
34
34
- Vue.js 3.0.0+
35
+ - ` "script-setup" ` ... [ ` <script setup> ` ] [ Vue RFCs - 0040-script-setup ]
35
36
- ` "v-model-argument" ` ... [ argument on ` v-model ` ] [ Vue RFCs - 0005-replace-v-bind-sync-with-v-model-argument ]
36
37
- ` "v-model-custom-modifiers" ` ... [ custom modifiers on ` v-model ` ] [ Vue RFCs - 0011-v-model-api-change ]
37
38
- ` "v-is" ` ... [ v-is] ( https://v3.vuejs.org/api/directives.html#v-is ) directive.
@@ -105,13 +106,15 @@ The `"ignores"` option accepts an array of the following strings.
105
106
- [ Vue RFCs - 0003-dynamic-directive-arguments]
106
107
- [ Vue RFCs - 0005-replace-v-bind-sync-with-v-model-argument]
107
108
- [ Vue RFCs - 0011-v-model-api-change]
109
+ - [ Vue RFCs - 0040-script-setup]
108
110
- [ Vue RFCs - v-bind .prop shorthand proposal]
109
111
110
112
[ Vue RFCs - 0001-new-slot-syntax ] : https://github.com/vuejs/rfcs/blob/master/active-rfcs/0001-new-slot-syntax.md
111
113
[ Vue RFCs - 0002-slot-syntax-shorthand ] : https://github.com/vuejs/rfcs/blob/master/active-rfcs/0002-slot-syntax-shorthand.md
112
114
[ Vue RFCs - 0003-dynamic-directive-arguments ] : https://github.com/vuejs/rfcs/blob/master/active-rfcs/0003-dynamic-directive-arguments.md
113
115
[ Vue RFCs - 0005-replace-v-bind-sync-with-v-model-argument ] : https://github.com/vuejs/rfcs/blob/master/active-rfcs/0005-replace-v-bind-sync-with-v-model-argument.md
114
116
[ Vue RFCs - 0011-v-model-api-change ] : https://github.com/vuejs/rfcs/blob/master/active-rfcs/0011-v-model-api-change.md
117
+ [ Vue RFCs - 0040-script-setup ] : https://github.com/vuejs/rfcs/blob/master/active-rfcs/0040-script-setup.md
115
118
116
119
[ Vue RFCs - v-bind .prop shorthand proposal ] : https://github.com/vuejs/rfcs/pull/18
117
120
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ const FEATURES = {
26
26
'v-model-argument' : require ( './syntaxes/v-model-argument' ) ,
27
27
'v-model-custom-modifiers' : require ( './syntaxes/v-model-custom-modifiers' ) ,
28
28
'v-is' : require ( './syntaxes/v-is' ) ,
29
+ 'script-setup' : require ( './syntaxes/script-setup' ) ,
29
30
// Vue.js 3.1.0+
30
31
'is-attribute-with-vue-prefix' : require ( './syntaxes/is-attribute-with-vue-prefix' )
31
32
}
@@ -100,6 +101,9 @@ module.exports = {
100
101
forbiddenVModelCustomModifiers :
101
102
'Custom modifiers on `v-model` are not supported until Vue.js "3.0.0".' ,
102
103
forbiddenVIs : '`v-is` are not supported until Vue.js "3.0.0".' ,
104
+ forbiddenScriptSetup :
105
+ '`<script setup>` are not supported until Vue.js "3.0.0".' ,
106
+ // Vue.js 3.1.0+
103
107
forbiddenIsAttributeWithVuePrefix :
104
108
'`is="vue:"` are not supported until Vue.js "3.1.0".'
105
109
}
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @author Yosuke Ota
3
+ * See LICENSE file in root directory for full license.
4
+ */
5
+ 'use strict'
6
+
7
+ const utils = require ( '../../utils' )
8
+
9
+ module . exports = {
10
+ supported : '>=3.0.0' ,
11
+ /** @param {RuleContext } context @returns {TemplateListener } */
12
+ createScriptVisitor ( context ) {
13
+ const scriptSetup = utils . getScriptSetupElement ( context )
14
+ if ( ! scriptSetup ) {
15
+ return { }
16
+ }
17
+ const reportNode =
18
+ utils . getAttribute ( scriptSetup , 'setup' ) || scriptSetup . startTag
19
+ return {
20
+ Program ( ) {
21
+ context . report ( {
22
+ node : reportNode ,
23
+ messageId : 'forbiddenScriptSetup'
24
+ } )
25
+ }
26
+ }
27
+ }
28
+ }
Original file line number Diff line number Diff line change
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/no-unsupported-features' )
9
+ const utils = require ( './utils' )
10
+
11
+ const buildOptions = utils . optionsBuilder ( 'script-setup' , '^3.0.0' )
12
+ const tester = new RuleTester ( {
13
+ parser : require . resolve ( 'vue-eslint-parser' ) ,
14
+ parserOptions : {
15
+ ecmaVersion : 2019
16
+ }
17
+ } )
18
+
19
+ tester . run ( 'no-unsupported-features/script-setup' , rule , {
20
+ valid : [
21
+ {
22
+ code : `
23
+ <script setup>
24
+ </script>` ,
25
+ options : buildOptions ( )
26
+ } ,
27
+ {
28
+ code : `
29
+ <script>
30
+ </script>` ,
31
+ options : buildOptions ( { version : '^2.6.0' } )
32
+ }
33
+ ] ,
34
+ invalid : [
35
+ {
36
+ code : `
37
+ <script setup>
38
+ </script>` ,
39
+ options : buildOptions ( { version : '^2.6.0' } ) ,
40
+ errors : [
41
+ {
42
+ message : '`<script setup>` are not supported until Vue.js "3.0.0".' ,
43
+ line : 2
44
+ }
45
+ ]
46
+ }
47
+ ]
48
+ } )
You can’t perform that action at this time.
0 commit comments