@@ -8,6 +8,19 @@ const utils = require('../utils')
88// ------------------------------------------------------------------------------
99// Rule Definition
1010// ------------------------------------------------------------------------------
11+ const ATTRS = {
12+ DEFINITION : 'DEFINITION' ,
13+ LIST_RENDERING : 'LIST_RENDERING' ,
14+ CONDITIONALS : 'CONDITIONALS' ,
15+ RENDER_MODIFIERS : 'RENDER_MODIFIERS' ,
16+ GLOBAL : 'GLOBAL' ,
17+ UNIQUE : 'UNIQUE' ,
18+ TWO_WAY_BINDING : 'TWO_WAY_BINDING' ,
19+ OTHER_DIRECTIVES : 'OTHER_DIRECTIVES' ,
20+ OTHER_ATTR : 'OTHER_ATTR' ,
21+ EVENTS : 'EVENTS' ,
22+ CONTENT : 'CONTENT' ,
23+ } ;
1124
1225function getAttributeType ( attribute , sourceCode ) {
1326 const isBind = attribute . directive && attribute . key . name . name === 'bind'
@@ -17,31 +30,31 @@ function getAttributeType (attribute, sourceCode) {
1730
1831 if ( attribute . directive && ! isBind ) {
1932 if ( name === 'for' ) {
20- return ' LIST_RENDERING'
33+ return ATTRS . LIST_RENDERING
2134 } else if ( name === 'if' || name === 'else-if' || name === 'else' || name === 'show' || name === 'cloak' ) {
22- return ' CONDITIONALS'
35+ return ATTRS . CONDITIONALS
2336 } else if ( name === 'pre' || name === 'once' ) {
24- return ' RENDER_MODIFIERS'
37+ return ATTRS . RENDER_MODIFIERS
2538 } else if ( name === 'model' ) {
26- return ' TWO_WAY_BINDING'
39+ return ATTRS . TWO_WAY_BINDING
2740 } else if ( name === 'on' ) {
28- return ' EVENTS'
41+ return ATTRS . EVENTS
2942 } else if ( name === 'html' || name === 'text' ) {
30- return ' CONTENT'
43+ return ATTRS . CONTENT
3144 } else if ( name === 'slot' ) {
32- return ' UNIQUE'
45+ return ATTRS . UNIQUE
3346 } else {
34- return ' OTHER_DIRECTIVES'
47+ return ATTRS . OTHER_DIRECTIVES
3548 }
3649 } else {
3750 if ( name === 'is' ) {
38- return ' DEFINITION'
51+ return ATTRS . DEFINITION
3952 } else if ( name === 'id' ) {
40- return ' GLOBAL'
53+ return ATTRS . GLOBAL
4154 } else if ( name === 'ref' || name === 'key' || name === 'slot' || name === 'slot-scope' ) {
42- return ' UNIQUE'
55+ return ATTRS . UNIQUE
4356 } else {
44- return ' OTHER_ATTR'
57+ return ATTRS . OTHER_ATTR
4558 }
4659 }
4760}
@@ -53,7 +66,7 @@ function getPosition (attribute, attributePosition, sourceCode) {
5366
5467function create ( context ) {
5568 const sourceCode = context . getSourceCode ( )
56- let attributeOrder = [ ' DEFINITION' , ' LIST_RENDERING' , ' CONDITIONALS' , ' RENDER_MODIFIERS' , ' GLOBAL' , ' UNIQUE' , ' TWO_WAY_BINDING' , ' OTHER_DIRECTIVES' , ' OTHER_ATTR' , ' EVENTS' , ' CONTENT' ]
69+ let attributeOrder = [ ATTRS . DEFINITION , ATTRS . LIST_RENDERING , ATTRS . CONDITIONALS , ATTRS . RENDER_MODIFIERS , ATTRS . GLOBAL , ATTRS . UNIQUE , ATTRS . TWO_WAY_BINDING , ATTRS . OTHER_DIRECTIVES , ATTRS . OTHER_ATTR , ATTRS . EVENTS , ATTRS . CONTENT ]
5770 if ( context . options [ 0 ] && context . options [ 0 ] . order ) {
5871 attributeOrder = context . options [ 0 ] . order
5972 }
0 commit comments