eslint-plugin-crisp 1.5.12 → 1.6.0

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 (89) 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 +16 -7
  5. package/recommended-ts.js +1 -1
  6. package/recommended-vue.js +3 -2
  7. package/rules/align-comments.js +6 -3
  8. package/rules/constructor-variables.js +17 -2
  9. package/rules/header-check.js +8 -2
  10. package/rules/header-comments-check.js +14 -3
  11. package/rules/import-group-comment.js +13 -4
  12. package/rules/jsdoc-enforce-access.js +16 -10
  13. package/rules/no-extra-line-within-function.js +8 -5
  14. package/rules/no-short-parameters.js +1 -1
  15. package/rules/no-snake-case.js +0 -24
  16. package/rules/no-space-in-optional-arguments.js +5 -2
  17. package/rules/one-space-after-operator.js +59 -14
  18. package/rules/vue-header-check.js +4 -3
  19. package/rules/vue-no-regex-data.js +1 -2
  20. package/rules/vue-pinia-action-single-parameter.js +158 -0
  21. package/rules/vue-props-declaration-line-break.js +8 -3
  22. package/rules/vue-watch-handler.js +34 -1
  23. package/tests/fixtures/vue-header-check/missing-script-style/TestComponent.vue +19 -0
  24. package/tests/fixtures/vue-header-check/missing-template/TestComponent.vue +3 -0
  25. package/tests/fixtures/vue-header-check/valid/TestComponent.vue +27 -0
  26. package/tests/rule-tester.js +78 -0
  27. package/tests/rules/align-comments.test.js +25 -0
  28. package/tests/rules/align-consecutive-class-assignements.test.js +24 -0
  29. package/tests/rules/align-one-var.test.js +31 -0
  30. package/tests/rules/align-requires.test.js +27 -0
  31. package/tests/rules/arrow-block-newline.test.js +23 -0
  32. package/tests/rules/consecutive-line-comments.test.js +27 -0
  33. package/tests/rules/const.test.js +52 -0
  34. package/tests/rules/constructor-variables.test.js +52 -0
  35. package/tests/rules/enforce-optional.test.js +24 -0
  36. package/tests/rules/header-check.test.js +69 -0
  37. package/tests/rules/header-comments-check.test.js +90 -0
  38. package/tests/rules/import-group-comment.test.js +88 -0
  39. package/tests/rules/import-group-order.test.js +58 -0
  40. package/tests/rules/jsdoc-align-params.test.js +32 -0
  41. package/tests/rules/jsdoc-check-indentation.test.js +45 -0
  42. package/tests/rules/jsdoc-check-optional-params.test.js +40 -0
  43. package/tests/rules/jsdoc-description-length.test.js +60 -0
  44. package/tests/rules/jsdoc-description-multiline.test.js +34 -0
  45. package/tests/rules/jsdoc-enforce-access.test.js +66 -0
  46. package/tests/rules/jsdoc-enforce-classdesc.test.js +39 -0
  47. package/tests/rules/jsdoc-no-param-return.test.js +47 -0
  48. package/tests/rules/jsdoc-require-description-uppercase.test.js +52 -0
  49. package/tests/rules/methods-naming.test.js +70 -0
  50. package/tests/rules/methods-ordering.test.js +75 -0
  51. package/tests/rules/multiline-comment-end-backslash.test.js +52 -0
  52. package/tests/rules/newline-after-switch-case.test.js +75 -0
  53. package/tests/rules/no-async.test.js +57 -0
  54. package/tests/rules/no-extra-line-within-function.test.js +87 -0
  55. package/tests/rules/no-inline-function-in-ternary.test.js +59 -0
  56. package/tests/rules/no-short-parameters.test.js +62 -0
  57. package/tests/rules/no-snake-case.test.js +81 -0
  58. package/tests/rules/no-space-in-optional-arguments.test.js +40 -0
  59. package/tests/rules/no-useless-template-literals.test.js +36 -0
  60. package/tests/rules/no-var-in-blocks.test.js +40 -0
  61. package/tests/rules/one-space-after-operator.test.js +69 -0
  62. package/tests/rules/regex-in-constructor.test.js +40 -0
  63. package/tests/rules/ternary-parenthesis.test.js +34 -0
  64. package/tests/rules/two-lines-between-class-members.test.js +62 -0
  65. package/tests/rules/variable-names.test.js +60 -0
  66. package/tests/rules/vue-attribute-comma.test.js +43 -0
  67. package/tests/rules/vue-attribute-linebreak.test.js +54 -0
  68. package/tests/rules/vue-class-attribute-last.test.js +59 -0
  69. package/tests/rules/vue-class-shorthand-max-len.test.js +67 -0
  70. package/tests/rules/vue-computed-order.test.js +27 -0
  71. package/tests/rules/vue-data-comment.test.js +61 -0
  72. package/tests/rules/vue-define-component.test.js +45 -0
  73. package/tests/rules/vue-emits-order.test.js +27 -0
  74. package/tests/rules/vue-header-check.test.js +49 -0
  75. package/tests/rules/vue-html-indent.test.js +77 -0
  76. package/tests/rules/vue-html-quotes.test.js +71 -0
  77. package/tests/rules/vue-methods-separator.test.js +55 -0
  78. package/tests/rules/vue-name-prop.test.js +59 -0
  79. package/tests/rules/vue-no-component-class-shorthand.test.js +49 -0
  80. package/tests/rules/vue-no-mixed-class.test.js +56 -0
  81. package/tests/rules/vue-no-name-option.test.js +44 -0
  82. package/tests/rules/vue-no-regex-data.test.js +39 -0
  83. package/tests/rules/vue-pinia-action-single-parameter.test.js +234 -0
  84. package/tests/rules/vue-props-declaration-line-break.test.js +68 -0
  85. package/tests/rules/vue-props-declaration-multiline.test.js +40 -0
  86. package/tests/rules/vue-props-declaration-order.test.js +27 -0
  87. package/tests/rules/vue-ref-case.test.js +40 -0
  88. package/tests/rules/vue-watch-handler.test.js +89 -0
  89. package/tests/rules-coverage.test.js +19 -0
