eslint-plugin-sonarjs 4.0.1 → 4.0.2

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 (314) hide show
  1. package/README.md +1 -1
  2. package/cjs/S100/rule.js +7 -5
  3. package/cjs/S101/rule.js +2 -2
  4. package/cjs/S104/rule.js +2 -2
  5. package/cjs/S105/rule.js +2 -2
  6. package/cjs/S1066/rule.js +5 -4
  7. package/cjs/S1067/rule.js +8 -6
  8. package/cjs/S1110/rule.js +7 -5
  9. package/cjs/S1119/rule.js +2 -2
  10. package/cjs/S1121/rule.js +4 -3
  11. package/cjs/S1125/rule.js +9 -8
  12. package/cjs/S1126/rule.js +2 -2
  13. package/cjs/S1128/rule.js +8 -5
  14. package/cjs/S1134/rule.js +2 -2
  15. package/cjs/S1135/rule.js +2 -2
  16. package/cjs/S1154/rule.js +6 -4
  17. package/cjs/S117/rule.js +6 -5
  18. package/cjs/S1172/rule.js +2 -2
  19. package/cjs/S1192/rule.js +5 -4
  20. package/cjs/S1219/rule.js +4 -3
  21. package/cjs/S1226/rule.js +6 -4
  22. package/cjs/S124/rule.js +2 -2
  23. package/cjs/S125/rule.js +9 -7
  24. package/cjs/S126/rule.js +2 -2
  25. package/cjs/S1264/rule.js +2 -2
  26. package/cjs/S128/rule.js +4 -3
  27. package/cjs/S1291/rule.js +2 -2
  28. package/cjs/S1301/rule.js +2 -2
  29. package/cjs/S1313/rule.js +2 -2
  30. package/cjs/S134/rule.js +7 -5
  31. package/cjs/S135/rule.js +5 -4
  32. package/cjs/S138/rule.js +9 -6
  33. package/cjs/S1439/rule.js +2 -2
  34. package/cjs/S1444/rule.js +2 -2
  35. package/cjs/S1451/rule.js +2 -2
  36. package/cjs/S1472/rule.js +2 -2
  37. package/cjs/S1479/rule.js +2 -2
  38. package/cjs/S1481/rule.js +2 -2
  39. package/cjs/S1488/rule.js +11 -7
  40. package/cjs/S1515/rule.js +10 -8
  41. package/cjs/S1523/rule.js +5 -5
  42. package/cjs/S1526/rule.js +5 -4
  43. package/cjs/S1527/rule.js +2 -2
  44. package/cjs/S1528/rule.js +2 -2
  45. package/cjs/S1529/rule.js +4 -3
  46. package/cjs/S1530/rule.js +5 -3
  47. package/cjs/S1533/rule.js +2 -2
  48. package/cjs/S1535/rule.js +2 -2
  49. package/cjs/S1541/rule.js +10 -7
  50. package/cjs/S1607/rule.js +22 -20
  51. package/cjs/S1764/rule.js +10 -7
  52. package/cjs/S1821/rule.js +2 -2
  53. package/cjs/S1848/rule.js +10 -7
  54. package/cjs/S1854/rule.js +18 -14
  55. package/cjs/S1862/rule.js +10 -8
  56. package/cjs/S1871/rule.js +21 -16
  57. package/cjs/S1874/rule.js +4 -3
  58. package/cjs/S1940/rule.js +2 -2
  59. package/cjs/S1994/rule.js +10 -7
  60. package/cjs/S2004/rule.js +9 -7
  61. package/cjs/S2068/rule.js +75 -12
  62. package/cjs/S2077/rule.js +10 -6
  63. package/cjs/S2092/rule.js +2 -2
  64. package/cjs/S2123/rule.js +2 -2
  65. package/cjs/S2137/rule.js +2 -2
  66. package/cjs/S2138/rule.js +4 -3
  67. package/cjs/S2187/rule.js +2 -2
  68. package/cjs/S2201/rule.js +8 -5
  69. package/cjs/S2208/rule.js +2 -2
  70. package/cjs/S2234/rule.js +15 -11
  71. package/cjs/S2245/rule.js +4 -3
  72. package/cjs/S2251/rule.js +5 -4
  73. package/cjs/S2255/rule.js +6 -5
  74. package/cjs/S2259/rule.js +14 -9
  75. package/cjs/S2301/rule.js +14 -9
  76. package/cjs/S2310/rule.js +14 -11
  77. package/cjs/S2392/rule.js +7 -5
  78. package/cjs/S2424/rule.js +2 -2
  79. package/cjs/S2428/rule.js +8 -6
  80. package/cjs/S2486/rule.js +4 -3
  81. package/cjs/S2589/rule.js +12 -10
  82. package/cjs/S2598/rule.js +17 -14
  83. package/cjs/S2612/generated-meta.js +1 -1
  84. package/cjs/S2612/rule.js +8 -6
  85. package/cjs/S2639/rule.js +2 -2
  86. package/cjs/S2681/rule.js +2 -2
  87. package/cjs/S2692/rule.js +6 -4
  88. package/cjs/S2699/rule.js +40 -31
  89. package/cjs/S2703/rule.js +2 -2
  90. package/cjs/S2737/rule.js +6 -4
  91. package/cjs/S2755/rule.js +9 -6
  92. package/cjs/S2757/rule.js +2 -2
  93. package/cjs/S2817/rule.js +10 -7
  94. package/cjs/S2819/rule.js +16 -12
  95. package/cjs/S2870/rule.js +8 -5
  96. package/cjs/S2871/rule.js +12 -9
  97. package/cjs/S2970/rule.js +9 -8
  98. package/cjs/S2990/rule.js +2 -2
  99. package/cjs/S2999/rule.js +10 -7
  100. package/cjs/S3001/rule.js +2 -2
  101. package/cjs/S3003/rule.js +10 -7
  102. package/cjs/S3317/rule.js +4 -3
  103. package/cjs/S3330/rule.js +2 -2
  104. package/cjs/S3358/rule.js +2 -2
  105. package/cjs/S3402/rule.js +14 -10
  106. package/cjs/S3403/rule.js +10 -7
  107. package/cjs/S3415/rule.js +16 -13
  108. package/cjs/S3499/rule.js +5 -4
  109. package/cjs/S3500/rule.js +5 -4
  110. package/cjs/S3513/rule.js +5 -4
  111. package/cjs/S3514/rule.js +10 -7
  112. package/cjs/S3516/rule.js +10 -7
  113. package/cjs/S3524/rule.js +2 -2
  114. package/cjs/S3525/rule.js +6 -4
  115. package/cjs/S3531/rule.js +5 -3
  116. package/cjs/S3533/rule.js +8 -7
  117. package/cjs/S3579/rule.js +6 -4
  118. package/cjs/S3616/rule.js +6 -4
  119. package/cjs/S3626/rule.js +4 -3
  120. package/cjs/S3686/rule.js +7 -5
  121. package/cjs/S3699/rule.js +4 -3
  122. package/cjs/S3735/rule.js +8 -5
  123. package/cjs/S3757/rule.js +8 -6
  124. package/cjs/S3758/rule.js +9 -7
  125. package/cjs/S3760/rule.js +24 -21
  126. package/cjs/S3776/rule.js +26 -22
  127. package/cjs/S3782/rule.js +6 -4
  128. package/cjs/S3785/rule.js +9 -6
  129. package/cjs/S3796/rule.js +12 -8
  130. package/cjs/S3798/rule.js +4 -3
  131. package/cjs/S3800/rule.js +16 -11
  132. package/cjs/S3801/rule.js +15 -11
  133. package/cjs/S3827/rule.js +9 -6
  134. package/cjs/S3923/rule.js +9 -6
  135. package/cjs/S3972/rule.js +5 -4
  136. package/cjs/S3973/rule.js +7 -5
  137. package/cjs/S3981/rule.js +4 -3
  138. package/cjs/S3984/rule.js +4 -3
  139. package/cjs/S4030/rule.js +10 -7
  140. package/cjs/S4036/rule.js +7 -5
  141. package/cjs/S4043/rule.js +12 -8
  142. package/cjs/S4139/rule.js +7 -5
  143. package/cjs/S4143/rule.js +12 -9
  144. package/cjs/S4144/rule.js +12 -9
  145. package/cjs/S4158/rule.js +11 -8
  146. package/cjs/S4165/rule.js +14 -12
  147. package/cjs/S4322/rule.js +8 -5
  148. package/cjs/S4323/rule.js +4 -3
  149. package/cjs/S4324/rule.js +7 -5
  150. package/cjs/S4328/rule.js +2 -2
  151. package/cjs/S4335/rule.js +6 -4
  152. package/cjs/S4423/rule.js +4 -3
  153. package/cjs/S4423/rule.lib.js +8 -7
  154. package/cjs/S4426/rule.js +11 -10
  155. package/cjs/S4502/rule.js +16 -13
  156. package/cjs/S4507/rule.js +8 -6
  157. package/cjs/S4524/rule.js +2 -2
  158. package/cjs/S4619/rule.js +6 -4
  159. package/cjs/S4621/rule.js +5 -4
  160. package/cjs/S4622/rule.js +5 -3
  161. package/cjs/S4623/rule.js +8 -5
  162. package/cjs/S4624/rule.js +6 -4
  163. package/cjs/S4634/rule.js +4 -3
  164. package/cjs/S4721/rule.js +7 -5
  165. package/cjs/S4782/rule.js +7 -5
  166. package/cjs/S4784/rule.js +5 -4
  167. package/cjs/S4787/rule.js +9 -7
  168. package/cjs/S4790/rule.js +7 -5
  169. package/cjs/S4798/rule.js +2 -2
  170. package/cjs/S4817/rule.js +10 -8
  171. package/cjs/S4818/rule.js +4 -3
  172. package/cjs/S4822/rule.js +13 -9
  173. package/cjs/S4823/rule.js +4 -3
  174. package/cjs/S4829/rule.js +4 -3
  175. package/cjs/S4830/rule.js +11 -8
  176. package/cjs/S5042/rule.js +9 -7
  177. package/cjs/S5122/rule.js +40 -36
  178. package/cjs/S5148/rule.js +9 -8
  179. package/cjs/S5247/rule.js +22 -18
  180. package/cjs/S5256/rule.js +5 -4
  181. package/cjs/S5257/rule.js +4 -3
  182. package/cjs/S5260/rule.js +4 -3
  183. package/cjs/S5264/rule.js +4 -3
  184. package/cjs/S5332/rule.js +4 -3
  185. package/cjs/S5332/rule.lib.js +19 -17
  186. package/cjs/S5443/rule.js +2 -2
  187. package/cjs/S5527/rule.js +18 -14
  188. package/cjs/S5542/rule.js +6 -4
  189. package/cjs/S5547/rule.js +6 -4
  190. package/cjs/S5604/rule.js +15 -14
  191. package/cjs/S5659/rule.js +15 -12
  192. package/cjs/S5689/rule.js +11 -8
  193. package/cjs/S5691/rule.js +7 -5
  194. package/cjs/S5693/rule.js +14 -12
  195. package/cjs/S5725/rule.js +9 -6
  196. package/cjs/S5728/rule.js +7 -4
  197. package/cjs/S5730/rule.js +9 -6
  198. package/cjs/S5732/rule.js +8 -5
  199. package/cjs/S5734/rule.js +7 -4
  200. package/cjs/S5736/rule.js +8 -5
  201. package/cjs/S5739/rule.js +11 -8
  202. package/cjs/S5742/rule.js +7 -4
  203. package/cjs/S5743/rule.js +8 -6
  204. package/cjs/S5757/rule.js +13 -10
  205. package/cjs/S5759/rule.js +10 -7
  206. package/cjs/S5842/rule.js +2 -2
  207. package/cjs/S5843/rule.js +22 -19
  208. package/cjs/S5850/rule.js +4 -3
  209. package/cjs/S5852/rule.js +2 -2
  210. package/cjs/S5856/rule.js +10 -7
  211. package/cjs/S5860/rule.js +30 -26
  212. package/cjs/S5863/rule.js +15 -11
  213. package/cjs/S5867/rule.js +8 -7
  214. package/cjs/S5868/rule.js +7 -5
  215. package/cjs/S5869/rule.js +6 -5
  216. package/cjs/S5876/rule.js +12 -8
  217. package/cjs/S5958/rule.js +12 -9
  218. package/cjs/S5973/rule.js +10 -7
  219. package/cjs/S6019/rule.js +4 -3
  220. package/cjs/S6035/rule.js +2 -2
  221. package/cjs/S6079/rule.js +9 -6
  222. package/cjs/S6080/rule.js +13 -10
  223. package/cjs/S6092/rule.js +9 -7
  224. package/cjs/S6245/rule.js +14 -9
  225. package/cjs/S6249/rule.js +7 -5
  226. package/cjs/S6252/rule.js +12 -8
  227. package/cjs/S6265/rule.js +27 -20
  228. package/cjs/S6268/rule.js +5 -4
  229. package/cjs/S6270/rule.js +12 -9
  230. package/cjs/S6275/rule.js +2 -2
  231. package/cjs/S6281/rule.js +22 -17
  232. package/cjs/S6299/rule.js +2 -2
  233. package/cjs/S6302/rule.js +6 -5
  234. package/cjs/S6303/rule.js +12 -10
  235. package/cjs/S6304/rule.js +6 -5
  236. package/cjs/S6308/rule.js +7 -5
  237. package/cjs/S6317/rule.js +5 -4
  238. package/cjs/S6319/rule.js +2 -2
  239. package/cjs/S6321/rule.js +25 -23
  240. package/cjs/S6323/rule.js +4 -3
  241. package/cjs/S6324/rule.js +2 -2
  242. package/cjs/S6326/rule.js +2 -2
  243. package/cjs/S6327/rule.js +2 -2
  244. package/cjs/S6328/rule.js +4 -3
  245. package/cjs/S6329/rule.js +7 -5
  246. package/cjs/S6330/rule.js +2 -2
  247. package/cjs/S6332/rule.js +2 -2
  248. package/cjs/S6333/rule.js +8 -6
  249. package/cjs/S6351/rule.js +22 -19
  250. package/cjs/S6353/rule.js +2 -2
  251. package/cjs/S6397/rule.js +2 -2
  252. package/cjs/S6418/rule.js +9 -24
  253. package/cjs/S6426/rule.js +5 -4
  254. package/cjs/S6437/rule.js +10 -7
  255. package/cjs/S6439/rule.js +9 -7
  256. package/cjs/S6442/rule.js +11 -8
  257. package/cjs/S6443/rule.js +9 -7
  258. package/cjs/S6486/rule.js +5 -4
  259. package/cjs/S6564/rule.js +4 -3
  260. package/cjs/S6594/rule.js +12 -8
  261. package/cjs/S6627/rule.js +6 -4
  262. package/cjs/S6759/rule.js +10 -6
  263. package/cjs/S6958/rule.js +2 -2
  264. package/cjs/S6959/rule.js +9 -6
  265. package/cjs/S7059/rule.js +8 -5
  266. package/cjs/S7639/rule.js +5 -4
  267. package/cjs/S7790/rule.js +7 -5
  268. package/cjs/S8441/rule.js +13 -9
  269. package/cjs/S881/rule.js +2 -2
  270. package/cjs/S888/rule.js +4 -3
  271. package/cjs/S930/rule.js +14 -12
  272. package/cjs/helpers/ast.js +11 -8
  273. package/cjs/helpers/aws/s3.js +9 -6
  274. package/cjs/helpers/chai.js +41 -43
  275. package/cjs/helpers/cookie-flag-check.js +19 -17
  276. package/cjs/helpers/{decorators/index.js → entropy.js} +16 -17
  277. package/cjs/helpers/express.js +127 -128
  278. package/cjs/helpers/mocha.js +50 -54
  279. package/cjs/helpers/regex/ast.js +7 -6
  280. package/cjs/helpers/regex/extract.js +11 -11
  281. package/cjs/helpers/regex/group.js +2 -2
  282. package/cjs/helpers/regex/location.js +2 -2
  283. package/cjs/helpers/regex/range.js +5 -4
  284. package/cjs/helpers/regex/rule-template.js +4 -3
  285. package/cjs/helpers/sinon.js +33 -36
  286. package/cjs/helpers/supertest.js +34 -37
  287. package/cjs/helpers/vitest.js +29 -32
  288. package/docs/file-permissions.md +1 -1
  289. package/package.json +39 -1
  290. package/types/helpers/ancestor.d.ts +1 -1
  291. package/types/helpers/aws/s3.d.ts +1 -1
  292. package/types/helpers/chai.d.ts +3 -5
  293. package/types/helpers/entropy.d.ts +1 -0
  294. package/types/helpers/express.d.ts +38 -43
  295. package/types/helpers/mocha.d.ts +19 -21
  296. package/types/helpers/regex/ast.d.ts +1 -1
  297. package/types/helpers/regex/rule-template.d.ts +1 -1
  298. package/types/helpers/sinon.d.ts +3 -5
  299. package/types/helpers/supertest.d.ts +3 -5
  300. package/types/helpers/type.d.ts +1 -1
  301. package/types/helpers/vitest.d.ts +3 -5
  302. package/cjs/helpers/aws/index.js +0 -35
  303. package/cjs/helpers/decorators/interceptor.js +0 -88
  304. package/cjs/helpers/index.js +0 -60
  305. package/cjs/helpers/recognizers/index.js +0 -37
  306. package/cjs/helpers/rule-detect-react.js +0 -29
  307. package/cjs/helpers/validate-version.js +0 -94
  308. package/types/helpers/aws/index.d.ts +0 -3
  309. package/types/helpers/decorators/index.d.ts +0 -2
  310. package/types/helpers/decorators/interceptor.d.ts +0 -16
  311. package/types/helpers/index.d.ts +0 -28
  312. package/types/helpers/recognizers/index.d.ts +0 -2
  313. package/types/helpers/rule-detect-react.d.ts +0 -2
  314. package/types/helpers/validate-version.d.ts +0 -13
