eslint-plugin-crisp 1.0.11 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build.yml +0 -3
- package/index.js +1 -0
- package/package.json +3 -2
- package/recommended-vue.js +36 -2
- package/rules/vue-html-quotes.js +76 -0
package/index.js
CHANGED
|
@@ -28,6 +28,7 @@ module.exports = {
|
|
|
28
28
|
"two-lines-between-class-members": require("./rules/two-lines-between-class-members"),
|
|
29
29
|
"variable-names": require("./rules/variable-names"),
|
|
30
30
|
"align-consecutive-class-assignements": require("./rules/align-consecutive-class-assignements"),
|
|
31
|
+
"vue-html-quotes": require("./rules/vue-html-quotes"),
|
|
31
32
|
"vue-props-declaration-order": require("./rules/vue-props-declaration-order")
|
|
32
33
|
}
|
|
33
34
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-crisp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "Custom EsLint Rules for Crisp",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Crisp IM SAS",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"eslint": "8.45.0",
|
|
14
14
|
"eslint-plugin-vue": "8.5.0",
|
|
15
|
-
"eslint-plugin-vue-pug": "0.6.0"
|
|
15
|
+
"eslint-plugin-vue-pug": "0.6.0",
|
|
16
|
+
"vue-eslint-parser": "9.3.1"
|
|
16
17
|
}
|
|
17
18
|
}
|
package/recommended-vue.js
CHANGED
|
@@ -105,10 +105,43 @@ module.exports = {
|
|
|
105
105
|
"crisp/jsdocs-align-params": "error",
|
|
106
106
|
|
|
107
107
|
// General Vue rules
|
|
108
|
-
"vue/
|
|
108
|
+
"vue/no-v-html": "off",
|
|
109
|
+
"vue/html-quotes": "off",
|
|
110
|
+
"vue/component-tags-order": [
|
|
111
|
+
"error",
|
|
109
112
|
|
|
110
|
-
|
|
113
|
+
{
|
|
114
|
+
"order": [ "template", "script", "style" ]
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
"vue/attributes-order": [
|
|
118
|
+
"error",
|
|
111
119
|
|
|
120
|
+
{
|
|
121
|
+
order: [
|
|
122
|
+
"RENDER_MODIFIERS",
|
|
123
|
+
"CONDITIONALS",
|
|
124
|
+
"OTHER_DIRECTIVES",
|
|
125
|
+
"LIST_RENDERING",
|
|
126
|
+
"SLOT",
|
|
127
|
+
"TWO_WAY_BINDING",
|
|
128
|
+
"CONTENT",
|
|
129
|
+
"EVENTS",
|
|
130
|
+
"DEFINITION",
|
|
131
|
+
["GLOBAL", "UNIQUE", "OTHER_ATTR"]
|
|
132
|
+
],
|
|
133
|
+
"alphabetical": false
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
"vue/v-slot-style": [
|
|
137
|
+
"error",
|
|
138
|
+
|
|
139
|
+
{
|
|
140
|
+
"atComponent": "v-slot",
|
|
141
|
+
"default": "v-slot",
|
|
142
|
+
"named": "longform"
|
|
143
|
+
}
|
|
144
|
+
],
|
|
112
145
|
|
|
113
146
|
// Crisp JS rules
|
|
114
147
|
"crisp/header-check": "error",
|
|
@@ -130,6 +163,7 @@ module.exports = {
|
|
|
130
163
|
],
|
|
131
164
|
|
|
132
165
|
// Crisp Vue rules
|
|
166
|
+
"crisp/vue-html-quotes": "error",
|
|
133
167
|
"crisp/vue-props-declaration-order": "error"
|
|
134
168
|
},
|
|
135
169
|
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
meta: {
|
|
3
|
+
type: "layout",
|
|
4
|
+
docs: {
|
|
5
|
+
description: "enforce quotes style of HTML attributes"
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
schema: [
|
|
9
|
+
{ enum: ["double", "single"] },
|
|
10
|
+
{
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
avoidEscape: {
|
|
14
|
+
type: "boolean"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
additionalProperties: false
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
|
|
21
|
+
messages: {
|
|
22
|
+
expected: "Expected to be enclosed by {{kind}}."
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
create(context) {
|
|
27
|
+
const sourceCode = context.getSourceCode()
|
|
28
|
+
const double = context.options[0] !== "single"
|
|
29
|
+
const avoidEscape =
|
|
30
|
+
context.options[1] && context.options[1].avoidEscape === true
|
|
31
|
+
const quoteChar = double ? '"' : "'"
|
|
32
|
+
const quoteName = double ? "double quotes" : "single quotes"
|
|
33
|
+
|
|
34
|
+
return context.parserServices.defineTemplateBodyVisitor(
|
|
35
|
+
{
|
|
36
|
+
"VAttribute[value!=null]"(node) {
|
|
37
|
+
const text = sourceCode.getText(node.value)
|
|
38
|
+
const firstChar = text[0]
|
|
39
|
+
|
|
40
|
+
if (firstChar !== quoteChar) {
|
|
41
|
+
const contentText = text.slice(1, -1);
|
|
42
|
+
|
|
43
|
+
const quoted = firstChar === "'" || firstChar === '"';
|
|
44
|
+
|
|
45
|
+
if (avoidEscape && quoted) {
|
|
46
|
+
if (contentText.includes(quoteChar)) {
|
|
47
|
+
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Attribute value is an object or an array
|
|
53
|
+
if (firstChar === "[" || firstChar === "{") {
|
|
54
|
+
// Matching quote in the object
|
|
55
|
+
if (contentText.includes(quoteChar)) {
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// No quotes in the object or array
|
|
60
|
+
if (!contentText.includes("'") && !contentText.includes('"')) {
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
context.report({
|
|
66
|
+
node: node.value,
|
|
67
|
+
loc: node.value.loc,
|
|
68
|
+
messageId: "expected",
|
|
69
|
+
data: { kind: quoteName }
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
}
|