@@ -0,0 +1,69 @@
1
+ import rule from "../../rules/header-check.js";
2
+ import createRuleTester from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+
6
+ ruleTester.run("header-check", rule, {
7
+ valid: [
8
+ {
9
+ code:
10
+ "/*\n * This file is part of Example\n *\n" +
11
+ " * Copyright (c) 2026 Crisp IM SAS\n" +
12
+ " * All rights belong to Crisp IM SAS\n */\nconst VALUE = 1;",
13
+ filename: "/project/example.js"
14
+ },
15
+ {
16
+ code: "/* Custom header */\nconst VALUE = 1;",
17
+ filename: "/project/example.ts",
18
+ options: [
19
+ {
20
+ patterns: [" Custom header "]
21
+ }
22
+ ]
23
+ },
24
+ {
25
+ code: "const VALUE = 1;",
26
+ filename: "/project/example.txt"
27
+ }
28
+ ],
29
+
30
+ invalid: [
31
+ {
32
+ code: "const VALUE = 1;",
33
+ filename: "/project/example.js",
34
+ errors: [
35
+ {
36
+ message: "File must start with the proper header."
37
+ }
38
+ ]
39
+ },
40
+ {
41
+ code: "/* Wrong header */\nconst VALUE = 1;",
42
+ filename: "/project/example.ts",
43
+ options: [
44
+ {
45
+ patterns: [" Expected header "]
46
+ }
47
+ ],
48
+ errors: [
49
+ {
50
+ message: "File must start with the proper header."
51
+ }
52
+ ]
53
+ },
54
+ {
55
+ code: "const VALUE = 1;",
56
+ filename: "/project/example.js",
57
+ options: [
58
+ {
59
+ patterns: ["["]
60
+ }
61
+ ],
62
+ errors: [
63
+ {
64
+ message: "File must start with the proper header."
65
+ }
66
+ ]
67
+ }
68
+ ]
69
+ });
@@ -0,0 +1,90 @@
1
+ import rule from "../../rules/header-comments-check.js";
2
+ import createRuleTester from "../rule-tester.js";
3
+
4
+ const ruleTester = createRuleTester();
5
+ const header = (name) => [
6
+ "/**************************************************************************",
7
+ ` * ${name}`,
8
+ " ***************************************************************************/"
9
+ ].join("\n");
10
+
11
+ ruleTester.run("header-comments-check", rule, {
12
+ valid: [
13
+ {
14
+ filename: "/project/src/example.js",
15
+ code: `${header("IMPORTS")}\nimport value from "package";`
16
+ },
17
+ {
18
+ filename: "/project/src/example.ts",
19
+ code: `${header("CONSTANTS")}\nconst MAX_RETRIES = 3;\n\n${header("INSTANCES")}\nconst pattern = /value/;`
20
+ },
21
+ {
22
+ filename: "/project/src/example.js",
23
+ code:
24
+ `${header("TYPES")}\n/** @typedef {string} Identifier */\n\n` +
25
+ `${header("EXPORTS")}\nexport default {};`
26
+ },
27
+ {
28
+ filename: "/project/src/example.js",
29
+ code:
30
+ `${header("IMPORTS")}\nimport first from "first";\n` +
31
+ "import second from \"second\";"
32
+ },
33
+ {
34
+ filename: "/project/src/example.vue",
35
+ code: "import value from \"package\";\nconst MAX_RETRIES = 3;"
36
+ },
37
+ {
38
+ filename: "/project/src/example.js",
39
+ code: "function wrapper() {\n const LOCAL_CONSTANT = 1;\n}"
40
+ }
41
+ ],
42
+
43
+ invalid: [
44
+ {
45
+ filename: "/project/src/example.js",
46
+ code: "import value from \"package\";",
47
+ errors: [
48
+ {
49
+ message: "Import group must be preceded by a 'IMPORTS' comment block"
50
+ }
51
+ ]
52
+ },
53
+ {
54
+ filename: "/project/src/example.ts",
55
+ code: "const MAX_RETRIES = 3;",
56
+ errors: [
57
+ {
58
+ message: "Variable group must be preceded by a 'CONSTANTS' comment block"
59
+ }
60
+ ]
61
+ },
62
+ {
63
+ filename: "/project/src/example.js",
64
+ code: "const patterns = [/first/, /second/];",
65
+ errors: [
66
+ {
67
+ message: "Regex group must be preceded by a 'INSTANCES' comment block"
68
+ }
69
+ ]
70
+ },
71
+ {
72
+ filename: "/project/src/example.js",
73
+ code: "/** @typedef {string} Identifier */\nconst value = 1;",
74
+ errors: [
75
+ {
76
+ message: "Type comments group must be preceded by a 'TYPES' comment block"
77
+ }
78
+ ]
79
+ },
80
+ {
81
+ filename: "/project/src/example.js",
82
+ code: "export default {};",
83
+ errors: [
84
+ {
85
+ message: "Export group must be preceded by a 'EXPORTS' comment block"
86
+ }
87
+ ]
88
+ }
89
+ ]
90
+ });
@@ -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
+ });