package/cjs/S6328/rule.js CHANGED
@@ -52,20 +52,21 @@ var __importStar = (this && this.__importStar) || (function () {
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
54
  const regexpp_1 = require("@eslint-community/regexpp");
55
- const index_js_1 = require("../helpers/index.js");
55
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
56
+ const parser_services_js_1 = require("../helpers/parser-services.js");
56
57
  const meta = __importStar(require("./generated-meta.js"));
57
58
  const group_js_1 = require("../helpers/regex/group.js");
58
59
  const extract_js_1 = require("../helpers/regex/extract.js");
59
60
  const ast_js_1 = require("../helpers/regex/ast.js");
60
61
  exports.rule = {
61
- meta: (0, index_js_1.generateMeta)(meta, {
62
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
62
63
  messages: {
63
64
  nonExistingGroup: 'Referencing non-existing group{{groups}}.',
64
65
  },
65
66
  }),
66
67
  create(context) {
67
68
  const services = context.sourceCode.parserServices;
68
- if (!(0, index_js_1.isRequiredParserServices)(services)) {
69
+ if (!(0, parser_services_js_1.isRequiredParserServices)(services)) {
69
70
  return {};
70
71
  }
71
72
  return {
package/cjs/S6329/rule.js CHANGED
@@ -53,7 +53,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
54
  const cdk_js_1 = require("../helpers/aws/cdk.js");
55
55
  const result_js_1 = require("../helpers/result.js");
56
- const index_js_1 = require("../helpers/index.js");
56
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
57
+ const module_js_1 = require("../helpers/module.js");
58
+ const ast_js_1 = require("../helpers/ast.js");
57
59
  const meta = __importStar(require("./generated-meta.js"));
58
60
  const PROPERTIES_POSITION = 2;
59
61
  const PRIVATE_SUBNETS = new Set([
@@ -68,7 +70,7 @@ exports.rule = (0, cdk_js_1.AwsCdkTemplate)({
68
70
  'aws-cdk-lib.aws_rds.DatabaseInstance': checkDatabaseInstance,
69
71
  'aws-cdk-lib.aws_rds.CfnDBInstance': (0, cdk_js_1.AwsCdkCheckArguments)('publicNetwork', false, 'publiclyAccessible', { primitives: { invalid: [true] } }),
70
72
  'aws-cdk-lib.aws_dms.CfnReplicationInstance': (0, cdk_js_1.AwsCdkCheckArguments)('publicNetwork', true, 'publiclyAccessible', { primitives: { invalid: [true] } }),
71
- }, (0, index_js_1.generateMeta)(meta, {
73
+ }, (0, generate_meta_js_1.generateMeta)(meta, {
72
74
  messages: {
73
75
  publicNetwork: 'Make sure allowing public network access is safe here.',
74
76
  },
@@ -105,7 +107,7 @@ function getSelectSubnetsCall(subnetId) {
105
107
  while (current.ofType('MemberExpression')) {
106
108
  current = current.getMemberObject();
107
109
  }
108
- return current.filter(n => n.type === 'CallExpression' && (0, index_js_1.isCallingMethod)(n, 1, 'selectSubnets'));
110
+ return current.filter(n => n.type === 'CallExpression' && (0, ast_js_1.isCallingMethod)(n, 1, 'selectSubnets'));
109
111
  }
110
112
  function checkDatabaseInstance(expr, ctx) {
111
113
  const properties = (0, result_js_1.getResultOfExpression)(ctx, expr).getArgument(PROPERTIES_POSITION);
@@ -131,9 +133,9 @@ function checkDatabaseInstance(expr, ctx) {
131
133
  }
132
134
  }
133
135
  function isPrivateSubnet(node, ctx) {
134
- const subnet = (0, index_js_1.getFullyQualifiedName)(ctx, node)?.replaceAll('-', '_');
136
+ const subnet = (0, module_js_1.getFullyQualifiedName)(ctx, node)?.replaceAll('-', '_');
135
137
  return subnet !== undefined && PRIVATE_SUBNETS.has(subnet);
136
138
  }
137
139
  function isPublicSubnet(node, ctx) {
138
- return PUBLIC_SUBNET === (0, index_js_1.getFullyQualifiedName)(ctx, node)?.replaceAll('-', '_');
140
+ return PUBLIC_SUBNET === (0, module_js_1.getFullyQualifiedName)(ctx, node)?.replaceAll('-', '_');
139
141
  }
package/cjs/S6330/rule.js CHANGED
@@ -52,12 +52,12 @@ var __importStar = (this && this.__importStar) || (function () {
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
54
  const cdk_js_1 = require("../helpers/aws/cdk.js");
55
- const index_js_1 = require("../helpers/index.js");
55
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
56
56
  const meta = __importStar(require("./generated-meta.js"));
57
57
  exports.rule = (0, cdk_js_1.AwsCdkTemplate)({
58
58
  'aws-cdk-lib.aws-sqs.Queue': (0, cdk_js_1.AwsCdkCheckArguments)(['OmittedQueue', 'DisabledQueue'], true, 'encryption', { fqns: { invalid: ['aws-cdk-lib.aws-sqs.QueueEncryption.UNENCRYPTED'] } }),
59
59
  'aws-cdk-lib.aws-sqs.CfnQueue': (0, cdk_js_1.AwsCdkCheckArguments)('CfnQueue', true, 'kmsMasterKeyId'),
60
- }, (0, index_js_1.generateMeta)(meta, {
60
+ }, (0, generate_meta_js_1.generateMeta)(meta, {
61
61
  messages: {
62
62
  CfnQueue: 'Omitting "kmsMasterKeyId" disables SQS queues encryption. Make sure it is safe here.',
63
63
  OmittedQueue: 'Omitting "encryption" disables SQS queues encryption. Make sure it is safe here.',
package/cjs/S6332/rule.js CHANGED
@@ -52,12 +52,12 @@ var __importStar = (this && this.__importStar) || (function () {
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
54
  const cdk_js_1 = require("../helpers/aws/cdk.js");
55
- const index_js_1 = require("../helpers/index.js");
55
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
56
56
  const meta = __importStar(require("./generated-meta.js"));
57
57
  exports.rule = (0, cdk_js_1.AwsCdkTemplate)({
58
58
  'aws-cdk-lib.aws_efs.FileSystem': (0, cdk_js_1.AwsCdkCheckArguments)('FSEncryptionDisabled', false, 'encrypted', { primitives: { invalid: [false] } }),
59
59
  'aws-cdk-lib.aws_efs.CfnFileSystem': (0, cdk_js_1.AwsCdkCheckArguments)(['CFSEncryptionOmitted', 'CFSEncryptionDisabled'], true, 'encrypted', { primitives: { valid: [true] } }),
60
- }, (0, index_js_1.generateMeta)(meta, {
60
+ }, (0, generate_meta_js_1.generateMeta)(meta, {
61
61
  messages: {
62
62
  FSEncryptionDisabled: 'Make sure that using unencrypted file systems is safe here.',
63
63
  CFSEncryptionDisabled: 'Make sure that using unencrypted file systems is safe here.',
package/cjs/S6333/rule.js CHANGED
@@ -53,7 +53,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
54
  const cdk_js_1 = require("../helpers/aws/cdk.js");
55
55
  const result_js_1 = require("../helpers/result.js");
56
- const index_js_1 = require("../helpers/index.js");
56
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
57
+ const module_js_1 = require("../helpers/module.js");
58
+ const ast_js_1 = require("../helpers/ast.js");
57
59
  const meta = __importStar(require("./generated-meta.js"));
58
60
  const REST_API_PROPERTIES_POSITION = 2;
59
61
  const RESOURCE_ADD_RESOURCE_PROPERTIES_POSITION = 1;
@@ -117,7 +119,7 @@ function consumersFactory(ctx) {
117
119
  }
118
120
  }
119
121
  function getDefaultAuthorizationType(node) {
120
- const resource = (0, index_js_1.getUniqueWriteUsageOrNode)(ctx, node);
122
+ const resource = (0, ast_js_1.getUniqueWriteUsageOrNode)(ctx, node);
121
123
  if (defaultAuthorizationTypes.has(resource)) {
122
124
  return defaultAuthorizationTypes.get(resource);
123
125
  }
@@ -142,14 +144,14 @@ function consumersFactory(ctx) {
142
144
  };
143
145
  }
144
146
  function isSensitiveAuthorizationType(node) {
145
- const fqn = (0, cdk_js_1.normalizeFQN)((0, index_js_1.getFullyQualifiedName)(ctx, node));
147
+ const fqn = (0, cdk_js_1.normalizeFQN)((0, module_js_1.getFullyQualifiedName)(ctx, node));
146
148
  return fqn === NONE_AUTHORIZATION_TYPE;
147
149
  }
148
150
  }
149
151
  function isDefaultFromObject(node, ...names) {
150
- return node.type === 'MemberExpression' && names.some(name => (0, index_js_1.isMemberWithProperty)(node, name));
152
+ return node.type === 'MemberExpression' && names.some(name => (0, ast_js_1.isMemberWithProperty)(node, name));
151
153
  }
152
154
  function isDefaultFromCallee(node) {
153
- return node.type === 'CallExpression' && (0, index_js_1.isMethodCall)(node);
155
+ return node.type === 'CallExpression' && (0, ast_js_1.isMethodCall)(node);
154
156
  }
155
- exports.rule = (0, cdk_js_1.AwsCdkTemplate)(consumersFactory, (0, index_js_1.generateMeta)(meta, { messages }));
157
+ exports.rule = (0, cdk_js_1.AwsCdkTemplate)(consumersFactory, (0, generate_meta_js_1.generateMeta)(meta, { messages }));
package/cjs/S6351/rule.js CHANGED
@@ -51,12 +51,15 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const ast_js_1 = require("../helpers/ast.js");
55
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
56
+ const ancestor_js_1 = require("../helpers/ancestor.js");
57
+ const location_js_1 = require("../helpers/location.js");
55
58
  const meta = __importStar(require("./generated-meta.js"));
56
- const ast_js_1 = require("../helpers/regex/ast.js");
59
+ const ast_js_2 = require("../helpers/regex/ast.js");
57
60
  const flags_js_1 = require("../helpers/regex/flags.js");
58
61
  exports.rule = {
59
- meta: (0, index_js_1.generateMeta)(meta),
62
+ meta: (0, generate_meta_js_1.generateMeta)(meta),
60
63
  create(context) {
61
64
  const invocations = new Map();
62
65
  const regexes = [];
@@ -89,22 +92,22 @@ exports.rule = {
89
92
  },
90
93
  };
91
94
  function extractRegex(node, acc) {
92
- if ((0, index_js_1.isRegexLiteral)(node)) {
95
+ if ((0, ast_js_1.isRegexLiteral)(node)) {
93
96
  const { flags } = node.regex;
94
97
  acc.push({ node, flags });
95
98
  }
96
- else if ((0, ast_js_1.isRegExpConstructor)(node)) {
99
+ else if ((0, ast_js_2.isRegExpConstructor)(node)) {
97
100
  const flags = (0, flags_js_1.getFlags)(node) ?? '';
98
101
  acc.push({ node, flags });
99
102
  }
100
103
  }
101
104
  function extractRegexInvocation(callExpr, regexes, invocations, context) {
102
- if ((0, index_js_1.isCallingMethod)(callExpr, 1, 'exec', 'test') &&
105
+ if ((0, ast_js_1.isCallingMethod)(callExpr, 1, 'exec', 'test') &&
103
106
  callExpr.callee.object.type === 'Identifier') {
104
107
  const { object } = callExpr.callee;
105
- const variable = (0, index_js_1.getVariableFromName)(context, object.name, callExpr);
108
+ const variable = (0, ast_js_1.getVariableFromName)(context, object.name, callExpr);
106
109
  if (variable) {
107
- const value = (0, index_js_1.getUniqueWriteUsage)(context, variable.name, callExpr);
110
+ const value = (0, ast_js_1.getUniqueWriteUsage)(context, variable.name, callExpr);
108
111
  const regex = regexes.find(r => r.node === value);
109
112
  if (regex?.flags.includes('g')) {
110
113
  const usages = invocations.get(variable);
@@ -120,14 +123,14 @@ function extractRegexInvocation(callExpr, regexes, invocations, context) {
120
123
  }
121
124
  function extractResetRegex(node, regexes, resets, context) {
122
125
  /* RegExp.prototype.lastIndex = ... */
123
- if ((0, index_js_1.isDotNotation)(node) &&
126
+ if ((0, ast_js_1.isDotNotation)(node) &&
124
127
  node.object.type === 'Identifier' &&
125
128
  node.property.name === 'lastIndex') {
126
- const parent = (0, index_js_1.getParent)(context, node);
129
+ const parent = (0, ancestor_js_1.getParent)(context, node);
127
130
  if (parent?.type === 'AssignmentExpression' && parent.left === node) {
128
- const variable = (0, index_js_1.getVariableFromName)(context, node.object.name, node);
131
+ const variable = (0, ast_js_1.getVariableFromName)(context, node.object.name, node);
129
132
  if (variable) {
130
- const value = (0, index_js_1.getUniqueWriteUsage)(context, variable.name, node);
133
+ const value = (0, ast_js_1.getUniqueWriteUsage)(context, variable.name, node);
131
134
  const regex = regexes.find(r => r.node === value);
132
135
  if (regex) {
133
136
  resets.add(variable);
@@ -138,12 +141,12 @@ function extractResetRegex(node, regexes, resets, context) {
138
141
  }
139
142
  function checkWhileConditionRegex(callExpr, context) {
140
143
  /* RegExp.prototype.exec() within while conditions */
141
- if ((0, index_js_1.isMethodCall)(callExpr)) {
144
+ if ((0, ast_js_1.isMethodCall)(callExpr)) {
142
145
  const { object, property } = callExpr.callee;
143
- if (((0, index_js_1.isRegexLiteral)(object) || (0, ast_js_1.isRegExpConstructor)(object)) && property.name === 'exec') {
146
+ if (((0, ast_js_1.isRegexLiteral)(object) || (0, ast_js_2.isRegExpConstructor)(object)) && property.name === 'exec') {
144
147
  const flags = object.type === 'Literal' ? object.regex.flags : (0, flags_js_1.getFlags)(object);
145
148
  if (flags?.includes('g') && isWithinWhileCondition(callExpr, context)) {
146
- (0, index_js_1.report)(context, {
149
+ (0, location_js_1.report)(context, {
147
150
  message: 'Extract this regular expression to avoid infinite loop.',
148
151
  node: object,
149
152
  });
@@ -154,7 +157,7 @@ function checkWhileConditionRegex(callExpr, context) {
154
157
  function checkGlobalStickyRegex(regex, context) {
155
158
  /* RegExp with `g` and `y` flags */
156
159
  if (regex.flags.includes('g') && regex.flags.includes('y')) {
157
- (0, index_js_1.report)(context, {
160
+ (0, location_js_1.report)(context, {
158
161
  message: `Remove the 'g' flag from this regex as it is shadowed by the 'y' flag.`,
159
162
  node: regex.node,
160
163
  });
@@ -168,10 +171,10 @@ function checkMultipleInputsRegex(regex, usages, resets, context) {
168
171
  const regexReset = uniqueInputs.has(`''`) || uniqueInputs.has(`""`);
169
172
  if (definition && uniqueInputs.size > 1 && !regexReset) {
170
173
  const pattern = definition.node.init;
171
- (0, index_js_1.report)(context, {
174
+ (0, location_js_1.report)(context, {
172
175
  message: `Remove the 'g' flag from this regex as it is used on different inputs.`,
173
176
  node: pattern,
174
- }, usages.map((node, idx) => (0, index_js_1.toSecondaryLocation)(node, `Usage ${idx + 1}`)));
177
+ }, usages.map((node, idx) => (0, location_js_1.toSecondaryLocation)(node, `Usage ${idx + 1}`)));
175
178
  }
176
179
  }
177
180
  }
@@ -180,7 +183,7 @@ function isWithinWhileCondition(node, context) {
180
183
  let parent;
181
184
  let child = node;
182
185
  while ((parent = ancestors.pop()) !== undefined) {
183
- if (index_js_1.functionLike.has(parent.type)) {
186
+ if (ast_js_1.functionLike.has(parent.type)) {
184
187
  break;
185
188
  }
186
189
  if (parent.type === 'WhileStatement' || parent.type === 'DoWhileStatement') {
package/cjs/S6353/rule.js CHANGED
@@ -51,7 +51,7 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
55
55
  const meta = __importStar(require("./generated-meta.js"));
56
56
  const rule_template_js_1 = require("../helpers/regex/rule-template.js");
57
57
  exports.rule = (0, rule_template_js_1.createRegExpRule)(context => {
@@ -69,7 +69,7 @@ exports.rule = (0, rule_template_js_1.createRegExpRule)(context => {
69
69
  checkBulkyQuantifier(node, context);
70
70
  },
71
71
  };
72
- }, (0, index_js_1.generateMeta)(meta));
72
+ }, (0, generate_meta_js_1.generateMeta)(meta));
73
73
  function checkBulkyAnyCharacterClass(node, flags, context) {
74
74
  if (node.negate || node.elements.length !== 2) {
75
75
  return;
package/cjs/S6397/rule.js CHANGED
@@ -51,7 +51,7 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
55
55
  const meta = __importStar(require("./generated-meta.js"));
56
56
  const rule_template_js_1 = require("../helpers/regex/rule-template.js");
57
57
  const FORBIDDEN_TYPES = new Set([
@@ -73,7 +73,7 @@ exports.rule = (0, rule_template_js_1.createRegExpRule)(context => {
73
73
  }
74
74
  },
75
75
  };
76
- }, (0, index_js_1.generateMeta)(meta, {
76
+ }, (0, generate_meta_js_1.generateMeta)(meta, {
77
77
  messages: {
78
78
  issue: 'Replace this character class by the character itself.',
79
79
  },
package/cjs/S6418/rule.js CHANGED
@@ -51,7 +51,9 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
55
+ const ast_js_1 = require("../helpers/ast.js");
56
+ const entropy_js_1 = require("../helpers/entropy.js");
55
57
  const meta = __importStar(require("./generated-meta.js"));
56
58
  const DEFAULT_SECRET_WORDS = 'api[_.-]?key,auth,credential,secret,token';
57
59
  const DEFAULT_RANDOMNESS_SENSIBILITY = 5;
@@ -62,7 +64,7 @@ function message(name) {
62
64
  let randomnessSensibility;
63
65
  let secretWordRegexps;
64
66
  exports.rule = {
65
- meta: (0, index_js_1.generateMeta)(meta),
67
+ meta: (0, generate_meta_js_1.generateMeta)(meta),
66
68
  create(context) {
67
69
  // get typed rule options with FromSchema helper
68
70
  const secretWords = context.options[0]?.['secretWords'] ??
@@ -101,7 +103,7 @@ function handleAssignmentExpression(context, node) {
101
103
  }
102
104
  function extractDefaultOperatorIfNeeded(node) {
103
105
  const defaultOperators = ['??', '||'];
104
- if ((0, index_js_1.isLogicalExpression)(node.right) &&
106
+ if ((0, ast_js_1.isLogicalExpression)(node.right) &&
105
107
  defaultOperators.includes(node.right.operator)) {
106
108
  return node.right.right;
107
109
  }
@@ -141,10 +143,10 @@ function handleVariableDeclarator(context, node) {
141
143
  }
142
144
  }
143
145
  function findKeySuspect(node) {
144
- if ((0, index_js_1.isIdentifier)(node) && secretWordRegexps.some(pattern => pattern.test(node.name))) {
146
+ if ((0, ast_js_1.isIdentifier)(node) && secretWordRegexps.some(pattern => pattern.test(node.name))) {
145
147
  return node.name;
146
148
  }
147
- else if ((0, index_js_1.isStringLiteral)(node) &&
149
+ else if ((0, ast_js_1.isStringLiteral)(node) &&
148
150
  secretWordRegexps.some(pattern => pattern.test(node.value))) {
149
151
  return node.value;
150
152
  }
@@ -159,7 +161,7 @@ function findValueSuspect(node) {
159
161
  if (!node) {
160
162
  return undefined;
161
163
  }
162
- if ((0, index_js_1.isStringLiteral)(node) &&
164
+ if ((0, ast_js_1.isStringLiteral)(node) &&
163
165
  valuePassesPostValidation(node.value) &&
164
166
  entropyShouldRaise(node.value)) {
165
167
  return node;
@@ -183,22 +185,5 @@ function buildSecretWordRegexps(secretWords) {
183
185
  }
184
186
  }
185
187
  function entropyShouldRaise(value) {
186
- return ShannonEntropy.calculate(value) > randomnessSensibility;
188
+ return (0, entropy_js_1.shannonEntropy)(value) > randomnessSensibility;
187
189
  }
188
- const ShannonEntropy = {
189
- calculate: (str) => {
190
- if (!str) {
191
- return 0;
192
- }
193
- const lettersTotal = str.length;
194
- const occurrences = {};
195
- for (const letter of str) {
196
- occurrences[letter] = (occurrences[letter] ?? 0) + 1;
197
- }
198
- const values = Object.values(occurrences);
199
- return (values
200
- .map(count => count / lettersTotal)
201
- .map(frequency => -frequency * Math.log(frequency))
202
- .reduce((acc, entropy) => acc + entropy, 0) / Math.log(2));
203
- },
204
- };
package/cjs/S6426/rule.js CHANGED
@@ -51,10 +51,11 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
55
+ const ast_js_1 = require("../helpers/ast.js");
55
56
  const meta = __importStar(require("./generated-meta.js"));
56
57
  exports.rule = {
57
- meta: (0, index_js_1.generateMeta)(meta, {
58
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
58
59
  hasSuggestions: true,
59
60
  messages: {
60
61
  issue: 'Remove ".only()" from your test case.',
@@ -64,9 +65,9 @@ exports.rule = {
64
65
  create(context) {
65
66
  return {
66
67
  CallExpression: (node) => {
67
- if ((0, index_js_1.isMethodCall)(node)) {
68
+ if ((0, ast_js_1.isMethodCall)(node)) {
68
69
  const { property, object } = node.callee;
69
- if ((0, index_js_1.isIdentifier)(property, 'only') && (0, index_js_1.isIdentifier)(object, 'describe', 'it', 'test')) {
70
+ if ((0, ast_js_1.isIdentifier)(property, 'only') && (0, ast_js_1.isIdentifier)(object, 'describe', 'it', 'test')) {
70
71
  context.report({
71
72
  messageId: 'issue',
72
73
  node: property,
package/cjs/S6437/rule.js CHANGED
@@ -51,7 +51,10 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const location_js_1 = require("../helpers/location.js");
55
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
56
+ const module_js_1 = require("../helpers/module.js");
57
+ const ast_js_1 = require("../helpers/ast.js");
55
58
  const meta = __importStar(require("./generated-meta.js"));
56
59
  // Dictionary with fully qualified names of functions and indices of their
57
60
  // parameters to analyze for hardcoded credentials.
@@ -86,7 +89,7 @@ const secretObjectSignatures = {
86
89
  'express-session': { argIndex: 0, propertyName: 'secret' },
87
90
  };
88
91
  exports.rule = {
89
- meta: (0, index_js_1.generateMeta)(meta, {
92
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
90
93
  messages: {},
91
94
  }),
92
95
  create(context) {
@@ -107,13 +110,13 @@ exports.rule = {
107
110
  if (expr.type === 'Identifier' && hardcodedVariables.has(expr.name)) {
108
111
  const nodeName = hardcodedVariables.get(expr.name);
109
112
  if (nodeName) {
110
- return [(0, index_js_1.toSecondaryLocation)(nodeName, 'Hardcoded value assigned here')];
113
+ return [(0, location_js_1.toSecondaryLocation)(nodeName, 'Hardcoded value assigned here')];
111
114
  }
112
115
  }
113
116
  return [];
114
117
  }
115
118
  function reportIssue(callExpression, secretExpr) {
116
- (0, index_js_1.report)(context, {
119
+ (0, location_js_1.report)(context, {
117
120
  message: 'Revoke and change this password, as it is compromised.',
118
121
  loc: callExpression.callee.loc,
119
122
  }, getSecondaryLocations(secretExpr));
@@ -132,11 +135,11 @@ exports.rule = {
132
135
  if (!arg) {
133
136
  return;
134
137
  }
135
- const objectExpr = (0, index_js_1.getValueOfExpression)(context, arg, 'ObjectExpression');
138
+ const objectExpr = (0, ast_js_1.getValueOfExpression)(context, arg, 'ObjectExpression');
136
139
  if (!objectExpr) {
137
140
  return;
138
141
  }
139
- const secretProperty = (0, index_js_1.getProperty)(objectExpr, propertyName, context);
142
+ const secretProperty = (0, ast_js_1.getProperty)(objectExpr, propertyName, context);
140
143
  if (!secretProperty) {
141
144
  return;
142
145
  }
@@ -162,7 +165,7 @@ exports.rule = {
162
165
  }
163
166
  },
164
167
  CallExpression(node) {
165
- const fqn = (0, index_js_1.getFullyQualifiedName)(context, node);
168
+ const fqn = (0, module_js_1.getFullyQualifiedName)(context, node);
166
169
  if (!fqn) {
167
170
  return;
168
171
  }
package/cjs/S6439/rule.js CHANGED
@@ -51,7 +51,9 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
55
+ const type_js_1 = require("../helpers/type.js");
56
+ const parser_services_js_1 = require("../helpers/parser-services.js");
55
57
  const meta = __importStar(require("./generated-meta.js"));
56
58
  const detectReactNativeSelector = [
57
59
  ':matches(',
@@ -62,7 +64,7 @@ const detectReactNativeSelector = [
62
64
  ')',
63
65
  ].join('');
64
66
  exports.rule = {
65
- meta: (0, index_js_1.generateMeta)(meta, {
67
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
66
68
  hasSuggestions: true,
67
69
  messages: {
68
70
  nonBooleanMightRender: 'Convert the conditional to a boolean to avoid leaked value',
@@ -70,7 +72,7 @@ exports.rule = {
70
72
  },
71
73
  }),
72
74
  create(context) {
73
- if (!(0, index_js_1.isRequiredParserServices)(context.sourceCode.parserServices)) {
75
+ if (!(0, parser_services_js_1.isRequiredParserServices)(context.sourceCode.parserServices)) {
74
76
  return {};
75
77
  }
76
78
  let usesReactNative = false;
@@ -114,12 +116,12 @@ function report(node, context) {
114
116
  });
115
117
  }
116
118
  function isStringOrNumber(node, context) {
117
- const type = (0, index_js_1.getTypeFromTreeNode)(node, context.sourceCode.parserServices);
118
- return (0, index_js_1.isStringType)(type) || (0, index_js_1.isBigIntType)(type) || (0, index_js_1.isNumberType)(type);
119
+ const type = (0, type_js_1.getTypeFromTreeNode)(node, context.sourceCode.parserServices);
120
+ return (0, type_js_1.isStringType)(type) || (0, type_js_1.isBigIntType)(type) || (0, type_js_1.isNumberType)(type);
119
121
  }
120
122
  function isNumber(node, context) {
121
- const type = (0, index_js_1.getTypeFromTreeNode)(node, context.sourceCode.parserServices);
122
- return (0, index_js_1.isBigIntType)(type) || (0, index_js_1.isNumberType)(type);
123
+ const type = (0, type_js_1.getTypeFromTreeNode)(node, context.sourceCode.parserServices);
124
+ return (0, type_js_1.isBigIntType)(type) || (0, type_js_1.isNumberType)(type);
123
125
  }
124
126
  function checkNonBoolean(context, isLeakingType, node) {
125
127
  if (node.type === 'LogicalExpression') {
package/cjs/S6442/rule.js CHANGED
@@ -51,25 +51,28 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const ancestor_js_1 = require("../helpers/ancestor.js");
55
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
56
+ const module_js_1 = require("../helpers/module.js");
57
+ const ast_js_1 = require("../helpers/ast.js");
55
58
  const meta = __importStar(require("./generated-meta.js"));
56
59
  const REACT_MODULE = 'react';
57
60
  const REACT_PATTERN = /^[^a-z]/;
58
61
  const HOOK_FUNCTION = 'useState';
59
62
  exports.rule = {
60
- meta: (0, index_js_1.generateMeta)(meta, {
63
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
61
64
  messages: {
62
65
  noHookSetterInBody: 'Remove this state setter call, perhaps move it to an event handler or JSX attribute',
63
66
  },
64
67
  }),
65
68
  create(context) {
66
69
  function isHookCall(node) {
67
- return ((0, index_js_1.getFullyQualifiedName)(context, node) === `${REACT_MODULE}.${HOOK_FUNCTION}` &&
70
+ return ((0, module_js_1.getFullyQualifiedName)(context, node) === `${REACT_MODULE}.${HOOK_FUNCTION}` &&
68
71
  node.arguments.length === 1);
69
72
  }
70
73
  function getReactComponentScope(node) {
71
74
  const scope = context.sourceCode.getScope(node);
72
- const isReact = (0, index_js_1.isFunctionNode)(scope.block) && matchesReactComponentName(scope.block, 1);
75
+ const isReact = (0, ast_js_1.isFunctionNode)(scope.block) && matchesReactComponentName(scope.block, 1);
73
76
  return isReact ? scope : null;
74
77
  }
75
78
  function isInsideFunctionScope(scope, node) {
@@ -107,7 +110,7 @@ exports.rule = {
107
110
  }
108
111
  const hookDeclarator = node;
109
112
  if (isHookCall(hookDeclarator.init)) {
110
- const variable = (0, index_js_1.getVariableFromName)(context, hookDeclarator.id.elements[1].name, node);
113
+ const variable = (0, ast_js_1.getVariableFromName)(context, hookDeclarator.id.elements[1].name, node);
111
114
  if (variable != null) {
112
115
  setters.push(variable);
113
116
  }
@@ -121,7 +124,7 @@ exports.rule = {
121
124
  return;
122
125
  }
123
126
  const maybeSetterCall = node;
124
- const calleeVariable = (0, index_js_1.getVariableFromName)(context, maybeSetterCall.callee.name, node);
127
+ const calleeVariable = (0, ast_js_1.getVariableFromName)(context, maybeSetterCall.callee.name, node);
125
128
  if (calleeVariable && setters.includes(calleeVariable)) {
126
129
  context.report({
127
130
  messageId: 'noHookSetterInBody',
@@ -133,7 +136,7 @@ exports.rule = {
133
136
  },
134
137
  };
135
138
  function isInsideConditional(node) {
136
- return ((0, index_js_1.findFirstMatchingLocalAncestor)(node, n => n.type === 'IfStatement') !==
139
+ return ((0, ancestor_js_1.findFirstMatchingLocalAncestor)(node, n => n.type === 'IfStatement') !==
137
140
  undefined);
138
141
  }
139
142
  function hasParent(node) {
@@ -143,7 +146,7 @@ function matchesReactComponentName(node, max = 0) {
143
146
  if (node == null) {
144
147
  return false;
145
148
  }
146
- else if ((0, index_js_1.isIdentifier)(node)) {
149
+ else if ((0, ast_js_1.isIdentifier)(node)) {
147
150
  return REACT_PATTERN.test(node.name);
148
151
  }
149
152
  else if (node.type === 'FunctionDeclaration') {
package/cjs/S6443/rule.js CHANGED
@@ -51,7 +51,9 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
55
+ const module_js_1 = require("../helpers/module.js");
56
+ const ast_js_1 = require("../helpers/ast.js");
55
57
  const meta = __importStar(require("./generated-meta.js"));
56
58
  const declarationSelector = [
57
59
  ':matches(',
@@ -71,7 +73,7 @@ const callSelector = [
71
73
  '[arguments.0.type="Identifier"]',
72
74
  ].join('');
73
75
  exports.rule = {
74
- meta: (0, index_js_1.generateMeta)(meta, {
76
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
75
77
  messages: {
76
78
  uselessSetState: 'Change the argument of this setter to not use its matching state variable',
77
79
  },
@@ -84,14 +86,14 @@ exports.rule = {
84
86
  const { elements } = node.id;
85
87
  const setter = elements[1].name;
86
88
  referencesBySetterName[setter] = {
87
- setter: (0, index_js_1.getVariableFromName)(context, setter, node),
88
- value: (0, index_js_1.getVariableFromName)(context, elements[0].name, node),
89
+ setter: (0, ast_js_1.getVariableFromName)(context, setter, node),
90
+ value: (0, ast_js_1.getVariableFromName)(context, elements[0].name, node),
89
91
  };
90
92
  }
91
93
  },
92
94
  [callSelector](node) {
93
- const setter = (0, index_js_1.getVariableFromName)(context, node.callee.name, node);
94
- const value = (0, index_js_1.getVariableFromName)(context, node.arguments[0].name, node);
95
+ const setter = (0, ast_js_1.getVariableFromName)(context, node.callee.name, node);
96
+ const value = (0, ast_js_1.getVariableFromName)(context, node.arguments[0].name, node);
95
97
  const key = setter?.name;
96
98
  if (setter &&
97
99
  value &&
@@ -108,7 +110,7 @@ exports.rule = {
108
110
  },
109
111
  };
110
112
  function isReactCall(context, callExpr) {
111
- const fqn = (0, index_js_1.getFullyQualifiedName)(context, callExpr);
113
+ const fqn = (0, module_js_1.getFullyQualifiedName)(context, callExpr);
112
114
  if (fqn) {
113
115
  const [module] = fqn.split('.');
114
116
  return module === 'react';
package/cjs/S6486/rule.js CHANGED
@@ -51,10 +51,11 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
- const index_js_1 = require("../helpers/index.js");
54
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
55
+ const ast_js_1 = require("../helpers/ast.js");
55
56
  const meta = __importStar(require("./generated-meta.js"));
56
57
  exports.rule = {
57
- meta: (0, index_js_1.generateMeta)(meta, {
58
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
58
59
  messages: {
59
60
  noGeneratedKeys: 'Do not use generated values for keys of React list components.',
60
61
  },
@@ -134,11 +135,11 @@ function isGeneratedExpression(node) {
134
135
  return isMathRandom(node) || isDateNow(node);
135
136
  function isMathRandom(node) {
136
137
  return (node.type === 'CallExpression' &&
137
- (0, index_js_1.isMemberExpression)(node.callee, 'Math', 'random'));
138
+ (0, ast_js_1.isMemberExpression)(node.callee, 'Math', 'random'));
138
139
  }
139
140
  function isDateNow(node) {
140
141
  return (node.type === 'CallExpression' &&
141
- (0, index_js_1.isMemberExpression)(node.callee, 'Date', 'now'));
142
+ (0, ast_js_1.isMemberExpression)(node.callee, 'Date', 'now'));
142
143
  }
143
144
  }
144
145
  function getCallExpressionsFromBinaryExpression(side) {