eslint-plugin-crisp 1.5.13 → 1.6.1

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.
Files changed (88) hide show
  1. package/.github/workflows/build.yml +6 -0
  2. package/README.md +2 -1
  3. package/index.js +2 -0
  4. package/package.json +9 -1
  5. package/recommended-vue.js +1 -0
  6. package/rules/align-comments.js +6 -3
  7. package/rules/constructor-variables.js +17 -2
  8. package/rules/header-check.js +8 -2
  9. package/rules/header-comments-check.js +10 -13
  10. package/rules/import-group-comment.js +13 -4
  11. package/rules/jsdoc-enforce-access.js +16 -10
  12. package/rules/no-extra-line-within-function.js +8 -5
  13. package/rules/no-short-parameters.js +1 -1
  14. package/rules/no-snake-case.js +0 -24
  15. package/rules/no-space-in-optional-arguments.js +5 -2
  16. package/rules/one-space-after-operator.js +59 -14
  17. package/rules/vue-header-check.js +4 -3
  18. package/rules/vue-no-regex-data.js +1 -2
  19. package/rules/vue-pinia-action-single-parameter.js +158 -0
  20. package/rules/vue-props-declaration-line-break.js +8 -3
  21. package/rules/vue-watch-handler.js +34 -1
  22. package/tests/fixtures/vue-header-check/missing-script-style/TestComponent.vue +19 -0
  23. package/tests/fixtures/vue-header-check/missing-template/TestComponent.vue +3 -0
  24. package/tests/fixtures/vue-header-check/valid/TestComponent.vue +27 -0
  25. package/tests/rule-tester.js +78 -0
  26. package/tests/rules/align-comments.test.js +25 -0
  27. package/tests/rules/align-consecutive-class-assignements.test.js +24 -0
  28. package/tests/rules/align-one-var.test.js +31 -0
  29. package/tests/rules/align-requires.test.js +27 -0
  30. package/tests/rules/arrow-block-newline.test.js +23 -0
  31. package/tests/rules/consecutive-line-comments.test.js +27 -0
  32. package/tests/rules/const.test.js +52 -0
  33. package/tests/rules/constructor-variables.test.js +52 -0
  34. package/tests/rules/enforce-optional.test.js +24 -0
  35. package/tests/rules/header-check.test.js +69 -0
  36. package/tests/rules/header-comments-check.test.js +89 -0
  37. package/tests/rules/import-group-comment.test.js +88 -0
  38. package/tests/rules/import-group-order.test.js +58 -0
  39. package/tests/rules/jsdoc-align-params.test.js +32 -0
  40. package/tests/rules/jsdoc-check-indentation.test.js +45 -0
  41. package/tests/rules/jsdoc-check-optional-params.test.js +40 -0
  42. package/tests/rules/jsdoc-description-length.test.js +60 -0
  43. package/tests/rules/jsdoc-description-multiline.test.js +34 -0
  44. package/tests/rules/jsdoc-enforce-access.test.js +66 -0
  45. package/tests/rules/jsdoc-enforce-classdesc.test.js +39 -0
  46. package/tests/rules/jsdoc-no-param-return.test.js +47 -0
  47. package/tests/rules/jsdoc-require-description-uppercase.test.js +52 -0
  48. package/tests/rules/methods-naming.test.js +70 -0
  49. package/tests/rules/methods-ordering.test.js +75 -0
  50. package/tests/rules/multiline-comment-end-backslash.test.js +52 -0
  51. package/tests/rules/newline-after-switch-case.test.js +75 -0
  52. package/tests/rules/no-async.test.js +57 -0
  53. package/tests/rules/no-extra-line-within-function.test.js +87 -0
  54. package/tests/rules/no-inline-function-in-ternary.test.js +59 -0
  55. package/tests/rules/no-short-parameters.test.js +62 -0
  56. package/tests/rules/no-snake-case.test.js +81 -0
  57. package/tests/rules/no-space-in-optional-arguments.test.js +40 -0
  58. package/tests/rules/no-useless-template-literals.test.js +36 -0
  59. package/tests/rules/no-var-in-blocks.test.js +40 -0
  60. package/tests/rules/one-space-after-operator.test.js +69 -0
  61. package/tests/rules/regex-in-constructor.test.js +40 -0
  62. package/tests/rules/ternary-parenthesis.test.js +34 -0
  63. package/tests/rules/two-lines-between-class-members.test.js +62 -0
  64. package/tests/rules/variable-names.test.js +60 -0
  65. package/tests/rules/vue-attribute-comma.test.js +43 -0
  66. package/tests/rules/vue-attribute-linebreak.test.js +54 -0
  67. package/tests/rules/vue-class-attribute-last.test.js +59 -0
  68. package/tests/rules/vue-class-shorthand-max-len.test.js +67 -0
  69. package/tests/rules/vue-computed-order.test.js +27 -0
  70. package/tests/rules/vue-data-comment.test.js +61 -0
  71. package/tests/rules/vue-define-component.test.js +45 -0
  72. package/tests/rules/vue-emits-order.test.js +27 -0
  73. package/tests/rules/vue-header-check.test.js +49 -0
  74. package/tests/rules/vue-html-indent.test.js +77 -0
  75. package/tests/rules/vue-html-quotes.test.js +71 -0
  76. package/tests/rules/vue-methods-separator.test.js +55 -0
  77. package/tests/rules/vue-name-prop.test.js +59 -0
  78. package/tests/rules/vue-no-component-class-shorthand.test.js +49 -0
  79. package/tests/rules/vue-no-mixed-class.test.js +56 -0
  80. package/tests/rules/vue-no-name-option.test.js +44 -0
  81. package/tests/rules/vue-no-regex-data.test.js +39 -0
  82. package/tests/rules/vue-pinia-action-single-parameter.test.js +234 -0
  83. package/tests/rules/vue-props-declaration-line-break.test.js +68 -0
  84. package/tests/rules/vue-props-declaration-multiline.test.js +40 -0
  85. package/tests/rules/vue-props-declaration-order.test.js +27 -0
  86. package/tests/rules/vue-ref-case.test.js +40 -0
  87. package/tests/rules/vue-watch-handler.test.js +89 -0
  88. package/tests/rules-coverage.test.js +19 -0
