eslint-plugin-crisp 1.4.12 → 1.4.15

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/README.md CHANGED
@@ -90,6 +90,7 @@ Each item has emojis denoting:
90
90
  | [no-multiple-empty-lines](https://eslint.org/docs/latest/rules/no-multiple-empty-lines) | Allows a maximum of 1 consecutive empty lines | | 🟢 | 🟣 |
91
91
  | [no-mixed-spaces-and-tabs](https://eslint.org/docs/latest/rules/no-mixed-spaces-and-tabs) | Disallows mixed spaces and tabs for indentation | 🟠 | 🟢 | 🟣 |
92
92
  | [no-restricted-syntax](https://eslint.org/docs/latest/rules/no-restricted-syntax) | Enforces `switch` `case`'s content to be enclosed in braces | | 🟢 | 🟣 |
93
+ | [no-restricted-syntax](https://eslint.org/docs/latest/rules/no-restricted-syntax) | Enforces `watch` watchers to use the object form with a `handler` function | | 🟢 | |
93
94
  | [no-tabs](https://eslint.org/docs/latest/rules/no-tabs) | Disallows tabs | 🟠 | 🟢 | 🟣 |
94
95
  | [no-trailing-spaces](https://eslint.org/docs/latest/rules/no-trailing-spaces) | Disallows trailing whitespace at the end of lines | 🟠 | 🟢 | 🟣 |
95
96
  | [no-undef](https://eslint.org/docs/latest/rules/no-undef) | Disallows use of undeclared variables | 🟠 | 🟢 | 🟣 |
package/index.js CHANGED
@@ -17,6 +17,7 @@ import ruleImportGroupOrder from "./rules/import-group-order.js";
17
17
  import ruleJsdocAlignParams from "./rules/jsdoc-align-params.js";
18
18
  import ruleJsdocCheckIndentation from "./rules/jsdoc-check-indentation.js";
19
19
  import ruleJsdocCheckOptionalParams from "./rules/jsdoc-check-optional-params.js";
20
+ import ruleJsdocDescriptionMultiline from "./rules/jsdoc-description-multiline.js";
20
21
  import ruleJsdocEnforceAccess from "./rules/jsdoc-enforce-access.js";
21
22
  import ruleJsdocEnforceClassdesc from "./rules/jsdoc-enforce-classdesc.js";
22
23
  import ruleJsdocNoParamReturn from "./rules/jsdoc-no-param-return.js";
@@ -83,6 +84,7 @@ const plugin = {
83
84
  "jsdoc-align-params": ruleJsdocAlignParams,
84
85
  "jsdoc-check-indentation": ruleJsdocCheckIndentation,
85
86
  "jsdoc-check-optional-params": ruleJsdocCheckOptionalParams,
87
+ "jsdoc-description-multiline": ruleJsdocDescriptionMultiline,
86
88
  "jsdoc-enforce-access": ruleJsdocEnforceAccess,
87
89
  "jsdoc-enforce-classdesc": ruleJsdocEnforceClassdesc,
88
90
  "jsdoc-no-param-return": ruleJsdocNoParamReturn,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-crisp",
3
- "version": "1.4.12",
3
+ "version": "1.4.15",
4
4
  "description": "Custom ESLint Rules for Crisp",
5
5
  "author": "Crisp IM SAS",
6
6
  "main": "index.js",
package/recommended-ts.js CHANGED
@@ -184,6 +184,7 @@ export default function configRecommendedTS(pluginCrisp) {
184
184
 
185
185
  // Crisp JSDoc rules
186
186
  "crisp/jsdoc-description-length": "error",
187
+ "crisp/jsdoc-description-multiline": "error",
187
188
  "crisp/jsdoc-no-param-return": "error",
188
189
 
189
190
  // General JSDoc rules
@@ -111,6 +111,11 @@ export default function configRecommendedVue(pluginCrisp) {
111
111
  {
112
112
  "selector": "SwitchCase > *.consequent[type!='BlockStatement']",
113
113
  "message": "Switch cases without braces are disallowed."
114
+ },
115
+
116
+ {
117
+ "selector": "Property[key.name='watch'] > ObjectExpression > Property[value.type='FunctionExpression']",
118
+ "message": "Watchers must use the object form with a `handler` function."
114
119
  }
115
120
  ],
116
121
  "no-tabs": "error",
@@ -0,0 +1,45 @@
1
+ import iterateJsdoc from "eslint-plugin-jsdoc/iterateJsdoc.js";
2
+
3
+ export default iterateJsdoc.default(({
4
+ context,
5
+ indent,
6
+ jsdocNode,
7
+ sourceCode
8
+ }) => {
9
+ if (jsdocNode.loc.start.line !== jsdocNode.loc.end.line) {
10
+ return;
11
+ }
12
+
13
+ const description = sourceCode
14
+ .getText(jsdocNode)
15
+ .slice(3, -2)
16
+ .trim();
17
+
18
+ // Keep empty and tag-only JSDoc comments unchanged.
19
+ if (!description || description.startsWith("@")) {
20
+ return;
21
+ }
22
+
23
+ context.report({
24
+ node: jsdocNode,
25
+ messageId: "multiline",
26
+ fix(fixer) {
27
+ return fixer.replaceText(
28
+ jsdocNode,
29
+ `/**\n${indent} * ${description}\n${indent} */`
30
+ );
31
+ }
32
+ });
33
+ }, {
34
+ meta: {
35
+ type: "layout",
36
+ docs: {
37
+ description: "Enforce multiline formatting for function JSDoc descriptions."
38
+ },
39
+ fixable: "whitespace",
40
+ schema: [],
41
+ messages: {
42
+ multiline: "Function JSDoc descriptions must use multiline formatting."
43
+ }
44
+ }
45
+ });