eslint-plugin-nima 1.2.4 → 1.2.6

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 (227) hide show
  1. package/README.md +18 -18
  2. package/dist/constants/boolean-prefixes.js.map +1 -1
  3. package/dist/constants/consoles.js.map +1 -1
  4. package/dist/constants/hooks.js.map +1 -1
  5. package/dist/index.d.ts +25 -24
  6. package/dist/index.js +13 -57
  7. package/dist/index.js.map +1 -1
  8. package/dist/{models/boolean-naming-convention.model.d.ts → rules/boolean-naming-convention/config.d.ts} +11 -0
  9. package/dist/rules/boolean-naming-convention/config.js +70 -0
  10. package/dist/rules/boolean-naming-convention/config.js.map +1 -0
  11. package/dist/rules/boolean-naming-convention/create.d.ts +11 -0
  12. package/dist/rules/boolean-naming-convention/create.js +415 -0
  13. package/dist/rules/boolean-naming-convention/create.js.map +1 -0
  14. package/dist/rules/boolean-naming-convention/index.d.ts +2 -0
  15. package/dist/rules/boolean-naming-convention/index.js +22 -0
  16. package/dist/rules/boolean-naming-convention/index.js.map +1 -0
  17. package/dist/rules/{restrict-imports.d.ts → boolean-naming-convention/rule.d.ts} +2 -2
  18. package/dist/rules/boolean-naming-convention/rule.js +14 -0
  19. package/dist/rules/boolean-naming-convention/rule.js.map +1 -0
  20. package/dist/rules/index.d.ts +12 -0
  21. package/dist/rules/index.js +49 -0
  22. package/dist/rules/index.js.map +1 -0
  23. package/dist/rules/no-handler-suffix/config.d.ts +14 -0
  24. package/dist/rules/no-handler-suffix/config.js +23 -0
  25. package/dist/rules/no-handler-suffix/config.js.map +1 -0
  26. package/dist/rules/no-handler-suffix/create.d.ts +8 -0
  27. package/dist/rules/no-handler-suffix/create.js +71 -0
  28. package/dist/rules/no-handler-suffix/create.js.map +1 -0
  29. package/dist/rules/no-handler-suffix/index.d.ts +2 -0
  30. package/dist/rules/no-handler-suffix/index.js +22 -0
  31. package/dist/rules/no-handler-suffix/index.js.map +1 -0
  32. package/dist/rules/{no-handler-suffix.d.ts → no-handler-suffix/rule.d.ts} +2 -2
  33. package/dist/rules/no-handler-suffix/rule.js +14 -0
  34. package/dist/rules/no-handler-suffix/rule.js.map +1 -0
  35. package/dist/rules/no-objects-in-deps/config.d.ts +14 -0
  36. package/dist/rules/no-objects-in-deps/config.js +22 -0
  37. package/dist/rules/no-objects-in-deps/config.js.map +1 -0
  38. package/dist/rules/no-objects-in-deps/create.d.ts +6 -0
  39. package/dist/rules/no-objects-in-deps/create.js +124 -0
  40. package/dist/rules/no-objects-in-deps/create.js.map +1 -0
  41. package/dist/rules/no-objects-in-deps/index.d.ts +2 -0
  42. package/dist/rules/no-objects-in-deps/index.js +22 -0
  43. package/dist/rules/no-objects-in-deps/index.js.map +1 -0
  44. package/dist/rules/{no-objects-in-deps.d.ts → no-objects-in-deps/rule.d.ts} +2 -2
  45. package/dist/rules/no-objects-in-deps/rule.js +14 -0
  46. package/dist/rules/no-objects-in-deps/rule.js.map +1 -0
  47. package/dist/rules/params-naming-convention/config.d.ts +21 -0
  48. package/dist/rules/params-naming-convention/config.js +55 -0
  49. package/dist/rules/params-naming-convention/config.js.map +1 -0
  50. package/dist/rules/params-naming-convention/create.d.ts +6 -0
  51. package/dist/rules/params-naming-convention/create.js +49 -0
  52. package/dist/rules/params-naming-convention/create.js.map +1 -0
  53. package/dist/rules/params-naming-convention/index.d.ts +2 -0
  54. package/dist/rules/params-naming-convention/index.js +22 -0
  55. package/dist/rules/params-naming-convention/index.js.map +1 -0
  56. package/dist/rules/{prefer-react-fc.d.ts → params-naming-convention/rule.d.ts} +2 -2
  57. package/dist/rules/params-naming-convention/rule.js +14 -0
  58. package/dist/rules/params-naming-convention/rule.js.map +1 -0
  59. package/dist/{models/prefer-arrow-functions.model.d.ts → rules/prefer-arrow-functions/config.d.ts} +10 -0
  60. package/dist/rules/prefer-arrow-functions/config.js +67 -0
  61. package/dist/rules/prefer-arrow-functions/config.js.map +1 -0
  62. package/dist/rules/prefer-arrow-functions/create.d.ts +9 -0
  63. package/dist/rules/prefer-arrow-functions/create.js +150 -0
  64. package/dist/rules/prefer-arrow-functions/create.js.map +1 -0
  65. package/dist/rules/prefer-arrow-functions/index.d.ts +2 -0
  66. package/dist/rules/prefer-arrow-functions/index.js +22 -0
  67. package/dist/rules/prefer-arrow-functions/index.js.map +1 -0
  68. package/dist/rules/{restrict-function-usage.d.ts → prefer-arrow-functions/rule.d.ts} +2 -2
  69. package/dist/rules/prefer-arrow-functions/rule.js +14 -0
  70. package/dist/rules/prefer-arrow-functions/rule.js.map +1 -0
  71. package/dist/rules/prefer-export-under-component/config.d.ts +14 -0
  72. package/dist/rules/prefer-export-under-component/config.js +23 -0
  73. package/dist/rules/prefer-export-under-component/config.js.map +1 -0
  74. package/dist/rules/prefer-export-under-component/create.d.ts +8 -0
  75. package/dist/rules/prefer-export-under-component/create.js +99 -0
  76. package/dist/rules/prefer-export-under-component/create.js.map +1 -0
  77. package/dist/rules/prefer-export-under-component/index.d.ts +2 -0
  78. package/dist/rules/prefer-export-under-component/index.js +22 -0
  79. package/dist/rules/prefer-export-under-component/index.js.map +1 -0
  80. package/dist/rules/{prefer-react-with-hooks.d.ts → prefer-export-under-component/rule.d.ts} +2 -2
  81. package/dist/rules/prefer-export-under-component/rule.js +14 -0
  82. package/dist/rules/prefer-export-under-component/rule.js.map +1 -0
  83. package/dist/rules/prefer-react-fc/config.d.ts +19 -0
  84. package/dist/rules/prefer-react-fc/config.js +43 -0
  85. package/dist/rules/prefer-react-fc/config.js.map +1 -0
  86. package/dist/rules/prefer-react-fc/create.d.ts +8 -0
  87. package/dist/rules/prefer-react-fc/create.js +166 -0
  88. package/dist/rules/prefer-react-fc/create.js.map +1 -0
  89. package/dist/rules/prefer-react-fc/index.d.ts +2 -0
  90. package/dist/rules/prefer-react-fc/index.js +22 -0
  91. package/dist/rules/prefer-react-fc/index.js.map +1 -0
  92. package/dist/rules/{prefer-arrow-functions.d.ts → prefer-react-fc/rule.d.ts} +2 -2
  93. package/dist/rules/prefer-react-fc/rule.js +14 -0
  94. package/dist/rules/prefer-react-fc/rule.js.map +1 -0
  95. package/dist/rules/prefer-react-with-hooks/config.d.ts +15 -0
  96. package/dist/rules/prefer-react-with-hooks/config.js +25 -0
  97. package/dist/rules/prefer-react-with-hooks/config.js.map +1 -0
  98. package/dist/rules/prefer-react-with-hooks/create.d.ts +7 -0
  99. package/dist/rules/prefer-react-with-hooks/create.js +188 -0
  100. package/dist/rules/prefer-react-with-hooks/create.js.map +1 -0
  101. package/dist/rules/prefer-react-with-hooks/index.d.ts +2 -0
  102. package/dist/rules/prefer-react-with-hooks/index.js +22 -0
  103. package/dist/rules/prefer-react-with-hooks/index.js.map +1 -0
  104. package/dist/rules/{prefer-export-under-component.d.ts → prefer-react-with-hooks/rule.d.ts} +2 -2
  105. package/dist/rules/prefer-react-with-hooks/rule.js +14 -0
  106. package/dist/rules/prefer-react-with-hooks/rule.js.map +1 -0
  107. package/dist/rules/prefer-void-for-optional-param/config.d.ts +15 -0
  108. package/dist/rules/prefer-void-for-optional-param/config.js +25 -0
  109. package/dist/rules/prefer-void-for-optional-param/config.js.map +1 -0
  110. package/dist/rules/prefer-void-for-optional-param/create.d.ts +8 -0
  111. package/dist/rules/prefer-void-for-optional-param/create.js +188 -0
  112. package/dist/rules/prefer-void-for-optional-param/create.js.map +1 -0
  113. package/dist/rules/prefer-void-for-optional-param/index.d.ts +2 -0
  114. package/dist/rules/prefer-void-for-optional-param/index.js +22 -0
  115. package/dist/rules/prefer-void-for-optional-param/index.js.map +1 -0
  116. package/dist/rules/prefer-void-for-optional-param/rule.d.ts +5 -0
  117. package/dist/rules/prefer-void-for-optional-param/rule.js +14 -0
  118. package/dist/rules/prefer-void-for-optional-param/rule.js.map +1 -0
  119. package/dist/rules/restrict-console-methods/config.d.ts +18 -0
  120. package/dist/rules/restrict-console-methods/config.js +38 -0
  121. package/dist/rules/restrict-console-methods/config.js.map +1 -0
  122. package/dist/rules/restrict-console-methods/create.d.ts +6 -0
  123. package/dist/rules/restrict-console-methods/create.js +34 -0
  124. package/dist/rules/restrict-console-methods/create.js.map +1 -0
  125. package/dist/rules/restrict-console-methods/index.d.ts +2 -0
  126. package/dist/rules/restrict-console-methods/index.js +22 -0
  127. package/dist/rules/restrict-console-methods/index.js.map +1 -0
  128. package/dist/rules/restrict-console-methods/rule.d.ts +5 -0
  129. package/dist/rules/restrict-console-methods/rule.js +14 -0
  130. package/dist/rules/restrict-console-methods/rule.js.map +1 -0
  131. package/dist/rules/restrict-function-usage/config.d.ts +21 -0
  132. package/dist/rules/restrict-function-usage/config.js +62 -0
  133. package/dist/rules/restrict-function-usage/config.js.map +1 -0
  134. package/dist/rules/restrict-function-usage/create.d.ts +6 -0
  135. package/dist/rules/restrict-function-usage/create.js +76 -0
  136. package/dist/rules/restrict-function-usage/create.js.map +1 -0
  137. package/dist/rules/restrict-function-usage/index.d.ts +2 -0
  138. package/dist/rules/restrict-function-usage/index.js +22 -0
  139. package/dist/rules/restrict-function-usage/index.js.map +1 -0
  140. package/dist/rules/restrict-function-usage/rule.d.ts +5 -0
  141. package/dist/rules/restrict-function-usage/rule.js +14 -0
  142. package/dist/rules/restrict-function-usage/rule.js.map +1 -0
  143. package/dist/rules/restrict-imports/config.d.ts +22 -0
  144. package/dist/rules/restrict-imports/config.js +69 -0
  145. package/dist/rules/restrict-imports/config.js.map +1 -0
  146. package/dist/rules/restrict-imports/create.d.ts +6 -0
  147. package/dist/rules/restrict-imports/create.js +92 -0
  148. package/dist/rules/restrict-imports/create.js.map +1 -0
  149. package/dist/rules/restrict-imports/index.d.ts +2 -0
  150. package/dist/rules/restrict-imports/index.js +22 -0
  151. package/dist/rules/restrict-imports/index.js.map +1 -0
  152. package/dist/rules/restrict-imports/rule.d.ts +5 -0
  153. package/dist/rules/restrict-imports/rule.js +14 -0
  154. package/dist/rules/restrict-imports/rule.js.map +1 -0
  155. package/dist/utility/core.js.map +1 -1
  156. package/dist/utility/file-helpers.d.ts +6 -0
  157. package/dist/utility/file-helpers.js +32 -0
  158. package/dist/utility/file-helpers.js.map +1 -0
  159. package/dist/utility/function-helpers.d.ts +4 -4
  160. package/dist/utility/function-helpers.js +17 -15
  161. package/dist/utility/function-helpers.js.map +1 -1
  162. package/dist/utility/type-helpers.d.ts +4 -1
  163. package/dist/utility/type-helpers.js +6 -4
  164. package/dist/utility/type-helpers.js.map +1 -1
  165. package/package.json +75 -73
  166. package/dist/models/boolean-naming-convention.model.js +0 -11
  167. package/dist/models/boolean-naming-convention.model.js.map +0 -1
  168. package/dist/models/no-handler-suffix.model.d.ts +0 -4
  169. package/dist/models/no-handler-suffix.model.js +0 -8
  170. package/dist/models/no-handler-suffix.model.js.map +0 -1
  171. package/dist/models/no-objects-in-deps.model.d.ts +0 -4
  172. package/dist/models/no-objects-in-deps.model.js +0 -8
  173. package/dist/models/no-objects-in-deps.model.js.map +0 -1
  174. package/dist/models/params-naming-convention.model.d.ts +0 -11
  175. package/dist/models/params-naming-convention.model.js +0 -8
  176. package/dist/models/params-naming-convention.model.js.map +0 -1
  177. package/dist/models/prefer-arrow-functions.model.js +0 -10
  178. package/dist/models/prefer-arrow-functions.model.js.map +0 -1
  179. package/dist/models/prefer-export-under-component.model.d.ts +0 -4
  180. package/dist/models/prefer-export-under-component.model.js +0 -8
  181. package/dist/models/prefer-export-under-component.model.js.map +0 -1
  182. package/dist/models/prefer-react-fc.model.d.ts +0 -9
  183. package/dist/models/prefer-react-fc.model.js +0 -8
  184. package/dist/models/prefer-react-fc.model.js.map +0 -1
  185. package/dist/models/prefer-react-with-hooks.model.d.ts +0 -5
  186. package/dist/models/prefer-react-with-hooks.model.js +0 -9
  187. package/dist/models/prefer-react-with-hooks.model.js.map +0 -1
  188. package/dist/models/prefer-void-for-optional-param.model.d.ts +0 -5
  189. package/dist/models/prefer-void-for-optional-param.model.js +0 -9
  190. package/dist/models/prefer-void-for-optional-param.model.js.map +0 -1
  191. package/dist/models/restrict-console-methods.model.d.ts +0 -8
  192. package/dist/models/restrict-console-methods.model.js +0 -8
  193. package/dist/models/restrict-console-methods.model.js.map +0 -1
  194. package/dist/models/restrict-function-usage.model.d.ts +0 -11
  195. package/dist/models/restrict-function-usage.model.js +0 -8
  196. package/dist/models/restrict-function-usage.model.js.map +0 -1
  197. package/dist/models/restrict-imports.model.d.ts +0 -12
  198. package/dist/models/restrict-imports.model.js +0 -8
  199. package/dist/models/restrict-imports.model.js.map +0 -1
  200. package/dist/rules/boolean-naming-convention.d.ts +0 -5
  201. package/dist/rules/boolean-naming-convention.js +0 -379
  202. package/dist/rules/boolean-naming-convention.js.map +0 -1
  203. package/dist/rules/no-handler-suffix.js +0 -89
  204. package/dist/rules/no-handler-suffix.js.map +0 -1
  205. package/dist/rules/no-objects-in-deps.js +0 -90
  206. package/dist/rules/no-objects-in-deps.js.map +0 -1
  207. package/dist/rules/params-naming-convention.d.ts +0 -5
  208. package/dist/rules/params-naming-convention.js +0 -95
  209. package/dist/rules/params-naming-convention.js.map +0 -1
  210. package/dist/rules/prefer-arrow-functions.js +0 -208
  211. package/dist/rules/prefer-arrow-functions.js.map +0 -1
  212. package/dist/rules/prefer-export-under-component.js +0 -113
  213. package/dist/rules/prefer-export-under-component.js.map +0 -1
  214. package/dist/rules/prefer-react-fc.js +0 -204
  215. package/dist/rules/prefer-react-fc.js.map +0 -1
  216. package/dist/rules/prefer-react-with-hooks.js +0 -185
  217. package/dist/rules/prefer-react-with-hooks.js.map +0 -1
  218. package/dist/rules/prefer-void-for-optional-param.d.ts +0 -6
  219. package/dist/rules/prefer-void-for-optional-param.js +0 -188
  220. package/dist/rules/prefer-void-for-optional-param.js.map +0 -1
  221. package/dist/rules/restrict-console-methods.d.ts +0 -5
  222. package/dist/rules/restrict-console-methods.js +0 -66
  223. package/dist/rules/restrict-console-methods.js.map +0 -1
  224. package/dist/rules/restrict-function-usage.js +0 -121
  225. package/dist/rules/restrict-function-usage.js.map +0 -1
  226. package/dist/rules/restrict-imports.js +0 -135
  227. package/dist/rules/restrict-imports.js.map +0 -1