@@ -0,0 +1,88 @@
1
+ import rule from "../../rules/import-group-comment.js";
2
+ import createRuleTester from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("import-group-comment", rule, {
7
+ valid: [
8
+ {
9
+ filename: "/project/src/example.js",
10
+ code: "// NPM\nimport lodash from \"lodash\";"
11
+ },
12
+ {
13
+ filename: "/project/src/components/example.js",
14
+ code: "// PROJECT: COMPONENTS\nimport Button from \"./Button.js\";"
15
+ },
16
+ {
17
+ filename: "/project/src/example.js",
18
+ code: "// PROJECT: HELPERS\n// @ts-ignore\nimport helper from \"@/helpers/helper.js\";"
19
+ },
20
+ {
21
+ filename: "/project/src/example.js",
22
+ options: [{ "^virtual:": "GENERATED" }],
23
+ code: "// PROJECT: GENERATED\nimport value from \"virtual:value\";"
24
+ },
25
+ {
26
+ filename: "/project/src/Component.vue",
27
+ code: "// TYPES\n/** @typedef {string} Identifier */"
28
+ },
29
+ {
30
+ code: "// PROJECT: MAIN\nimport value from \"./value.js\";"
31
+ },
32
+ {
33
+ code: "// NPM\nimport value from \"package\";",
34
+ options: [{ "[": "INVALID" }]
35
+ }
36
+ ],
37
+
38
+ invalid: [
39
+ {
40
+ filename: "/project/src/example.js",
41
+ code: "// PROJECT: HELPERS\nimport lodash from \"lodash\";",
42
+ errors: [
43
+ {
44
+ message: "Import \"lodash\" should be in the \"NPM\" group."
45
+ }
46
+ ]
47
+ },
48
+ {
49
+ filename: "/project/src/example.js",
50
+ code: "// NPM\n\nimport lodash from \"lodash\";",
51
+ output: "// NPM\nimport lodash from \"lodash\";",
52
+ errors: [
53
+ {
54
+ message: "Import group comment must be immediately followed by an import (no blank line)."
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ filename: "/project/src/example.js",
60
+ options: [{ "^virtual:": "GENERATED" }],
61
+ code: "// NPM\nimport value from \"virtual:value\";",
62
+ errors: [
63
+ {
64
+ message: "Import \"virtual:value\" should be in the \"PROJECT: GENERATED\" group."
65
+ }
66
+ ]
67
+ },
68
+ {
69
+ filename: "/project/src/Component.vue",
70
+ code: "/** @typedef {string} Identifier */",
71
+ errors: [
72
+ {
73
+ message: "Type comments group must be preceded by a '// TYPES' comment"
74
+ }
75
+ ]
76
+ },
77
+ {
78
+ filename: "/project/src/Component.vue",
79
+ code: "// TYPES\n\n/** @typedef {string} Identifier */",
80
+ output: "// TYPES\n/** @typedef {string} Identifier */",
81
+ errors: [
82
+ {
83
+ message: "Type group comment must be immediately followed by a type comment (no blank line)."
84
+ }
85
+ ]
86
+ }
87
+ ]
88
+ });
@@ -0,0 +1,58 @@
1
+ import rule from "../../rules/import-group-order.js";
2
+ import createRuleTester from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("import-group-order", rule, {
7
+ valid: [
8
+ {
9
+ code: [
10
+ "// NPM",
11
+ "import lodash from \"lodash\";",
12
+ "// PROJECT: COMPONENTS",
13
+ "import Button from \"@/components/Button.js\";",
14
+ "// PROJECT: HELPERS",
15
+ "import helper from \"@/helpers/helper.js\";",
16
+ "// TYPES",
17
+ "import \"./types.js\";"
18
+ ].join("\n")
19
+ },
20
+ {
21
+ code: "// PROJECT: UNKNOWN\nimport value from \"./value.js\";"
22
+ },
23
+ {
24
+ code: "import first from \"first\";\nimport second from \"second\";"
25
+ }
26
+ ],
27
+
28
+ invalid: [
29
+ {
30
+ code: [
31
+ "// PROJECT: HELPERS",
32
+ "import helper from \"@/helpers/helper.js\";",
33
+ "// NPM",
34
+ "import lodash from \"lodash\";"
35
+ ].join("\n"),
36
+ errors: [
37
+ {
38
+ message: "Import group 'NPM' should be before 'PROJECT: HELPERS' group."
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ code: [
44
+ "// NPM",
45
+ "import lodash from \"lodash\";",
46
+ "// TYPES",
47
+ "import \"./types.js\";",
48
+ "// PROJECT: COMPONENTS",
49
+ "import Button from \"@/components/Button.js\";"
50
+ ].join("\n"),
51
+ errors: [
52
+ {
53
+ message: "Import group 'PROJECT: COMPONENTS' should be after 'NPM' group."
54
+ }
55
+ ]
56
+ }
57
+ ]
58
+ });
@@ -0,0 +1,32 @@
1
+ import rule from "../../rules/jsdoc-align-params.js";
2
+ import createRuleTester, { withoutFixes } from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("jsdoc-align-params", withoutFixes(rule), {
7
+ valid: [
8
+ "/**\n * Fetch a value.\n * @public\n * @param {string} value\n * @return {string} Result.\n */\nfunction fetchValue(value) { return value; }",
9
+ "/**\n * Produce values.\n * @protected\n * @internal\n * @generator\n * @param {number} count\n * @yields {number} Next value.\n */\nfunction* values(count) { yield count; }",
10
+ "/** A compact comment. */\nconst value = 1;",
11
+ "/**\n * Missing scope is ignored.\n * @param {string} value\n */\nfunction ignored(value) { return value; }"
12
+ ],
13
+
14
+ invalid: [
15
+ {
16
+ code: "/**\n * Fetch a value.\n * @public\n * @param {string} value\n * @return {string} Result.\n */\nfunction fetchValue(value) { return value; }",
17
+ errors: [
18
+ {
19
+ message: "JSDoc alignment issue"
20
+ }
21
+ ]
22
+ },
23
+ {
24
+ code: "/**\n * Produce values.\n * @private\n * @generator\n * @param {number} count\n * @yields {number} Next value.\n */\nfunction* values(count) { yield count; }",
25
+ errors: [
26
+ {
27
+ message: "JSDoc alignment issue"
28
+ }
29
+ ]
30
+ }
31
+ ]
32
+ });
@@ -0,0 +1,45 @@
1
+ import rule from "../../rules/jsdoc-check-indentation.js";
2
+ import createRuleTester from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("jsdoc-check-indentation", rule, {
7
+ valid: [
8
+ "/**\n * A description.\n * @returns {boolean} The result.\n */\nfunction check() { return true; }",
9
+ "/**\n * ```js\n * const indented = true;\n * ```\n */\nfunction example() {}",
10
+ "/**\n * @example\n * const indented = true;\n */\nfunction example() {}",
11
+ {
12
+ code: "/**\n * @custom\n * deliberately indented\n */\nfunction example() {}",
13
+ options: [
14
+ {
15
+ excludeTags: ["custom"]
16
+ }
17
+ ]
18
+ },
19
+ "/**\n * A continued line \\\n * remains part of the description.\n */\nfunction example() {}"
20
+ ],
21
+
22
+ invalid: [
23
+ {
24
+ code: "/**\n * Unexpected indentation.\n */\nfunction example() {}",
25
+ errors: [
26
+ {
27
+ message: "There must be no indentation."
28
+ }
29
+ ]
30
+ },
31
+ {
32
+ code: "/**\n * @example\n * const indented = true;\n */\nfunction example() {}",
33
+ options: [
34
+ {
35
+ excludeTags: []
36
+ }
37
+ ],
38
+ errors: [
39
+ {
40
+ message: "There must be no indentation."
41
+ }
42
+ ]
43
+ }
44
+ ]
45
+ });
@@ -0,0 +1,40 @@
1
+ import rule from "../../rules/jsdoc-check-optional-params.js";
2
+ import createRuleTester from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("jsdoc-check-optional-params", rule, {
7
+ valid: [
8
+ "/** @param {string} value */\nfunction required(value) {}",
9
+ "/** @param {string} [value] */\nfunction optional(value = \"default\") {}",
10
+ "/** @param {number} [count=1] */\nconst optional = function(count = 1) {};",
11
+ "function undocumented(value) {}"
12
+ ],
13
+
14
+ invalid: [
15
+ {
16
+ code: "/** @param {string} value */\nfunction optional(value = \"default\") {}",
17
+ errors: [
18
+ {
19
+ message: "Optional parameters in JSDoc should be surrounded by brackets"
20
+ }
21
+ ]
22
+ },
23
+ {
24
+ code: "/** @param {string} [value] */\nfunction required(value) {}",
25
+ errors: [
26
+ {
27
+ message: "Non-optional parameters in JSDoc should not be surrounded by brackets"
28
+ }
29
+ ]
30
+ },
31
+ {
32
+ code: "/** @param {Object} options */\nfunction configure({ enabled }) {}",
33
+ errors: [
34
+ {
35
+ message: "No matching JSDoc param found"
36
+ }
37
+ ]
38
+ }
39
+ ]
40
+ });
@@ -0,0 +1,60 @@
1
+ import rule from "../../rules/jsdoc-description-length.js";
2
+ import createRuleTester from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("jsdoc-description-length", rule, {
7
+ valid: [
8
+ "/**\n * A single-line description.\n */\nfunction example() {}",
9
+ "/**\n * A description that continues \\\n * on the next line.\n * @returns {boolean} The result.\n */\nfunction example() { return true; }",
10
+ {
11
+ code: "/**\n * First line \\\n * second line \\\n * third line.\n */\nfunction example() {}",
12
+ options: [
13
+ {
14
+ maxLines: 3
15
+ }
16
+ ]
17
+ },
18
+ "/********************\n * Section header\n ********************/\nconst value = true;"
19
+ ],
20
+
21
+ invalid: [
22
+ {
23
+ code: "/**\n * First line \\\n * second line \\\n * third line.\n */\nfunction example() {}",
24
+ errors: [
25
+ {
26
+ message: "JSDoc description must not exceed 2 line(s)."
27
+ }
28
+ ]
29
+ },
30
+ {
31
+ code: "/**\n * First line\n * second line.\n */\nfunction example() {}",
32
+ errors: [
33
+ {
34
+ message: "Multi-line JSDoc description must end with '\\' before each continuation."
35
+ }
36
+ ]
37
+ },
38
+ {
39
+ code: "/**\n * First line \\\n * second line.\n */\nfunction example() {}",
40
+ errors: [
41
+ {
42
+ message: "Continuation lines in JSDoc description must be indented with 3 spaces after '*'."
43
+ }
44
+ ]
45
+ },
46
+ {
47
+ code: "/**\n * First line \\\n * second line.\n */\nfunction example() {}",
48
+ options: [
49
+ {
50
+ maxLines: 1
51
+ }
52
+ ],
53
+ errors: [
54
+ {
55
+ message: "JSDoc description must not exceed 1 line(s)."
56
+ }
57
+ ]
58
+ }
59
+ ]
60
+ });
@@ -0,0 +1,34 @@
1
+ import rule from "../../rules/jsdoc-description-multiline.js";
2
+ import createRuleTester from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("jsdoc-description-multiline", rule, {
7
+ valid: [
8
+ "/**\n * A multiline description.\n */\nfunction example() {}",
9
+ "/** */\nfunction empty() {}",
10
+ "/** @public */\nfunction tagged() {}",
11
+ "/**\n * @returns {boolean} The result.\n */\nfunction tagged() { return true; }"
12
+ ],
13
+
14
+ invalid: [
15
+ {
16
+ code: "/** A compact description. */\nfunction example() {}",
17
+ output: "/**\n * A compact description.\n */\nfunction example() {}",
18
+ errors: [
19
+ {
20
+ message: "Function JSDoc descriptions must use multiline formatting."
21
+ }
22
+ ]
23
+ },
24
+ {
25
+ code: "function outer() {\n /** An indented description. */\n function inner() {}\n}",
26
+ output: "function outer() {\n /**\n * An indented description.\n */\n function inner() {}\n}",
27
+ errors: [
28
+ {
29
+ message: "Function JSDoc descriptions must use multiline formatting."
30
+ }
31
+ ]
32
+ }
33
+ ]
34
+ });
@@ -0,0 +1,66 @@
1
+ import rule from "../../rules/jsdoc-enforce-access.js";
2
+ import createRuleTester from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("jsdoc-enforce-access", rule, {
7
+ valid: [
8
+ "/** @public */\nfunction publicFunction() {}",
9
+ "class Example {\n /** @protected */\n method() {}\n}",
10
+ "const object = {\n /** @private */\n method: () => {}\n};",
11
+ "/** @internal */\nconst internal = function() {};",
12
+ "/** @public */\n// Additional context.\nfunction documented() {}",
13
+ "function undocumented() {}"
14
+ ],
15
+
16
+ invalid: [
17
+ {
18
+ code: "/** A function. */\nfunction example() {}",
19
+ errors: [
20
+ {
21
+ message: "JSDoc comment should contain @public, @protected, @private or @internal"
22
+ }
23
+ ]
24
+ },
25
+ {
26
+ code: "class Example {\n /** A method. */\n method() {}\n}",
27
+ errors: [
28
+ {
29
+ message: "JSDoc comment should contain @public, @protected, @private or @internal"
30
+ }
31
+ ]
32
+ },
33
+ {
34
+ code: "const object = {\n /** A property method. */\n method: () => {}\n};",
35
+ errors: [
36
+ {
37
+ message: "JSDoc comment should contain @public, @protected, @private or @internal"
38
+ }
39
+ ]
40
+ },
41
+ {
42
+ code: "const expression = /** A function expression. */ function() {};",
43
+ errors: [
44
+ {
45
+ message: "JSDoc comment should contain @public, @protected, @private or @internal"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ code: "/** @publicity */\nfunction example() {}",
51
+ errors: [
52
+ {
53
+ message: "JSDoc comment should contain @public, @protected, @private or @internal"
54
+ }
55
+ ]
56
+ },
57
+ {
58
+ code: "/** A function. */\n// Additional context.\nfunction example() {}",
59
+ errors: [
60
+ {
61
+ message: "JSDoc comment should contain @public, @protected, @private or @internal"
62
+ }
63
+ ]
64
+ }
65
+ ]
66
+ });
@@ -0,0 +1,39 @@
1
+ import rule from "../../rules/jsdoc-enforce-classdesc.js";
2
+ import createRuleTester from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("jsdoc-enforce-classdesc", rule, {
7
+ valid: [
8
+ "/**\n * @classdesc Represents an example.\n */\nclass Example {}",
9
+ "class Undocumented {}",
10
+ "/** A factory function. */\nfunction createExample() {}"
11
+ ],
12
+
13
+ invalid: [
14
+ {
15
+ code: "/** Represents an example. */\nclass Example {}",
16
+ errors: [
17
+ {
18
+ message: "JSDoc class header should include @classdesc"
19
+ }
20
+ ]
21
+ },
22
+ {
23
+ code: "/**\n * @classdesc\n */\nclass Example {}",
24
+ errors: [
25
+ {
26
+ message: "The @classdesc tag in JSDoc class header should have a non-empty description"
27
+ }
28
+ ]
29
+ },
30
+ {
31
+ code: "/**\n * @classdesc \n */\nclass Example {}",
32
+ errors: [
33
+ {
34
+ message: "The @classdesc tag in JSDoc class header should have a non-empty description"
35
+ }
36
+ ]
37
+ }
38
+ ]
39
+ });
@@ -0,0 +1,47 @@
1
+ import rule from "../../rules/jsdoc-no-param-return.js";
2
+ import createRuleTester, { withoutFixes } from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("jsdoc-no-param-return", withoutFixes(rule), {
7
+ valid: [
8
+ "/**\n * Describe a function without signature tags.\n * @public\n */\nfunction example(value) { return value; }",
9
+ "/**\n * @property {string} value A property.\n * @type {Object}\n */\nconst object = {};",
10
+ "// @param is ordinary line-comment text.\nfunction example(value) {}"
11
+ ],
12
+
13
+ invalid: [
14
+ {
15
+ code: "/**\n * @param {string} value A value.\n */\nfunction example(value) {}",
16
+ errors: [
17
+ {
18
+ message: "@param and @return tags are not permitted in JSDoc, rely on the TypeScript signature instead."
19
+ }
20
+ ]
21
+ },
22
+ {
23
+ code: "/**\n * @arg {string} value A value.\n * @argument {number} count A count.\n */\nfunction example(value, count) {}",
24
+ errors: [
25
+ {
26
+ message: "@param and @return tags are not permitted in JSDoc, rely on the TypeScript signature instead."
27
+ }
28
+ ]
29
+ },
30
+ {
31
+ code: "/**\n * @return {string} A value.\n * @returns {string} Another value.\n */\nfunction example() { return \"value\"; }",
32
+ errors: [
33
+ {
34
+ message: "@param and @return tags are not permitted in JSDoc, rely on the TypeScript signature instead."
35
+ }
36
+ ]
37
+ },
38
+ {
39
+ code: "/**\n * @yield {number} A value.\n * @yields {number} Another value.\n */\nfunction* example() { yield 1; }",
40
+ errors: [
41
+ {
42
+ message: "@param and @return tags are not permitted in JSDoc, rely on the TypeScript signature instead."
43
+ }
44
+ ]
45
+ }
46
+ ]
47
+ });
@@ -0,0 +1,52 @@
1
+ import rule from "../../rules/jsdoc-require-description-uppercase.js";
2
+ import createRuleTester from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("jsdoc-require-description-uppercase", rule, {
7
+ valid: [
8
+ "/**\n * Starts with an uppercase character.\n */\nfunction example() {}",
9
+ "/**\n * # heading ignored\n * Description below the heading.\n */\nfunction example() {}",
10
+ "/**\n * | column | value |\n * | --- | --- |\n */\nconst table = true;",
11
+ "/**\n * @param {string} value Uppercase parameter description.\n * @returns {boolean} Uppercase return description.\n * @throws {Error} Uppercase error description.\n */\nfunction example(value) { return Boolean(value); }"
12
+ ],
13
+
14
+ invalid: [
15
+ {
16
+ code: "/**\n * lowercase description.\n */\nfunction example() {}",
17
+ output: "/**\n * Lowercase description.\n */\nfunction example() {}",
18
+ errors: [
19
+ {
20
+ message: "Sentences should start with an uppercase character."
21
+ }
22
+ ]
23
+ },
24
+ {
25
+ code: "/**\n * @param {string} value lowercase parameter description.\n */\nfunction example(value) {}",
26
+ output: "/**\n * @param {string} value Lowercase parameter description.\n */\nfunction example(value) {}",
27
+ errors: [
28
+ {
29
+ message: "Sentences should start with an uppercase character."
30
+ }
31
+ ]
32
+ },
33
+ {
34
+ code: "/**\n * @returns {boolean} lowercase return description.\n */\nfunction example() { return true; }",
35
+ output: "/**\n * @returns {boolean} Lowercase return description.\n */\nfunction example() { return true; }",
36
+ errors: [
37
+ {
38
+ message: "Sentences should start with an uppercase character."
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ code: "/**\n * @classdesc lowercase class description.\n */\nclass Example {}",
44
+ output: "/**\n * @classdesc Lowercase class description.\n */\nclass Example {}",
45
+ errors: [
46
+ {
47
+ message: "Sentences should start with an uppercase character."
48
+ }
49
+ ]
50
+ }
51
+ ]
52
+ });
@@ -0,0 +1,70 @@
1
+ import rule from "../../rules/methods-naming.js";
2
+ import createRuleTester from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("methods-naming", rule, {
7
+ valid: [
8
+ {
9
+ code: `class Service {
10
+ /** @public */
11
+ start() {}
12
+
13
+ /** @protected */
14
+ _refresh() {}
15
+
16
+ /** @private */
17
+ __reset() {}
18
+ }`
19
+ },
20
+ {
21
+ code: `class Service {
22
+ undocumented() {}
23
+
24
+ /** A method without a visibility tag. */
25
+ documented() {}
26
+ }`
27
+ },
28
+ {
29
+ code: `class Service {
30
+ /** @private */
31
+ ["computed"]() {}
32
+ }`
33
+ }
34
+ ],
35
+
36
+ invalid: [
37
+ {
38
+ code: "class Service {\n /** @public */\n __reset() {}\n}",
39
+ errors: [
40
+ {
41
+ message: "Methods starting with '__' should not be marked with '@public'."
42
+ }
43
+ ]
44
+ },
45
+ {
46
+ code: "class Service {\n /** @public */\n _refresh() {}\n}",
47
+ errors: [
48
+ {
49
+ message: "Methods starting with '_' should not be marked with '@public'."
50
+ }
51
+ ]
52
+ },
53
+ {
54
+ code: "class Service {\n /** @private */\n reset() {}\n}",
55
+ errors: [
56
+ {
57
+ message: "Methods not starting with '__' should not be marked with '@private'."
58
+ }
59
+ ]
60
+ },
61
+ {
62
+ code: "class Service {\n /** @protected */\n refresh() {}\n}",
63
+ errors: [
64
+ {
65
+ message: "Methods not starting with '_' should not be marked with '@protected'."
66
+ }
67
+ ]
68
+ }
69
+ ]
70
+ });