eslint-plugin-crisp 1.0.60 → 1.0.62
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 +2 -1
- package/package.json +1 -1
- package/recommended-vue.js +1 -0
- package/rules/vue-props-declaration-multiline.js +46 -0
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
package/recommended-vue.js
CHANGED
|
@@ -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
|
+
};
|