eslint-plugin-crisp 1.0.59 → 1.0.61

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/index.js CHANGED
@@ -36,6 +36,7 @@ module.exports = {
36
36
  "vue-header-check": require("./rules/vue-header-check"),
37
37
  "vue-html-quotes": require("./rules/vue-html-quotes"),
38
38
  "vue-no-regex-data": require("./rules/vue-no-regex-data"),
39
- "vue-props-declaration-order": require("./rules/vue-props-declaration-order")
39
+ "vue-props-declaration-order": require("./rules/vue-props-declaration-order"),
40
+ "vue-props-declaration-multiline": require("./rules/vue-props-declaration-multiline")
40
41
  }
41
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-crisp",
3
- "version": "1.0.59",
3
+ "version": "1.0.61",
4
4
  "description": "Custom ESLint Rules for Crisp",
5
5
  "author": "Crisp IM SAS",
6
6
  "main": "index.js",
@@ -128,6 +128,14 @@ module.exports = {
128
128
  "avoidEscape": true, "allowTemplateLiterals": true
129
129
  }
130
130
  ],
131
+ "no-restricted-syntax": [
132
+ "error",
133
+
134
+ {
135
+ "selector": "SwitchCase > *.consequent[type!='BlockStatement']",
136
+ "message": "Switch cases without blocks are disallowed."
137
+ },
138
+ ],
131
139
 
132
140
  // Crisp JS rules
133
141
  "crisp/enforce-optional": "error",
@@ -230,6 +238,7 @@ module.exports = {
230
238
  "vue/html-quotes": "off",
231
239
  "vue/no-v-html": "off",
232
240
  "vue/prefer-true-attribute-shorthand": "error",
241
+ "vue/require-name-property": "error",
233
242
  "vue/comma-dangle": "error",
234
243
  "vue/eqeqeq": "error",
235
244
  "vue/key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
@@ -313,6 +322,7 @@ module.exports = {
313
322
  "crisp/vue-header-check": "error",
314
323
  "crisp/vue-html-quotes": "error",
315
324
  "crisp/vue-no-regex-data": "error",
325
+ "crisp/vue-props-declaration-multiline": "error",
316
326
  "crisp/vue-props-declaration-order": "error"
317
327
  }
318
328
  }
@@ -0,0 +1,46 @@
1
+ module.exports = {
2
+ meta: {
3
+ type: "suggestion",
4
+ docs: {
5
+ description: "enforce multi-line declaration for Vue props",
6
+ category: "Stylistic Issues",
7
+ recommended: false,
8
+ },
9
+ fixable: "code",
10
+ schema: [], // no options
11
+ },
12
+
13
+ create(context) {
14
+ return {
15
+ 'ExportDefaultDeclaration Property[key.name="props"] ObjectExpression'(node) {
16
+ node.properties.forEach(prop => {
17
+ // Ensuring we only target the top-level prop definitions
18
+ if (prop.value.type === "ObjectExpression") {
19
+ const propDefinition = prop.value;
20
+
21
+ // Check if the prop definition is on a single line
22
+ if (propDefinition.loc.start.line === propDefinition.loc.end.line) {
23
+ context.report({
24
+ node: prop,
25
+ message: "Props should be declared in multiple lines.",
26
+
27
+ fix(fixer) {
28
+ const sourceCode = context.getSourceCode();
29
+ const propText = sourceCode.getText(propDefinition);
30
+
31
+ // Construct the multi-line version of the prop
32
+ const expandedProp = propText
33
+ .replace("{", "{\n")
34
+ .replace("}", "\n}")
35
+ .replace(/, /g, ",\n");
36
+
37
+ return fixer.replaceText(propDefinition, expandedProp);
38
+ }
39
+ });
40
+ }
41
+ }
42
+ });
43
+ }
44
+ };
45
+ }
46
+ };