eslint-plugin-crisp 1.0.65 → 1.0.67
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/package.json +1 -1
- package/recommended-vue.js +1 -0
- package/recommended.js +1 -0
- package/rules/jsdoc-align-params.js +1 -0
- package/rules/newline-after-switch-case.js +94 -0
- package/rules/one-space-after-operator.js +1 -0
- package/rules/ternary-parenthesis.js +1 -0
- package/rules/vue-computed-order.js +1 -0
- package/rules/vue-emits-order.js +1 -0
- package/rules/vue-header-check.js +1 -1
- package/rules/vue-props-declaration-order.js +1 -0
package/package.json
CHANGED
package/recommended-vue.js
CHANGED
|
@@ -144,6 +144,7 @@ module.exports = {
|
|
|
144
144
|
"crisp/methods-naming": "error",
|
|
145
145
|
"crisp/methods-ordering": "error",
|
|
146
146
|
"crisp/multiline-comment-end-backslash": "error",
|
|
147
|
+
"crisp/newline-after-switch-case": "error",
|
|
147
148
|
"crisp/no-async": "error",
|
|
148
149
|
"crisp/no-var-in-blocks": "error",
|
|
149
150
|
"crisp/no-useless-template-literals": "error",
|
package/recommended.js
CHANGED
|
@@ -148,6 +148,7 @@ module.exports = {
|
|
|
148
148
|
"crisp/methods-naming": "error",
|
|
149
149
|
"crisp/methods-ordering": "error",
|
|
150
150
|
"crisp/multiline-comment-end-backslash": "error",
|
|
151
|
+
"crisp/newline-after-switch-case": "error",
|
|
151
152
|
"crisp/no-async": "error",
|
|
152
153
|
"crisp/no-var-in-blocks": "error",
|
|
153
154
|
"crisp/no-space-in-optional-arguments": "error",
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
function getTokensWithNewlineBetween(sourceCode, startNode, endNode) {
|
|
2
|
+
const endLine = endNode.loc.start.line;
|
|
3
|
+
|
|
4
|
+
let next = startNode;
|
|
5
|
+
let previous = startNode;
|
|
6
|
+
|
|
7
|
+
do {
|
|
8
|
+
previous = next;
|
|
9
|
+
next = sourceCode.getTokenOrCommentAfter(next);
|
|
10
|
+
|
|
11
|
+
if (next.loc.start.line > previous.loc.end.line + 1) {
|
|
12
|
+
return [previous, next];
|
|
13
|
+
}
|
|
14
|
+
} while (next.loc.start.line < endLine);
|
|
15
|
+
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
meta: {
|
|
21
|
+
fixable: "whitespace",
|
|
22
|
+
schema: [] // no options
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
create: function newlineBetweenSwitchCase(context) {
|
|
26
|
+
let currentCodePath = null;
|
|
27
|
+
const sourceCode = context.getSourceCode();
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
onCodePathStart(codePath) {
|
|
31
|
+
currentCodePath = codePath;
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
onCodePathEnd() {
|
|
35
|
+
currentCodePath = currentCodePath.upper;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
"SwitchCase:exit": (node) => {
|
|
39
|
+
let lastNode = node.parent.cases[node.parent.cases.length - 1]
|
|
40
|
+
|
|
41
|
+
// Last case?
|
|
42
|
+
if (lastNode === node) {
|
|
43
|
+
// Ignore it
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let isFallthrough = false;
|
|
48
|
+
|
|
49
|
+
if (
|
|
50
|
+
node.consequent.length === 0 ||
|
|
51
|
+
currentCodePath.currentSegments.some((segment) => {
|
|
52
|
+
return segment.reachable;
|
|
53
|
+
})
|
|
54
|
+
) {
|
|
55
|
+
isFallthrough = true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const nextToken = sourceCode.getTokenAfter(node);
|
|
59
|
+
|
|
60
|
+
const tokensWithBlankLinesBetween = getTokensWithNewlineBetween(
|
|
61
|
+
sourceCode,
|
|
62
|
+
node,
|
|
63
|
+
nextToken
|
|
64
|
+
);
|
|
65
|
+
const hasBlankLinesBetween = Boolean(tokensWithBlankLinesBetween);
|
|
66
|
+
const isNewlineRequired = isFallthrough ? false : true;
|
|
67
|
+
|
|
68
|
+
if (hasBlankLinesBetween && !isNewlineRequired) {
|
|
69
|
+
context.report({
|
|
70
|
+
node,
|
|
71
|
+
message: "Extraneous newlines between switch cases.",
|
|
72
|
+
|
|
73
|
+
fix(fixer) {
|
|
74
|
+
const [previous, next] = tokensWithBlankLinesBetween;
|
|
75
|
+
return fixer.replaceTextRange(
|
|
76
|
+
[previous.range[1], next.range[0] - next.loc.start.column],
|
|
77
|
+
"\n"
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
} else if (!hasBlankLinesBetween && isNewlineRequired) {
|
|
82
|
+
context.report({
|
|
83
|
+
node,
|
|
84
|
+
message: "Newline required between switch cases.",
|
|
85
|
+
|
|
86
|
+
fix(fixer) {
|
|
87
|
+
return fixer.insertTextAfter(node, "\n");
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -32,6 +32,7 @@ module.exports = {
|
|
|
32
32
|
context.report({
|
|
33
33
|
node: operatorToken,
|
|
34
34
|
message: `There should be at least one space before and exactly one space after '${operatorName}'`,
|
|
35
|
+
|
|
35
36
|
fix(fixer) {
|
|
36
37
|
return fixer.replaceTextRange(
|
|
37
38
|
[sourceCode.getTokenBefore(operatorToken).range[1], sourceCode.getTokenAfter(operatorToken).range[0]],
|
package/rules/vue-emits-order.js
CHANGED
|
@@ -31,7 +31,7 @@ module.exports = {
|
|
|
31
31
|
// Check each tag individually
|
|
32
32
|
vueTags.forEach((tag, index) => {
|
|
33
33
|
const tagRegExp = new RegExp(`<${tag}`);
|
|
34
|
-
const headerRegExp = new RegExp(
|
|
34
|
+
const headerRegExp = new RegExp(`\\n\\n<!--\\s*\\*{70,73}\\s*\\n\\s{5}${headers[index]}\\s*\\n\\s*\\*{70,73}\\s*-->\\s*\\n\\n<${tag}`);
|
|
35
35
|
|
|
36
36
|
// If the tag exists without the corresponding header, report an error
|
|
37
37
|
if (tagRegExp.test(fileContent) && !headerRegExp.test(fileContent)) {
|