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,188 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = void 0;
4
+ const utils_1 = require("@typescript-eslint/utils");
5
+ const config_1 = require("./config");
6
+ const areAllPropertiesOptional = (typeAnnotation) => {
7
+ if (typeAnnotation.type !== utils_1.AST_NODE_TYPES.TSTypeLiteral) {
8
+ return false;
9
+ }
10
+ const propertySignatures = typeAnnotation.members.filter((member) => member.type === utils_1.AST_NODE_TYPES.TSPropertySignature);
11
+ if (propertySignatures.length === 0) {
12
+ return false;
13
+ }
14
+ return propertySignatures.every((member) => member.type === utils_1.AST_NODE_TYPES.TSPropertySignature &&
15
+ member.optional);
16
+ };
17
+ const buildTypeWithVoid = ({ hasVoid, typeAnnotation, typeText, }) => {
18
+ let cleanTypeText = typeText.replace(/^:\s*/, "");
19
+ if (!hasVoid) {
20
+ const isNeedsParentheses = typeAnnotation.type !== utils_1.AST_NODE_TYPES.TSTypeLiteral &&
21
+ typeAnnotation.type !== utils_1.AST_NODE_TYPES.TSTypeReference &&
22
+ typeAnnotation.type !== utils_1.AST_NODE_TYPES.TSUnionType;
23
+ cleanTypeText = isNeedsParentheses
24
+ ? `(${cleanTypeText}) | void`
25
+ : `${cleanTypeText} | void`;
26
+ }
27
+ return cleanTypeText;
28
+ };
29
+ const extractProperties = ({ param, sourceCode, }) => {
30
+ const properties = [];
31
+ for (const prop of param.properties) {
32
+ if (prop.type === utils_1.AST_NODE_TYPES.Property &&
33
+ prop.key.type === utils_1.AST_NODE_TYPES.Identifier) {
34
+ const propName = prop.key.name;
35
+ if (prop.value.type === utils_1.AST_NODE_TYPES.AssignmentPattern) {
36
+ const defaultValue = sourceCode.getText(prop.value.right);
37
+ properties.push(`${propName} = ${defaultValue}`);
38
+ }
39
+ else {
40
+ properties.push(propName);
41
+ }
42
+ }
43
+ else if (prop.type === utils_1.AST_NODE_TYPES.RestElement &&
44
+ prop.argument.type === utils_1.AST_NODE_TYPES.Identifier) {
45
+ properties.push(`...${prop.argument.name}`);
46
+ }
47
+ }
48
+ return properties;
49
+ };
50
+ const hasVoidOrUndefinedInUnion = ({ typeAnnotation, }) => {
51
+ let hasVoid = false;
52
+ let hasUndefined = false;
53
+ let baseType = typeAnnotation;
54
+ if (typeAnnotation.type === utils_1.AST_NODE_TYPES.TSUnionType) {
55
+ hasVoid = typeAnnotation.types.some((t) => t.type === utils_1.AST_NODE_TYPES.TSVoidKeyword);
56
+ hasUndefined = typeAnnotation.types.some((t) => t.type === utils_1.AST_NODE_TYPES.TSUndefinedKeyword);
57
+ const nonVoidUndefinedType = typeAnnotation.types.find((t) => t.type !== utils_1.AST_NODE_TYPES.TSVoidKeyword &&
58
+ t.type !== utils_1.AST_NODE_TYPES.TSUndefinedKeyword);
59
+ if (nonVoidUndefinedType) {
60
+ baseType = nonVoidUndefinedType;
61
+ }
62
+ }
63
+ return { baseType, hasUndefined, hasVoid };
64
+ };
65
+ const create = (context) => {
66
+ const sourceCode = context.sourceCode;
67
+ const checkFunction = (node) => {
68
+ const paramsToFix = [];
69
+ for (let paramIndex = 0; paramIndex < node.params.length; paramIndex++) {
70
+ let param = node.params[paramIndex];
71
+ let hasParamDefault = false;
72
+ let paramDefaultValue = "";
73
+ if (param.type === utils_1.AST_NODE_TYPES.AssignmentPattern) {
74
+ hasParamDefault = true;
75
+ paramDefaultValue = sourceCode.getText(param.right);
76
+ param = param.left;
77
+ }
78
+ if (param.type !== utils_1.AST_NODE_TYPES.ObjectPattern) {
79
+ continue;
80
+ }
81
+ if (!param.typeAnnotation) {
82
+ continue;
83
+ }
84
+ const typeAnnotation = param.typeAnnotation.typeAnnotation;
85
+ const { baseType, hasUndefined, hasVoid } = hasVoidOrUndefinedInUnion({
86
+ typeAnnotation,
87
+ });
88
+ const hasVoidOrUndefined = hasVoid || hasUndefined;
89
+ const areAllPropsOptional = areAllPropertiesOptional(baseType);
90
+ if (!hasVoidOrUndefined &&
91
+ !areAllPropsOptional &&
92
+ !hasParamDefault) {
93
+ continue;
94
+ }
95
+ const originalParam = node.params[paramIndex];
96
+ const typeText = sourceCode.getText(param.typeAnnotation);
97
+ const properties = extractProperties({
98
+ param,
99
+ sourceCode,
100
+ });
101
+ const paramName = paramsToFix.length === 0
102
+ ? "props"
103
+ : `props${paramsToFix.length + 1}`;
104
+ paramsToFix.push({
105
+ areAllPropsOptional,
106
+ hasParamDefault,
107
+ hasVoidOrUndefined,
108
+ originalParam,
109
+ param,
110
+ paramDefaultValue,
111
+ paramIndex,
112
+ paramName,
113
+ properties,
114
+ typeAnnotation,
115
+ typeText,
116
+ });
117
+ }
118
+ for (const paramData of paramsToFix) {
119
+ const { hasVoidOrUndefined, param } = paramData;
120
+ context.report({
121
+ fix: (fixer) => {
122
+ const allDestructuringStatements = paramsToFix
123
+ .map((p) => {
124
+ const props = p.properties.join(", ");
125
+ return `const { ${props} } = ${p.paramName} ?? {};`;
126
+ })
127
+ .join("\n ");
128
+ const fixes = [];
129
+ for (const fixData of paramsToFix) {
130
+ const { hasVoid: isPHasVoid } = hasVoidOrUndefinedInUnion({
131
+ typeAnnotation: fixData.typeAnnotation,
132
+ });
133
+ const pCleanTypeText = buildTypeWithVoid({
134
+ hasVoid: isPHasVoid,
135
+ typeAnnotation: fixData.typeAnnotation,
136
+ typeText: fixData.typeText,
137
+ });
138
+ let pNewParam = `${fixData.paramName}: ${pCleanTypeText}`;
139
+ if (fixData.hasParamDefault &&
140
+ node.body.type === utils_1.AST_NODE_TYPES.BlockStatement) {
141
+ pNewParam += ` = ${fixData.paramDefaultValue}`;
142
+ }
143
+ fixes.push(fixer.replaceTextRange(fixData.originalParam.range, pNewParam));
144
+ }
145
+ if (node.body.type === utils_1.AST_NODE_TYPES.BlockStatement) {
146
+ const firstStatement = node.body.body[0];
147
+ if (firstStatement) {
148
+ fixes.push(fixer.replaceTextRange([
149
+ node.body.range[0] + 1,
150
+ firstStatement.range[0],
151
+ ], `\n\n ${allDestructuringStatements}\n `));
152
+ }
153
+ else {
154
+ fixes.push(fixer.insertTextAfterRange([
155
+ node.body.range[0] + 1,
156
+ node.body.range[0] + 1,
157
+ ], `\n ${allDestructuringStatements}\n`));
158
+ }
159
+ return fixes;
160
+ }
161
+ else {
162
+ const bodyText = sourceCode.getText(node.body);
163
+ const newBody = ` {\n ${allDestructuringStatements}\n return ${bodyText};\n}`;
164
+ const arrowToken = sourceCode.getTokenBefore(node.body, (token) => token.value === "=>");
165
+ if (arrowToken) {
166
+ fixes.push(fixer.replaceTextRange([arrowToken.range[1], node.range[1]], newBody));
167
+ }
168
+ else {
169
+ fixes.push(fixer.replaceText(node.body, newBody));
170
+ }
171
+ return fixes;
172
+ }
173
+ },
174
+ messageId: hasVoidOrUndefined
175
+ ? config_1.Messages.PREFER_VOID_FOR_OPTIONAL_PARAM
176
+ : config_1.Messages.ADD_VOID_UNION,
177
+ node: param,
178
+ });
179
+ }
180
+ };
181
+ return {
182
+ ArrowFunctionExpression: checkFunction,
183
+ FunctionDeclaration: checkFunction,
184
+ FunctionExpression: checkFunction,
185
+ };
186
+ };
187
+ exports.create = create;
188
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/rules/prefer-void-for-optional-param/create.ts"],"names":[],"mappings":";;;AAAA,oDAIkC;AAGlC,qCAAkD;AAElD,MAAM,wBAAwB,GAAG,CAC7B,cAAiC,EAC1B,EAAE;IACT,IAAI,cAAc,CAAC,IAAI,KAAK,sBAAc,CAAC,aAAa,EAAE,CAAC;QACvD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,kBAAkB,GAAG,cAAc,CAAC,OAAO,CAAC,MAAM,CACpD,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,mBAAmB,CACjE,CAAC;IAEF,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,kBAAkB,CAAC,KA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 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/prefer-void-for-optional-param/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAA4C;AAAnC,gGAAA,MAAM,OAAA;AAAE,kGAAA,QAAQ,OAAA;AACzB,yCAAuB"}
@@ -0,0 +1,5 @@
1
+ import { Messages, name } from "./config";
2
+ export { name };
3
+ export declare const rule: import("@typescript-eslint/utils/ts-eslint").RuleModule<Messages, [], {
4
+ recommended: boolean;
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/prefer-void-for-optional-param/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,18 @@
1
+ import { RuleModule } from "@typescript-eslint/utils/ts-eslint";
2
+ export declare const name = "restrict-console-methods";
3
+ export declare const enum Messages {
4
+ NO_CONSOLE = "NO_CONSOLE"
5
+ }
6
+ export type Options = [
7
+ Partial<{
8
+ allow: string[];
9
+ }>
10
+ ];
11
+ type ExtendedPluginProperties = {
12
+ recommended: boolean;
13
+ };
14
+ export declare const config: {
15
+ docs: ExtendedPluginProperties & RuleModule<Messages, Options>["meta"]["docs"];
16
+ } & Omit<RuleModule<Messages, Options>["meta"], "defaultOptions">;
17
+ export declare const defaultOptions: Options;
18
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultOptions = exports.config = exports.Messages = exports.name = void 0;
4
+ exports.name = "restrict-console-methods";
5
+ var Messages;
6
+ (function (Messages) {
7
+ Messages["NO_CONSOLE"] = "NO_CONSOLE";
8
+ })(Messages || (exports.Messages = Messages = {}));
9
+ exports.config = {
10
+ docs: {
11
+ description: "Restrict the usage of console in the codebase",
12
+ recommended: true,
13
+ url: "https://github.com/NIMA-Enterprises/eslint-plugin-nima/blob/main/documentation/rules/restrict-console-methods.md",
14
+ },
15
+ messages: {
16
+ [Messages.NO_CONSOLE]: "NIMA: The usage of console.{{ console }} is restricted.",
17
+ },
18
+ schema: [
19
+ {
20
+ additionalProperties: false,
21
+ properties: {
22
+ allow: {
23
+ description: "List of console methods to allow",
24
+ items: { type: "string" },
25
+ type: "array",
26
+ },
27
+ },
28
+ type: "object",
29
+ },
30
+ ],
31
+ type: "suggestion",
32
+ };
33
+ exports.defaultOptions = [
34
+ {
35
+ allow: ["info"],
36
+ },
37
+ ];
38
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/rules/restrict-console-methods/config.ts"],"names":[],"mappings":";;;AAEa,QAAA,IAAI,GAAG,0BAA0B,CAAC;AAE/C,IAAkB,QAEjB;AAFD,WAAkB,QAAQ;IACtB,qCAAyB,CAAA;AAC7B,CAAC,EAFiB,QAAQ,wBAAR,QAAQ,QAEzB;AAYY,QAAA,MAAM,GAGiD;IAChE,IAAI,EAAE;QACF,WAAW,EAAE,+CAA+C;QAC5D,WAAW,EAAE,IAAI;QACjB,GAAG,EAAE,kHAAkH;KAC1H;IACD,QAAQ,EAAE;QACN,CAAC,QAAQ,CAAC,UAAU,CAAC,EACjB,yDAAyD;KAChE;IACD,MAAM,EAAE;QACJ;YACI,oBAAoB,EAAE,KAAK;YAC3B,UAAU,EAAE;gBACR,KAAK,EAAE;oBACH,WAAW,EAAE,kCAAkC;oBAC/C,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,IAAI,EAAE,OAAO;iBAChB;aACJ;YACD,IAAI,EAAE,QAAQ;SACjB;KACJ;IACD,IAAI,EAAE,YAAY;CACrB,CAAC;AAEW,QAAA,cAAc,GAAY;IACnC;QACI,KAAK,EAAE,CAAC,MAAM,CAAC;KAClB;CACJ,CAAC"}
@@ -0,0 +1,6 @@
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>, [options]: readonly Options[number][]) => {
5
+ CallExpression: (node: TSESTree.CallExpression) => void;
6
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = void 0;
4
+ const consoles_1 = require("../../constants/consoles");
5
+ const utils_1 = require("@typescript-eslint/utils");
6
+ const config_1 = require("./config");
7
+ const create = (context, [options]) => {
8
+ const { allow = ["info"] } = options;
9
+ return {
10
+ CallExpression: (node) => {
11
+ if (node.callee.type === utils_1.AST_NODE_TYPES.MemberExpression &&
12
+ node.callee.object.type === utils_1.AST_NODE_TYPES.Identifier &&
13
+ node.callee.object.name === "console" &&
14
+ node.callee.property.type === utils_1.AST_NODE_TYPES.Identifier) {
15
+ const methodName = node.callee.property.name;
16
+ if (!consoles_1.CONSOLES.has(methodName)) {
17
+ return;
18
+ }
19
+ if (allow.includes(methodName)) {
20
+ return;
21
+ }
22
+ context.report({
23
+ data: {
24
+ console: node.callee.property.name,
25
+ },
26
+ messageId: config_1.Messages.NO_CONSOLE,
27
+ node: node.callee.property,
28
+ });
29
+ }
30
+ },
31
+ };
32
+ };
33
+ exports.create = create;
34
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/rules/restrict-console-methods/create.ts"],"names":[],"mappings":";;;AAAA,kDAA+C;AAC/C,oDAAyE;AAGzE,qCAAkD;AAE3C,MAAM,MAAM,GAAG,CAClB,OAAuC,EACvC,CAAC,OAAO,CAA6B,EACvC,EAAE;IACA,MAAM,EAAE,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC;IAErC,OAAO;QACH,cAAc,EAAE,CAAC,IAA6B,EAAE,EAAE;YAC9C,IACI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,gBAAgB;gBACpD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,UAAU;gBACrD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS;gBACrC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,sBAAc,CAAC,UAAU,EACzD,CAAC;gBACC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAE7C,IAAI,CAAC,mBAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC5B,OAAO;gBACX,CAAC;gBAED,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC7B,OAAO;gBACX,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACX,IAAI,EAAE;wBACF,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI;qBACrC;oBACD,SAAS,EAAE,iBAAQ,CAAC,UAAU;oBAC9B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;iBAC7B,CAAC,CAAC;YACP,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAlCW,QAAA,MAAM,UAkCjB"}
@@ -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/restrict-console-methods/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAA4C;AAAnC,gGAAA,MAAM,OAAA;AAAE,kGAAA,QAAQ,OAAA;AACzB,yCAAuB"}
@@ -0,0 +1,5 @@
1
+ import { Messages, name, type Options } from "./config";
2
+ export { name };
3
+ export declare const rule: import("@typescript-eslint/utils/ts-eslint").RuleModule<Messages, Options, {
4
+ recommended: boolean;
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/restrict-console-methods/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,21 @@
1
+ import { RuleModule } from "@typescript-eslint/utils/ts-eslint";
2
+ export declare const name = "restrict-function-usage";
3
+ export declare const enum Messages {
4
+ FUNCTION_DISALLOWED = "FUNCTION_DISALLOWED"
5
+ }
6
+ export type Options = [
7
+ Partial<{
8
+ allowFunctions: string[];
9
+ disableFunctions: string[];
10
+ files: string[];
11
+ folders: string[];
12
+ }>[]
13
+ ];
14
+ type ExtendedPluginProperties = {
15
+ recommended: boolean;
16
+ };
17
+ export declare const config: {
18
+ docs: ExtendedPluginProperties & RuleModule<Messages, Options>["meta"]["docs"];
19
+ } & Omit<RuleModule<Messages, Options>["meta"], "defaultOptions">;
20
+ export declare const defaultOptions: Options;
21
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultOptions = exports.config = exports.Messages = exports.name = void 0;
4
+ exports.name = "restrict-function-usage";
5
+ var Messages;
6
+ (function (Messages) {
7
+ Messages["FUNCTION_DISALLOWED"] = "FUNCTION_DISALLOWED";
8
+ })(Messages || (exports.Messages = Messages = {}));
9
+ exports.config = {
10
+ docs: {
11
+ description: "Disallow use of any functions in any files or folders unless explicitly allowed.",
12
+ recommended: false,
13
+ url: "https://github.com/NIMA-Enterprises/eslint-plugin-nima/blob/main/documentation/rules/restrict-function-usage.md",
14
+ },
15
+ messages: {
16
+ [Messages.FUNCTION_DISALLOWED]: "Do not use {{ fnName }} inside {{ filename }}.",
17
+ },
18
+ schema: [
19
+ {
20
+ description: "List of rule option objects for restricting function usage",
21
+ items: {
22
+ additionalProperties: false,
23
+ description: "Rule option that configures allow/disable lists and file matching",
24
+ properties: {
25
+ allowFunctions: {
26
+ description: "Functions to explicitly allow",
27
+ items: {
28
+ type: "string",
29
+ },
30
+ type: "array",
31
+ },
32
+ disableFunctions: {
33
+ description: "Functions to disable",
34
+ items: {
35
+ type: "string",
36
+ },
37
+ type: "array",
38
+ },
39
+ files: {
40
+ description: "Files glob list to apply rule",
41
+ items: {
42
+ type: "string",
43
+ },
44
+ type: "array",
45
+ },
46
+ folders: {
47
+ description: "Folders glob list to apply rule",
48
+ items: {
49
+ type: "string",
50
+ },
51
+ type: "array",
52
+ },
53
+ },
54
+ type: "object",
55
+ },
56
+ type: "array",
57
+ },
58
+ ],
59
+ type: "problem",
60
+ };
61
+ exports.defaultOptions = [[]];
62
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/rules/restrict-function-usage/config.ts"],"names":[],"mappings":";;;AAEa,QAAA,IAAI,GAAG,yBAAyB,CAAC;AAE9C,IAAkB,QAEjB;AAFD,WAAkB,QAAQ;IACtB,uDAA2C,CAAA;AAC/C,CAAC,EAFiB,QAAQ,wBAAR,QAAQ,QAEzB;AAeY,QAAA,MAAM,GAGiD;IAChE,IAAI,EAAE;QACF,WAAW,EACP,kFAAkF;QACtF,WAAW,EAAE,KAAK;QAClB,GAAG,EAAE,iHAAiH;KACzH;IACD,QAAQ,EAAE;QACN,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAC1B,gDAAgD;KACvD;IACD,MAAM,EAAE;QACJ;YACI,WAAW,EACP,4DAA4D;YAChE,KAAK,EAAE;gBACH,oBAAoB,EAAE,KAAK;gBAC3B,WAAW,EACP,mEAAmE;gBACvE,UAAU,EAAE;oBACR,cAAc,EAAE;wBACZ,WAAW,EAAE,+BAA+B;wBAC5C,KAAK,EAAE;4BACH,IAAI,EAAE,QAAQ;yBACjB;wBACD,IAAI,EAAE,OAAO;qBAChB;oBACD,gBAAgB,EAAE;wBACd,WAAW,EAAE,sBAAsB;wBACnC,KAAK,EAAE;4BACH,IAAI,EAAE,QAAQ;yBACjB;wBACD,IAAI,EAAE,OAAO;qBAChB;oBACD,KAAK,EAAE;wBACH,WAAW,EAAE,+BAA+B;wBAC5C,KAAK,EAAE;4BACH,IAAI,EAAE,QAAQ;yBACjB;wBACD,IAAI,EAAE,OAAO;qBAChB;oBACD,OAAO,EAAE;wBACL,WAAW,EAAE,iCAAiC;wBAC9C,KAAK,EAAE;4BACH,IAAI,EAAE,QAAQ;yBACjB;wBACD,IAAI,EAAE,OAAO;qBAChB;iBACJ;gBACD,IAAI,EAAE,QAAQ;aACjB;YACD,IAAI,EAAE,OAAO;SAChB;KACJ;IACD,IAAI,EAAE,SAAS;CAClB,CAAC;AAEW,QAAA,cAAc,GAAY,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { 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>, [options]: readonly Options[number][]) => {
5
+ CallExpression: (node: TSESTree.CallExpression) => void;
6
+ };
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = void 0;
4
+ const utils_1 = require("@typescript-eslint/utils");
5
+ const file_helpers_1 = require("../../utility/file-helpers");
6
+ const config_1 = require("./config");
7
+ const create = (context, [options = []]) => {
8
+ const isFunctionDisabled = ({ filename, fnName, }) => {
9
+ return options.some((option) => {
10
+ const { allowFunctions = [], disableFunctions = [], files = [], folders = [], } = option;
11
+ let isAppliesToFile = false;
12
+ isAppliesToFile =
13
+ files.length === 0 && folders.length === 0
14
+ ? true
15
+ : (0, file_helpers_1.isFileMatched)({
16
+ filename,
17
+ files,
18
+ folders,
19
+ });
20
+ if (allowFunctions.length > 0) {
21
+ const isFunctionInAllowList = allowFunctions.some((fn) => fn.toLowerCase() === fnName.toLowerCase());
22
+ if (isFunctionInAllowList) {
23
+ return files.length === 0 && folders.length === 0
24
+ ? false
25
+ : !isAppliesToFile;
26
+ }
27
+ return false;
28
+ }
29
+ if (!isAppliesToFile) {
30
+ return false;
31
+ }
32
+ if (disableFunctions.some((fn) => fn.toLowerCase() === fnName.toLowerCase())) {
33
+ return true;
34
+ }
35
+ return false;
36
+ });
37
+ };
38
+ return {
39
+ CallExpression: (node) => {
40
+ const callee = node.callee;
41
+ const filename = context.filename;
42
+ if (callee.type === utils_1.AST_NODE_TYPES.Identifier) {
43
+ if (isFunctionDisabled({
44
+ filename,
45
+ fnName: callee.name.toLowerCase(),
46
+ })) {
47
+ context.report({
48
+ data: {
49
+ filename,
50
+ fnName: callee.name,
51
+ },
52
+ messageId: config_1.Messages.FUNCTION_DISALLOWED,
53
+ node: callee,
54
+ });
55
+ }
56
+ }
57
+ else if (callee.type === utils_1.AST_NODE_TYPES.MemberExpression &&
58
+ callee.property.type === utils_1.AST_NODE_TYPES.Identifier &&
59
+ isFunctionDisabled({
60
+ filename,
61
+ fnName: callee.property.name.toLowerCase(),
62
+ })) {
63
+ context.report({
64
+ data: {
65
+ filename,
66
+ fnName: callee.property.name,
67
+ },
68
+ messageId: config_1.Messages.FUNCTION_DISALLOWED,
69
+ node: callee.property,
70
+ });
71
+ }
72
+ },
73
+ };
74
+ };
75
+ exports.create = create;
76
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/rules/restrict-function-usage/create.ts"],"names":[],"mappings":";;;AAAA,oDAAoE;AAEpE,wDAAsD;AAEtD,qCAAkD;AAE3C,MAAM,MAAM,GAAG,CAClB,OAAuC,EACvC,CAAC,OAAO,GAAG,EAAE,CAA6B,EAC5C,EAAE;IACA,MAAM,kBAAkB,GAAG,CAAC,EACxB,QAAQ,EACR,MAAM,GAIT,EAAE,EAAE;QACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YAC3B,MAAM,EACF,cAAc,GAAG,EAAE,EACnB,gBAAgB,GAAG,EAAE,EACrB,KAAK,GAAG,EAAE,EACV,OAAO,GAAG,EAAE,GACf,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,kBAAkB,CAAC;oBACf,QAAQ;oBACR,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE;iBACpC,CAAC,EACJ,CAAC;oBACC,OAAO,CAAC,MAAM,CAAC;wBACX,IAAI,EAAE;4BACF,QAAQ;4BACR,MAAM,EAAE,MAAM,CAAC,IAAI;yBACtB;wBACD,SAAS,EAAE,iBAAQ,CAAC,mBAAmB;wBACvC,IAAI,EAAE,MAAM;qBACf,CAAC,CAAC;gBACP,CAAC;YACL,CAAC;iBAAM,IACH,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,gBAAgB;gBAC/C,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,sBAAc,CAAC,UAAU;gBAClD,kBAAkB,CAAC;oBACf,QAAQ;oBACR,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE;iBAC7C,CAAC,EACJ,CAAC;gBACC,OAAO,CAAC,MAAM,CAAC;oBACX,IAAI,EAAE;wBACF,QAAQ;wBACR,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;qBAC/B;oBACD,SAAS,EAAE,iBAAQ,CAAC,mBAAmB;oBACvC,IAAI,EAAE,MAAM,CAAC,QAAQ;iBACxB,CAAC,CAAC;YACP,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAlGW,QAAA,MAAM,UAkGjB"}
@@ -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/restrict-function-usage/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAA4C;AAAnC,gGAAA,MAAM,OAAA;AAAE,kGAAA,QAAQ,OAAA;AACzB,yCAAuB"}