eslint-plugin-crisp 1.4.1 → 1.4.2

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
@@ -42,6 +42,7 @@ import ruleVueEmitsOrder from "./rules/vue-emits-order.js";
42
42
  import ruleVueHeaderCheck from "./rules/vue-header-check.js";
43
43
  import ruleVueHtmlIndent from "./rules/vue-html-indent.js";
44
44
  import ruleVueHtmlQuotes from "./rules/vue-html-quotes.js";
45
+ import ruleVueMethodsSeparator from "./rules/vue-methods-separator.js";
45
46
  import ruleVueNameProp from "./rules/vue-name-prop.js";
46
47
  import ruleVueNoRegexData from "./rules/vue-no-regex-data.js";
47
48
  import ruleVuePropsDeclarationLineBreak from "./rules/vue-props-declaration-line-break.js";
@@ -103,6 +104,7 @@ const plugin = {
103
104
  "vue-header-check": ruleVueHeaderCheck,
104
105
  "vue-html-indent": ruleVueHtmlIndent,
105
106
  "vue-html-quotes": ruleVueHtmlQuotes,
107
+ "vue-methods-separator": ruleVueMethodsSeparator,
106
108
  "vue-name-prop": ruleVueNameProp,
107
109
  "vue-no-regex-data": ruleVueNoRegexData,
108
110
  "vue-props-declaration-line-break": ruleVuePropsDeclarationLineBreak,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-crisp",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Custom ESLint Rules for Crisp",
5
5
  "author": "Crisp IM SAS",
6
6
  "main": "index.js",
@@ -377,6 +377,7 @@ export default function configRecommendedVue(pluginCrisp) {
377
377
  "crisp/vue-header-check": "error",
378
378
  "crisp/vue-html-indent": "error",
379
379
  "crisp/vue-html-quotes": "error",
380
+ "crisp/vue-methods-separator": "error",
380
381
  "crisp/vue-name-prop": "error",
381
382
  "crisp/vue-no-regex-data": "error",
382
383
  "crisp/vue-props-declaration-line-break": "error",
@@ -0,0 +1,46 @@
1
+ export default {
2
+ meta: {
3
+ type: "suggestion",
4
+ docs: {
5
+ description: "enforce at least one separator comment in Vue methods block",
6
+ category: "Stylistic Issues",
7
+ recommended: false
8
+ },
9
+ fixable: null,
10
+ schema: []
11
+ },
12
+
13
+ create(context) {
14
+ const SEPARATOR_PATTERN = /^--> (ACTIONS|HELPERS|EVENT LISTENERS) <--$/;
15
+
16
+ return {
17
+ 'ExportDefaultDeclaration Property[key.name="methods"]'(node) {
18
+ const properties = node.value.properties;
19
+
20
+ if (!properties || properties.length === 0) {
21
+ return;
22
+ }
23
+
24
+ const sourceCode = context.getSourceCode();
25
+ const comments = sourceCode.getCommentsInside(node);
26
+
27
+ const hasSeparator = comments.some((comment) => {
28
+ return (
29
+ comment.type === "Line" &&
30
+ SEPARATOR_PATTERN.test(comment.value.trim())
31
+ );
32
+ });
33
+
34
+ if (!hasSeparator) {
35
+ context.report({
36
+ node,
37
+ message:
38
+ "Methods block must contain at least one separator comment " +
39
+ "('// --> ACTIONS <--', '// --> HELPERS <--', " +
40
+ "or '// --> EVENT LISTENERS <--')"
41
+ });
42
+ }
43
+ }
44
+ };
45
+ }
46
+ };