@prowise/eslint-config-linting-rules 2.3.2 → 2.3.4
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@prowise/eslint-config-linting-rules","version":"2.3.
|
|
1
|
+
{"name":"@prowise/eslint-config-linting-rules","version":"2.3.4","description":"Default Prowise linting rules for npm packages.","main":"index.js","type":"module","exports":{"./typescript":"./typescript.js","./backend":"./backend.js","./front-react":"./front-react.js","./front-solid":"./front-solid.js","./next":"./next.js"},"scripts":{"lint":"eslint","test":"node tests/jsx-pascal-case-rule.test.js","inspect":"eslint --inspect-config"},"repository":{"type":"git","url":"git+ssh://git@bitbucket.org/prowise/npm-linting-rules.git"},"author":"Prowise B.V.","license":"UNLICENSED","homepage":"https://bitbucket.org/prowise/npm-linting-rules#readme","dependencies":{"@next/eslint-plugin-next":"^15.3.5","@stylistic/eslint-plugin":"^5.1.0","@vitest/eslint-plugin":"^1.3.4","confusing-browser-globals":"^1.0.11","eslint":"^9.31.0","eslint-import-resolver-typescript":"^4.4.4","eslint-plugin-file-progress":"^3.0.2","eslint-plugin-import-x":"^4.16.1","eslint-plugin-jsdoc":"^51.3.4","eslint-plugin-jsx-a11y":"^6.10.2","eslint-plugin-n":"^17.21.0","eslint-plugin-prefer-arrow-functions":"^3.6.2","eslint-plugin-react":"^7.37.5","eslint-plugin-react-hooks":"^5.2.0","eslint-plugin-solid":"^0.14.5","globals":"^16.3.0","typescript-eslint":"^8.36.0"},"devDependencies":{"@eslint/config-inspector":"^1.1.0"}}
|
|
@@ -13,12 +13,16 @@ export const jsxElementRule = {
|
|
|
13
13
|
|
|
14
14
|
if (node.type === "BlockStatement") {
|
|
15
15
|
const returnStatement = node.body.find((stmt) => stmt.type === "ReturnStatement");
|
|
16
|
+
|
|
17
|
+
// accept null as valid JSX return type
|
|
18
|
+
if (returnStatement.argument.type === "Literal" && returnStatement.argument.value === null) return "JSXElement";
|
|
19
|
+
|
|
16
20
|
if (returnStatement) return returnStatement.argument.type === "LogicalExpression" ? returnStatement.argument.right.type : returnStatement.argument.type;
|
|
17
21
|
|
|
18
22
|
const switchStatement = node.body.find((stmt) => stmt.type === "SwitchStatement");
|
|
19
23
|
if (switchStatement) return switchStatement.cases[0].consequent.find((stmt) => stmt.type === "ReturnStatement")?.argument.type;
|
|
20
24
|
|
|
21
|
-
return
|
|
25
|
+
return undefined;
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
return node.type;
|
|
@@ -41,6 +45,9 @@ export const jsxElementRule = {
|
|
|
41
45
|
const functionName = node.id.name;
|
|
42
46
|
const returnStatement = node.body.body.find((stmt) => stmt.type === "ReturnStatement");
|
|
43
47
|
|
|
48
|
+
// skip any null returns which are likely used for hooks
|
|
49
|
+
if (returnStatement?.argument.type === "Literal" && returnStatement?.argument.value === null) return;
|
|
50
|
+
|
|
44
51
|
if (!isJSXNode(returnStatement?.argument) && isPascalCase(functionName)) {
|
|
45
52
|
context.report({ node, message: `Function-name "${functionName}" must be camelCase` });
|
|
46
53
|
}
|
|
@@ -55,6 +62,10 @@ export const jsxElementRule = {
|
|
|
55
62
|
ArrowFunctionExpression: (node) => {
|
|
56
63
|
if (node.parent.type === "VariableDeclarator") {
|
|
57
64
|
const functionName = node.parent.id.name;
|
|
65
|
+
|
|
66
|
+
// skip any null returns which are likely used for hooks
|
|
67
|
+
if (node.body.type === "Literal" && node.body.value === null) return;
|
|
68
|
+
|
|
58
69
|
if (!isJSXNode(node.body) && isPascalCase(functionName)) {
|
|
59
70
|
context.report({ node, message: `Function-name "${functionName}" must be camelCase` });
|
|
60
71
|
}
|