@@ -0,0 +1,415 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = void 0;
4
+ const boolean_prefixes_1 = require("../../constants/boolean-prefixes");
5
+ const utils_1 = require("@typescript-eslint/utils");
6
+ const type_helpers_1 = require("../../utility/type-helpers");
7
+ const config_1 = require("./config");
8
+ const create = (context, [options]) => {
9
+ const { allowedPrefixes = boolean_prefixes_1.DEFAULT_PREFIXES, checkFunctions = true, checkParameters = true, checkProperties = true, checkVariables = true, ignore = "filter", } = options;
10
+ const services = context.sourceCode.parserServices;
11
+ const checker = services?.program?.getTypeChecker();
12
+ const hasValidBooleanPrefix = (name) => {
13
+ return allowedPrefixes?.some((prefix) => name.toLowerCase().startsWith(prefix.toLowerCase()));
14
+ };
15
+ let ignoreRegex = null;
16
+ try {
17
+ ignoreRegex = new RegExp(ignore, "i");
18
+ }
19
+ catch {
20
+ ignoreRegex = null;
21
+ }
22
+ const generateSuggestion = (name) => {
23
+ return `is${name.charAt(0).toUpperCase()}${name.slice(1)}`;
24
+ };
25
+ const isBooleanType = (node) => {
26
+ try {
27
+ const type = (0, type_helpers_1.getType)({ context, node });
28
+ return type === "boolean" || type === "true" || type === "false";
29
+ }
30
+ catch {
31
+ return false;
32
+ }
33
+ };
34
+ const isParamBoolean = (node) => {
35
+ const reported = new Set();
36
+ for (const param of node.params) {
37
+ if (param.type === utils_1.AST_NODE_TYPES.Identifier &&
38
+ param.typeAnnotation?.typeAnnotation.type ===
39
+ utils_1.AST_NODE_TYPES.TSBooleanKeyword) {
40
+ checkNameOnce({
41
+ name: param.name,
42
+ node: param,
43
+ reported,
44
+ });
45
+ }
46
+ if (param.type === utils_1.AST_NODE_TYPES.Identifier &&
47
+ param.typeAnnotation?.typeAnnotation.type ===
48
+ utils_1.AST_NODE_TYPES.TSTypeLiteral) {
49
+ for (const member of param.typeAnnotation.typeAnnotation
50
+ .members) {
51
+ if (member.type === utils_1.AST_NODE_TYPES.TSPropertySignature &&
52
+ member.typeAnnotation?.typeAnnotation.type ===
53
+ utils_1.AST_NODE_TYPES.TSBooleanKeyword &&
54
+ member.key.type === utils_1.AST_NODE_TYPES.Identifier) {
55
+ checkNameOnce({
56
+ name: member.key.name,
57
+ node: member,
58
+ reported,
59
+ });
60
+ }
61
+ }
62
+ }
63
+ if (param.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
64
+ checkObjectPattern({
65
+ pattern: param,
66
+ reported,
67
+ typeAnnotation: param.typeAnnotation?.typeAnnotation,
68
+ });
69
+ }
70
+ }
71
+ };
72
+ const checkObjectPattern = ({ pattern, reported, typeAnnotation, }) => {
73
+ for (const prop of pattern.properties) {
74
+ if (prop.type === utils_1.AST_NODE_TYPES.Property) {
75
+ const propKey = prop.key;
76
+ const propValue = prop.value;
77
+ if (propKey.type === utils_1.AST_NODE_TYPES.Identifier &&
78
+ propValue.type === utils_1.AST_NODE_TYPES.Identifier) {
79
+ const hasDirectAnnotation = propValue.typeAnnotation?.typeAnnotation.type ===
80
+ utils_1.AST_NODE_TYPES.TSBooleanKeyword;
81
+ if (hasDirectAnnotation) {
82
+ checkNameOnce({
83
+ name: propKey.name,
84
+ node: propKey,
85
+ reported,
86
+ });
87
+ }
88
+ else if (typeAnnotation?.type === utils_1.AST_NODE_TYPES.TSTypeLiteral) {
89
+ for (const member of typeAnnotation.members) {
90
+ if (member.type ===
91
+ utils_1.AST_NODE_TYPES.TSPropertySignature &&
92
+ member.key.type === utils_1.AST_NODE_TYPES.Identifier &&
93
+ member.key.name === propKey.name &&
94
+ member.typeAnnotation?.typeAnnotation.type ===
95
+ utils_1.AST_NODE_TYPES.TSBooleanKeyword) {
96
+ checkNameOnce({
97
+ name: propKey.name,
98
+ node: propKey,
99
+ reported,
100
+ });
101
+ break;
102
+ }
103
+ }
104
+ }
105
+ }
106
+ else if (propKey.type === utils_1.AST_NODE_TYPES.Identifier &&
107
+ propValue.type === utils_1.AST_NODE_TYPES.ObjectPattern &&
108
+ typeAnnotation?.type === utils_1.AST_NODE_TYPES.TSTypeLiteral) {
109
+ for (const member of typeAnnotation.members) {
110
+ if (member.type ===
111
+ utils_1.AST_NODE_TYPES.TSPropertySignature &&
112
+ member.key.type === utils_1.AST_NODE_TYPES.Identifier &&
113
+ member.key.name === propKey.name) {
114
+ checkObjectPattern({
115
+ pattern: propValue,
116
+ reported,
117
+ typeAnnotation: member.typeAnnotation?.typeAnnotation,
118
+ });
119
+ break;
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
125
+ };
126
+ const checkNameOnce = ({ name, node, reported, }) => {
127
+ const key = `${name}-${node.loc.start.line}`;
128
+ if (reported && reported.has(key)) {
129
+ return;
130
+ }
131
+ if (ignoreRegex && ignoreRegex.test(name)) {
132
+ return;
133
+ }
134
+ if (!hasValidBooleanPrefix(name)) {
135
+ reported?.add(key);
136
+ context.report({
137
+ data: {
138
+ name,
139
+ suggestion: generateSuggestion(name),
140
+ },
141
+ messageId: config_1.Messages.BAD_PARAMETER_BOOLEAN_PREFIX,
142
+ node,
143
+ });
144
+ }
145
+ };
146
+ const functionReturnsBooleanType = (node) => {
147
+ try {
148
+ const tsNode = services?.esTreeNodeToTSNodeMap?.get(node);
149
+ if (!tsNode) {
150
+ return false;
151
+ }
152
+ const signature = checker?.getSignatureFromDeclaration(tsNode);
153
+ if (signature && checker) {
154
+ const returnType = checker.getReturnTypeOfSignature(signature);
155
+ const returnTypeString = checker.typeToString(returnType);
156
+ return (returnTypeString === "boolean" ||
157
+ returnTypeString === "true" ||
158
+ returnTypeString === "false");
159
+ }
160
+ return false;
161
+ }
162
+ catch {
163
+ return false;
164
+ }
165
+ };
166
+ return {
167
+ ArrowFunctionExpression: (node) => {
168
+ if (checkParameters) {
169
+ isParamBoolean(node);
170
+ }
171
+ },
172
+ FunctionDeclaration: (node) => {
173
+ if (!checkFunctions) {
174
+ return;
175
+ }
176
+ if (node.id && functionReturnsBooleanType(node)) {
177
+ const name = node.id.name;
178
+ if (ignoreRegex && ignoreRegex.test(name)) {
179
+ return;
180
+ }
181
+ if (!hasValidBooleanPrefix(name)) {
182
+ context.report({
183
+ data: {
184
+ name,
185
+ suggestion: generateSuggestion(name),
186
+ },
187
+ messageId: config_1.Messages.BAD_FUNCTION_BOOLEAN_PREFIX,
188
+ node: node.id,
189
+ });
190
+ }
191
+ }
192
+ if (checkParameters) {
193
+ isParamBoolean(node);
194
+ }
195
+ },
196
+ FunctionExpression: (node) => {
197
+ if (checkParameters) {
198
+ isParamBoolean(node);
199
+ }
200
+ },
201
+ ObjectExpression: (node) => {
202
+ if (!checkProperties) {
203
+ return;
204
+ }
205
+ for (const prop of node.properties) {
206
+ if (prop.type === utils_1.AST_NODE_TYPES.Property &&
207
+ prop.key.type === utils_1.AST_NODE_TYPES.Identifier &&
208
+ !prop.computed &&
209
+ prop.value &&
210
+ (isBooleanType(prop.value) ||
211
+ ((prop.value.type ===
212
+ utils_1.AST_NODE_TYPES.FunctionExpression ||
213
+ prop.value.type ===
214
+ utils_1.AST_NODE_TYPES.ArrowFunctionExpression) &&
215
+ functionReturnsBooleanType(prop.value)))) {
216
+ const name = prop.key.name;
217
+ if (ignoreRegex && ignoreRegex.test(name)) {
218
+ continue;
219
+ }
220
+ if (!hasValidBooleanPrefix(name)) {
221
+ context.report({
222
+ data: {
223
+ name,
224
+ suggestion: generateSuggestion(name),
225
+ },
226
+ messageId: config_1.Messages.BAD_PROPERTY_BOOLEAN_PREFIX,
227
+ node: prop.key,
228
+ });
229
+ }
230
+ }
231
+ }
232
+ },
233
+ Property: (node) => {
234
+ if (node.parent?.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
235
+ let current = node.parent;
236
+ while (current) {
237
+ if (current.type ===
238
+ utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
239
+ current.type === utils_1.AST_NODE_TYPES.FunctionExpression ||
240
+ current.type === utils_1.AST_NODE_TYPES.FunctionDeclaration) {
241
+ return;
242
+ }
243
+ current = current.parent;
244
+ }
245
+ }
246
+ if (!checkParameters) {
247
+ return;
248
+ }
249
+ if (node.key.type === utils_1.AST_NODE_TYPES.Identifier &&
250
+ node.value.type === utils_1.AST_NODE_TYPES.Identifier &&
251
+ node.parent?.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
252
+ let current = node.parent;
253
+ while (current && current.type !== utils_1.AST_NODE_TYPES.Identifier) {
254
+ current = current.parent;
255
+ }
256
+ let param = node.parent;
257
+ while (param && param.parent) {
258
+ if (param.parent.type ===
259
+ utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
260
+ param.parent.type ===
261
+ utils_1.AST_NODE_TYPES.FunctionExpression ||
262
+ param.parent.type === utils_1.AST_NODE_TYPES.FunctionDeclaration) {
263
+ break;
264
+ }
265
+ param = param.parent;
266
+ }
267
+ if (param &&
268
+ "typeAnnotation" in param &&
269
+ param.typeAnnotation) {
270
+ const typeAnnotation = param.typeAnnotation;
271
+ if (typeAnnotation.typeAnnotation.type ===
272
+ utils_1.AST_NODE_TYPES.TSTypeLiteral) {
273
+ const typeLiteral = typeAnnotation.typeAnnotation;
274
+ const propertyType = typeLiteral.members.find((member) => {
275
+ if (member.type ===
276
+ utils_1.AST_NODE_TYPES.TSPropertySignature &&
277
+ member.key?.type ===
278
+ utils_1.AST_NODE_TYPES.Identifier &&
279
+ member.key.name ===
280
+ node.key.name) {
281
+ return (member.typeAnnotation?.typeAnnotation
282
+ .type ===
283
+ utils_1.AST_NODE_TYPES.TSBooleanKeyword);
284
+ }
285
+ return false;
286
+ });
287
+ if (propertyType) {
288
+ const name = node.value.name;
289
+ if (ignoreRegex && ignoreRegex.test(name)) {
290
+ return;
291
+ }
292
+ if (!hasValidBooleanPrefix(name)) {
293
+ context.report({
294
+ data: {
295
+ name,
296
+ suggestion: generateSuggestion(name),
297
+ },
298
+ messageId: config_1.Messages.BAD_PARAMETER_BOOLEAN_PREFIX,
299
+ node: node.value,
300
+ });
301
+ }
302
+ }
303
+ }
304
+ }
305
+ }
306
+ },
307
+ VariableDeclarator: (node) => {
308
+ if (node.id.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
309
+ if (!checkParameters) {
310
+ return;
311
+ }
312
+ if (node.init) {
313
+ for (const prop of node.id.properties) {
314
+ if (prop.type === utils_1.AST_NODE_TYPES.Property &&
315
+ prop.key.type === utils_1.AST_NODE_TYPES.Identifier &&
316
+ prop.value.type === utils_1.AST_NODE_TYPES.Identifier) {
317
+ const valueName = prop.value.name;
318
+ try {
319
+ const tsNode = services?.esTreeNodeToTSNodeMap?.get(prop.value);
320
+ if (tsNode && checker) {
321
+ const type = checker.getTypeAtLocation(tsNode);
322
+ const typeString = checker.typeToString(type);
323
+ if (typeString === "boolean" ||
324
+ typeString === "true" ||
325
+ typeString === "false") {
326
+ if (ignoreRegex &&
327
+ ignoreRegex.test(valueName)) {
328
+ continue;
329
+ }
330
+ if (!hasValidBooleanPrefix(valueName)) {
331
+ context.report({
332
+ data: {
333
+ name: valueName,
334
+ suggestion: generateSuggestion(valueName),
335
+ },
336
+ messageId: config_1.Messages.BAD_VARIABLE_BOOLEAN_PREFIX,
337
+ node: prop.value,
338
+ });
339
+ }
340
+ }
341
+ }
342
+ }
343
+ catch {
344
+ // Intentionally ignore errors during type checking
345
+ }
346
+ }
347
+ }
348
+ }
349
+ }
350
+ if (!checkVariables) {
351
+ return;
352
+ }
353
+ if (node.id.type === utils_1.AST_NODE_TYPES.Identifier) {
354
+ if (node.id.typeAnnotation?.typeAnnotation.type ===
355
+ utils_1.AST_NODE_TYPES.TSBooleanKeyword) {
356
+ const name = node.id.name;
357
+ if (ignoreRegex && ignoreRegex.test(name)) {
358
+ return;
359
+ }
360
+ if (!hasValidBooleanPrefix(name)) {
361
+ context.report({
362
+ data: {
363
+ name,
364
+ suggestion: generateSuggestion(name),
365
+ },
366
+ messageId: config_1.Messages.BAD_VARIABLE_BOOLEAN_PREFIX,
367
+ node: node.id,
368
+ });
369
+ }
370
+ return;
371
+ }
372
+ if (node.init) {
373
+ if ((node.init.type ===
374
+ utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
375
+ node.init.type ===
376
+ utils_1.AST_NODE_TYPES.FunctionExpression) &&
377
+ functionReturnsBooleanType(node.init)) {
378
+ const name = node.id.name;
379
+ if (ignoreRegex && ignoreRegex.test(name)) {
380
+ return;
381
+ }
382
+ if (!hasValidBooleanPrefix(name)) {
383
+ context.report({
384
+ data: {
385
+ name,
386
+ suggestion: generateSuggestion(name),
387
+ },
388
+ messageId: config_1.Messages.BAD_FUNCTION_BOOLEAN_PREFIX,
389
+ node: node.id,
390
+ });
391
+ }
392
+ }
393
+ else if (isBooleanType(node.init)) {
394
+ const name = node.id.name;
395
+ if (ignoreRegex && ignoreRegex.test(name)) {
396
+ return;
397
+ }
398
+ if (!hasValidBooleanPrefix(name)) {
399
+ context.report({
400
+ data: {
401
+ name,
402
+ suggestion: generateSuggestion(name),
403
+ },
404
+ messageId: config_1.Messages.BAD_VARIABLE_BOOLEAN_PREFIX,
405
+ node: node.id,
406
+ });
407
+ }
408
+ }
409
+ }
410
+ }
411
+ },
412
+ };
413
+ };
414
+ exports.create = create;
415
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/rules/boolean-naming-convention/create.ts"],"names":[],"mappings":";;;AAAA,kEAA+D;AAC/D,oDAAyE;AAEzE,wDAAgD;AAEhD,qCAAkD;AAE3C,MAAM,MAAM,GAAG,CAClB,OAAuC,EACvC,CAAC,OAAO,CAA6B,EACvC,EAAE;IACA,MAAM,EACF,eAAe,GAAG,mCAAgB,EAClC,cAAc,GAAG,IAAI,EACrB,eAAe,GAAG,IAAI,EACtB,eAAe,GAAG,IAAI,EACtB,cAAc,GAAG,IAAI,EACrB,MAAM,GAAG,QAAQ,GACpB,GAAG,OAAO,CAAC;IAEZ,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC;IAEnD,MAAM,OAAO,GAAG,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;IAEpD,MAAM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ACJ,CAAC;AACN,CAAC,CAAC;AA5gBW,QAAA,MAAM,UA4gBjB"}
@@ -0,0 +1,2 @@
1
+ export { config, Messages } from "./config";
2
+ export * from "./rule";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Messages = exports.config = void 0;
18
+ var config_1 = require("./config");
19
+ Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_1.config; } });
20
+ Object.defineProperty(exports, "Messages", { enumerable: true, get: function () { return config_1.Messages; } });
21
+ __exportStar(require("./rule"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/boolean-naming-convention/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAA4C;AAAnC,gGAAA,MAAM,OAAA;AAAE,kGAAA,QAAQ,OAAA;AACzB,yCAAuB"}
@@ -1,5 +1,5 @@
1
- import { Messages, Options } from "../models/restrict-imports.model";
2
- export declare const name = "restrict-imports";
1
+ import { Messages, name, type Options } from "./config";
2
+ export { name };
3
3
  export declare const rule: import("@typescript-eslint/utils/ts-eslint").RuleModule<Messages, Options, {
4
4
  recommended: boolean;
5
5
  }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rule = exports.name = void 0;
4
+ const core_1 = require("../../utility/core");
5
+ const config_1 = require("./config");
6
+ Object.defineProperty(exports, "name", { enumerable: true, get: function () { return config_1.name; } });
7
+ const create_1 = require("./create");
8
+ exports.rule = (0, core_1.createRule)({
9
+ create: create_1.create,
10
+ defaultOptions: config_1.defaultOptions,
11
+ meta: config_1.config,
12
+ name: config_1.name,
13
+ });
14
+ //# sourceMappingURL=rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule.js","sourceRoot":"","sources":["../../../src/rules/boolean-naming-convention/rule.ts"],"names":[],"mappings":";;;AAAA,wCAA2C;AAE3C,qCAAgF;AAGvE,qFAHkC,aAAI,OAGlC;AAFb,qCAAkC;AAIrB,QAAA,IAAI,GAAG,IAAA,iBAAU,EAAoB;IAC9C,MAAM,EAAN,eAAM;IACN,cAAc,EAAd,uBAAc;IACd,IAAI,EAAE,eAAM;IACZ,IAAI,EAAJ,aAAI;CACP,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ export * as BooleanNamingConvention from "./boolean-naming-convention";
2
+ export * as NoHandlerSuffix from "./no-handler-suffix";
3
+ export * as NoObjectsInDeps from "./no-objects-in-deps";
4
+ export * as ParamsNamingConvention from "./params-naming-convention";
5
+ export * as PreferArrowFunctions from "./prefer-arrow-functions";
6
+ export * as PreferExportUnderComponent from "./prefer-export-under-component";
7
+ export * as PreferReactFc from "./prefer-react-fc";
8
+ export * as PreferReactWithHooks from "./prefer-react-with-hooks";
9
+ export * as PreferVoidForOptionalParam from "./prefer-void-for-optional-param";
10
+ export * as RestrictConsoleMethods from "./restrict-console-methods";
11
+ export * as RestrictFunctionUsage from "./restrict-function-usage";
12
+ export * as RestrictImports from "./restrict-imports";
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.RestrictImports = exports.RestrictFunctionUsage = exports.RestrictConsoleMethods = exports.PreferVoidForOptionalParam = exports.PreferReactWithHooks = exports.PreferReactFc = exports.PreferExportUnderComponent = exports.PreferArrowFunctions = exports.ParamsNamingConvention = exports.NoObjectsInDeps = exports.NoHandlerSuffix = exports.BooleanNamingConvention = void 0;
37
+ exports.BooleanNamingConvention = __importStar(require("./boolean-naming-convention"));
38
+ exports.NoHandlerSuffix = __importStar(require("./no-handler-suffix"));
39
+ exports.NoObjectsInDeps = __importStar(require("./no-objects-in-deps"));
40
+ exports.ParamsNamingConvention = __importStar(require("./params-naming-convention"));
41
+ exports.PreferArrowFunctions = __importStar(require("./prefer-arrow-functions"));
42
+ exports.PreferExportUnderComponent = __importStar(require("./prefer-export-under-component"));
43
+ exports.PreferReactFc = __importStar(require("./prefer-react-fc"));
44
+ exports.PreferReactWithHooks = __importStar(require("./prefer-react-with-hooks"));
45
+ exports.PreferVoidForOptionalParam = __importStar(require("./prefer-void-for-optional-param"));
46
+ exports.RestrictConsoleMethods = __importStar(require("./restrict-console-methods"));
47
+ exports.RestrictFunctionUsage = __importStar(require("./restrict-function-usage"));
48
+ exports.RestrictImports = __importStar(require("./restrict-imports"));
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uFAAuE;AACvE,uEAAuD;AACvD,wEAAwD;AACxD,qFAAqE;AACrE,iFAAiE;AACjE,8FAA8E;AAC9E,mEAAmD;AACnD,kFAAkE;AAClE,+FAA+E;AAC/E,qFAAqE;AACrE,mFAAmE;AACnE,sEAAsD"}
@@ -0,0 +1,14 @@
1
+ import { RuleModule } from "@typescript-eslint/utils/ts-eslint";
2
+ export declare const name = "no-handler-suffix";
3
+ export declare const enum Messages {
4
+ BAD_HANDLER_NAME = "BAD_HANDLER_NAME"
5
+ }
6
+ export type Options = [];
7
+ type ExtendedPluginProperties = {
8
+ recommended: boolean;
9
+ };
10
+ export declare const config: {
11
+ docs: ExtendedPluginProperties & RuleModule<Messages, Options>["meta"]["docs"];
12
+ } & Omit<RuleModule<Messages, Options>["meta"], "defaultOptions">;
13
+ export declare const defaultOptions: Options;
14
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultOptions = exports.config = exports.Messages = exports.name = void 0;
4
+ exports.name = "no-handler-suffix";
5
+ var Messages;
6
+ (function (Messages) {
7
+ Messages["BAD_HANDLER_NAME"] = "BAD_HANDLER_NAME";
8
+ })(Messages || (exports.Messages = Messages = {}));
9
+ exports.config = {
10
+ docs: {
11
+ description: "Suggests to use handleFn instead of fnHandler",
12
+ recommended: true,
13
+ url: "https://github.com/NIMA-Enterprises/eslint-plugin-nima/blob/main/documentation/rules/no-handler-suffix.md",
14
+ },
15
+ fixable: "code",
16
+ messages: {
17
+ [Messages.BAD_HANDLER_NAME]: "NIMA: You shouldn't use the handler suffix, use the handle prefix instead ({{ fnWithGoodName }})",
18
+ },
19
+ schema: [],
20
+ type: "problem",
21
+ };
22
+ exports.defaultOptions = [];
23
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/rules/no-handler-suffix/config.ts"],"names":[],"mappings":";;;AAEa,QAAA,IAAI,GAAG,mBAAmB,CAAC;AAExC,IAAkB,QAEjB;AAFD,WAAkB,QAAQ;IACtB,iDAAqC,CAAA;AACzC,CAAC,EAFiB,QAAQ,wBAAR,QAAQ,QAEzB;AAQY,QAAA,MAAM,GAGiD;IAChE,IAAI,EAAE;QACF,WAAW,EAAE,+CAA+C;QAC5D,WAAW,EAAE,IAAI;QACjB,GAAG,EAAE,2GAA2G;KACnH;IACD,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE;QACN,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EACvB,kGAAkG;KACzG;IACD,MAAM,EAAE,EAAE;IACV,IAAI,EAAE,SAAS;CAClB,CAAC;AAEW,QAAA,cAAc,GAAY,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type TSESTree } from "@typescript-eslint/utils";
2
+ import { RuleContext } from "@typescript-eslint/utils/ts-eslint";
3
+ import { Messages, type Options } from "./config";
4
+ export declare const create: (context: RuleContext<Messages, Options>) => {
5
+ ArrowFunctionExpression: (node: TSESTree.ArrowFunctionExpression) => void;
6
+ FunctionDeclaration: (node: TSESTree.FunctionDeclaration) => void;
7
+ FunctionExpression: (node: TSESTree.FunctionExpression) => void;
8
+ };