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/S2259/rule.js CHANGED
@@ -51,7 +51,12 @@ 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 equivalence_js_1 = require("../helpers/equivalence.js");
55
+ const ancestor_js_1 = require("../helpers/ancestor.js");
56
+ const ast_js_1 = require("../helpers/ast.js");
57
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
58
+ const parser_services_js_1 = require("../helpers/parser-services.js");
59
+ const type_js_1 = require("../helpers/type.js");
55
60
  const meta = __importStar(require("./generated-meta.js"));
56
61
  var Null;
57
62
  (function (Null) {
@@ -60,19 +65,19 @@ var Null;
60
65
  Null[Null["unknown"] = 2] = "unknown";
61
66
  })(Null || (Null = {}));
62
67
  function isNull(n) {
63
- return (0, index_js_1.isNullLiteral)(n) || (0, index_js_1.isUndefined)(n);
68
+ return (0, ast_js_1.isNullLiteral)(n) || (0, ast_js_1.isUndefined)(n);
64
69
  }
65
70
  const equalOperators = new Set(['==', '===']);
66
71
  const notEqualOperators = new Set(['!=', '!==']);
67
72
  exports.rule = {
68
- meta: (0, index_js_1.generateMeta)(meta, {
73
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
69
74
  messages: {
70
75
  nullDereference: 'TypeError can be thrown as "{{symbol}}" might be null or undefined here.',
71
76
  shortCircuitError: 'TypeError can be thrown as expression might be null or undefined here.',
72
77
  },
73
78
  }),
74
79
  create(context) {
75
- if (!(0, index_js_1.isRequiredParserServices)(context.sourceCode.parserServices)) {
80
+ if (!(0, parser_services_js_1.isRequiredParserServices)(context.sourceCode.parserServices)) {
76
81
  return {};
77
82
  }
78
83
  const alreadyRaisedSymbols = new Set();
@@ -104,9 +109,9 @@ exports.rule = {
104
109
  function getNullState(expr, node, context) {
105
110
  const { left, right } = expr;
106
111
  if ((isNull(right) &&
107
- (0, index_js_1.areEquivalent)(left, node, context.sourceCode)) ||
112
+ (0, equivalence_js_1.areEquivalent)(left, node, context.sourceCode)) ||
108
113
  (isNull(left) &&
109
- (0, index_js_1.areEquivalent)(right, node, context.sourceCode))) {
114
+ (0, equivalence_js_1.areEquivalent)(right, node, context.sourceCode))) {
110
115
  if (notEqualOperators.has(expr.operator)) {
111
116
  return Null.discarded;
112
117
  }
@@ -131,7 +136,7 @@ function checkLogicalNullDereference(expr, node, context) {
131
136
  function isWrittenInInnerFunction(symbol, fn) {
132
137
  return symbol.references.some(ref => {
133
138
  if (ref.isWrite() && ref.identifier.hasOwnProperty('parent')) {
134
- const enclosingFn = (0, index_js_1.findFirstMatchingAncestor)(ref.identifier, node => index_js_1.functionLike.has(node.type));
139
+ const enclosingFn = (0, ancestor_js_1.findFirstMatchingAncestor)(ref.identifier, node => ast_js_1.functionLike.has(node.type));
135
140
  return enclosingFn && enclosingFn !== fn;
136
141
  }
137
142
  return false;
@@ -148,10 +153,10 @@ function checkNullDereference(node, context, alreadyRaisedSymbols) {
148
153
  }
149
154
  const enclosingFunction = context.sourceCode
150
155
  .getAncestors(node)
151
- .find(n => index_js_1.functionLike.has(n.type));
156
+ .find(n => ast_js_1.functionLike.has(n.type));
152
157
  if (!alreadyRaisedSymbols.has(symbol) &&
153
158
  !isWrittenInInnerFunction(symbol, enclosingFunction) &&
154
- (0, index_js_1.isUndefinedOrNull)(node, context.sourceCode.parserServices)) {
159
+ (0, type_js_1.isUndefinedOrNull)(node, context.sourceCode.parserServices)) {
155
160
  alreadyRaisedSymbols.add(symbol);
156
161
  context.report({
157
162
  messageId: 'nullDereference',
package/cjs/S2301/rule.js CHANGED
@@ -51,20 +51,25 @@ 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 reaching_definitions_js_1 = require("../helpers/reaching-definitions.js");
57
+ const ast_js_1 = require("../helpers/ast.js");
58
+ const parser_services_js_1 = require("../helpers/parser-services.js");
59
+ const location_js_1 = require("../helpers/location.js");
55
60
  const meta = __importStar(require("./generated-meta.js"));
56
61
  const message = 'Provide multiple methods instead of using "{{parameterName}}" to determine which action to take.';
57
62
  /**
58
63
  * A suspect test node is a test node that is the only child of a function body
59
64
  */
60
65
  exports.rule = {
61
- meta: (0, index_js_1.generateMeta)(meta, {
66
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
62
67
  messages: {
63
68
  message,
64
69
  },
65
70
  }),
66
71
  create: context => {
67
- if (!(0, index_js_1.isRequiredParserServices)(context.sourceCode.parserServices)) {
72
+ if (!(0, parser_services_js_1.isRequiredParserServices)(context.sourceCode.parserServices)) {
68
73
  return {};
69
74
  }
70
75
  const suspectTestNodes = [];
@@ -77,7 +82,7 @@ exports.rule = {
77
82
  }
78
83
  };
79
84
  const isAChildOf = (identifier, node) => {
80
- if ((0, index_js_1.hasParent)(identifier)) {
85
+ if ((0, ast_js_1.hasParent)(identifier)) {
81
86
  if (identifier.parent === node) {
82
87
  return true;
83
88
  }
@@ -114,21 +119,21 @@ exports.rule = {
114
119
  if (!isSuspect) {
115
120
  return;
116
121
  }
117
- const variable = (0, index_js_1.getVariableFromIdentifier)(node, context.sourceCode.getScope(node));
122
+ const variable = (0, reaching_definitions_js_1.getVariableFromIdentifier)(node, context.sourceCode.getScope(node));
118
123
  if (variable) {
119
124
  const definition = variable.defs.at(-1);
120
125
  if (definition?.type === 'Parameter') {
121
- const type = (0, index_js_1.getTypeFromTreeNode)(definition.name, context.sourceCode.parserServices);
126
+ const type = (0, type_js_1.getTypeFromTreeNode)(definition.name, context.sourceCode.parserServices);
122
127
  const definitionParent = definition.name.parent;
123
- if ((0, index_js_1.isBooleanType)(type) && definitionParent?.type !== 'Property') {
124
- (0, index_js_1.report)(context, {
128
+ if ((0, type_js_1.isBooleanType)(type) && definitionParent?.type !== 'Property') {
129
+ (0, location_js_1.report)(context, {
125
130
  message,
126
131
  loc: node.loc,
127
132
  data: {
128
133
  parameterName: variable.name,
129
134
  },
130
135
  }, [
131
- (0, index_js_1.toSecondaryLocation)(definition.name, `Parameter "${variable.name}" was declared here`),
136
+ (0, location_js_1.toSecondaryLocation)(definition.name, `Parameter "${variable.name}" was declared here`),
132
137
  ]);
133
138
  }
134
139
  }
package/cjs/S2310/rule.js CHANGED
@@ -51,10 +51,13 @@ 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 ancestor_js_1 = require("../helpers/ancestor.js");
56
+ const ast_js_1 = require("../helpers/ast.js");
57
+ const location_js_1 = require("../helpers/location.js");
55
58
  const meta = __importStar(require("./generated-meta.js"));
56
59
  exports.rule = {
57
- meta: (0, index_js_1.generateMeta)(meta),
60
+ meta: (0, generate_meta_js_1.generateMeta)(meta),
58
61
  create(context) {
59
62
  function checkLoop(updateNode, extractCounters, loopBody) {
60
63
  const counters = [];
@@ -64,7 +67,7 @@ exports.rule = {
64
67
  }
65
68
  }
66
69
  function checkCounter(counter, block) {
67
- const variable = (0, index_js_1.getVariableFromName)(context, counter.name, block);
70
+ const variable = (0, ast_js_1.getVariableFromName)(context, counter.name, block);
68
71
  if (!variable) {
69
72
  return;
70
73
  }
@@ -73,16 +76,16 @@ exports.rule = {
73
76
  if (isIntentionalSkipAhead(ref.identifier, block)) {
74
77
  continue;
75
78
  }
76
- (0, index_js_1.report)(context, {
79
+ (0, location_js_1.report)(context, {
77
80
  node: ref.identifier,
78
81
  message: `Remove this assignment of "${counter.name}".`,
79
- }, [(0, index_js_1.toSecondaryLocation)(counter, 'Counter variable update')]);
82
+ }, [(0, location_js_1.toSecondaryLocation)(counter, 'Counter variable update')]);
80
83
  }
81
84
  }
82
85
  }
83
86
  return {
84
87
  'ForStatement > BlockStatement': (node) => {
85
- const forLoop = (0, index_js_1.getParent)(context, node);
88
+ const forLoop = (0, ancestor_js_1.getParent)(context, node);
86
89
  if (forLoop.update) {
87
90
  checkLoop(forLoop.update, collectCountersFor, node);
88
91
  }
@@ -121,7 +124,7 @@ function isIntentionalSkipAhead(id, outerLoopBody) {
121
124
  if (isInNestedForLoopUpdate(id, outerLoopBody)) {
122
125
  return false;
123
126
  }
124
- const parent = (0, index_js_1.getNodeParent)(id);
127
+ const parent = (0, ancestor_js_1.getNodeParent)(id);
125
128
  if (parent?.type === 'UpdateExpression') {
126
129
  return true;
127
130
  }
@@ -140,12 +143,12 @@ function isIntentionalSkipAhead(id, outerLoopBody) {
140
143
  * Walks up the AST from the given node to find the nearest enclosing BlockStatement.
141
144
  */
142
145
  function findEnclosingBlock(node) {
143
- let current = (0, index_js_1.getNodeParent)(node);
146
+ let current = (0, ancestor_js_1.getNodeParent)(node);
144
147
  while (current) {
145
148
  if (current.type === 'BlockStatement') {
146
149
  return current;
147
150
  }
148
- current = (0, index_js_1.getNodeParent)(current);
151
+ current = (0, ancestor_js_1.getNodeParent)(current);
149
152
  }
150
153
  return undefined;
151
154
  }
@@ -202,7 +205,7 @@ function isUsedInsideBody(id, loopBody) {
202
205
  }
203
206
  function isInNestedForLoopUpdate(id, outerLoopBody) {
204
207
  let node = id;
205
- let parent = (0, index_js_1.getNodeParent)(node);
208
+ let parent = (0, ancestor_js_1.getNodeParent)(node);
206
209
  while (parent) {
207
210
  // Stop if we've reached the outer loop body
208
211
  if (parent === outerLoopBody) {
@@ -219,7 +222,7 @@ function isInNestedForLoopUpdate(id, outerLoopBody) {
219
222
  }
220
223
  }
221
224
  node = parent;
222
- parent = (0, index_js_1.getNodeParent)(node);
225
+ parent = (0, ancestor_js_1.getNodeParent)(node);
223
226
  }
224
227
  return false;
225
228
  }
package/cjs/S2392/rule.js CHANGED
@@ -51,10 +51,12 @@ 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 collection_js_1 = require("../helpers/collection.js");
56
+ const location_js_1 = require("../helpers/location.js");
55
57
  const meta = __importStar(require("./generated-meta.js"));
56
58
  exports.rule = {
57
- meta: (0, index_js_1.generateMeta)(meta),
59
+ meta: (0, generate_meta_js_1.generateMeta)(meta),
58
60
  create(context) {
59
61
  let scopeRanges = [];
60
62
  let reported = [];
@@ -84,7 +86,7 @@ exports.rule = {
84
86
  if (varDeclaration.kind !== 'var') {
85
87
  return;
86
88
  }
87
- const scopeRange = (0, index_js_1.last)(scopeRanges);
89
+ const scopeRange = (0, collection_js_1.last)(scopeRanges);
88
90
  function isOutsideOfScope(reference) {
89
91
  const idRange = reference.range;
90
92
  return idRange[0] < scopeRange[0] || idRange[1] > scopeRange[1];
@@ -98,11 +100,11 @@ exports.rule = {
98
100
  }
99
101
  const definition = variable.defs.find(def => varDeclaration.declarations.includes(def.node));
100
102
  if (definition && !reported.includes(definition.name)) {
101
- (0, index_js_1.report)(context, {
103
+ (0, location_js_1.report)(context, {
102
104
  node: definition.name,
103
105
  message: `Consider moving declaration of '${variable.name}' ` +
104
106
  `as it is referenced outside current binding context.`,
105
- }, referencesOutside.map(node => (0, index_js_1.toSecondaryLocation)(node, 'Outside reference.')));
107
+ }, referencesOutside.map(node => (0, location_js_1.toSecondaryLocation)(node, 'Outside reference.')));
106
108
  for (const defId of variable.defs.map(def => def.name)) {
107
109
  reported.push(defId);
108
110
  }
package/cjs/S2424/rule.js CHANGED
@@ -55,10 +55,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
55
55
  Object.defineProperty(exports, "__esModule", { value: true });
56
56
  exports.rule = void 0;
57
57
  const globals_1 = __importDefault(require("globals"));
58
- const index_js_1 = require("../helpers/index.js");
58
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
59
59
  const meta = __importStar(require("./generated-meta.js"));
60
60
  exports.rule = {
61
- meta: (0, index_js_1.generateMeta)(meta, {
61
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
62
62
  messages: {
63
63
  removeOverride: 'Remove this override of "{{overridden}}".',
64
64
  },
package/cjs/S2428/rule.js CHANGED
@@ -51,10 +51,12 @@ 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 equivalence_js_1 = require("../helpers/equivalence.js");
55
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
56
+ const ast_js_1 = require("../helpers/ast.js");
55
57
  const meta = __importStar(require("./generated-meta.js"));
56
58
  exports.rule = {
57
- meta: (0, index_js_1.generateMeta)(meta, {
59
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
58
60
  messages: {
59
61
  declarePropertiesInsideObject: 'Declare one or more properties of this object inside of the object literal syntax instead of using separate statements.',
60
62
  },
@@ -63,7 +65,7 @@ exports.rule = {
63
65
  return {
64
66
  BlockStatement: (node) => checkObjectInitialization(node.body, context),
65
67
  Program: (node) => {
66
- checkObjectInitialization((0, index_js_1.getProgramStatements)(node), context);
68
+ checkObjectInitialization((0, ast_js_1.getProgramStatements)(node), context);
67
69
  },
68
70
  };
69
71
  },
@@ -72,7 +74,7 @@ function checkObjectInitialization(statements, context) {
72
74
  let index = 0;
73
75
  while (index < statements.length - 1) {
74
76
  const objectDeclaration = getObjectDeclaration(statements[index]);
75
- if (objectDeclaration && (0, index_js_1.isIdentifier)(objectDeclaration.id)) {
77
+ if (objectDeclaration && (0, ast_js_1.isIdentifier)(objectDeclaration.id)) {
76
78
  const nextStmt = statements[index + 1];
77
79
  if (isPropertyAssignment(nextStmt, objectDeclaration.id, context.sourceCode)) {
78
80
  context.report({ messageId: 'declarePropertiesInsideObject', node: objectDeclaration });
@@ -97,8 +99,8 @@ function isPropertyAssignment(statement, objectIdentifier, sourceCode) {
97
99
  if (left.type === 'MemberExpression') {
98
100
  return (!left.computed &&
99
101
  isSingleLineExpression(right, sourceCode) &&
100
- (0, index_js_1.areEquivalent)(left.object, objectIdentifier, sourceCode) &&
101
- !(0, index_js_1.areEquivalent)(left.object, right, sourceCode));
102
+ (0, equivalence_js_1.areEquivalent)(left.object, objectIdentifier, sourceCode) &&
103
+ !(0, equivalence_js_1.areEquivalent)(left.object, right, sourceCode));
102
104
  }
103
105
  }
104
106
  return false;
package/cjs/S2486/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
  handleException: "Handle this exception or don't catch it at all.",
60
61
  },
@@ -64,7 +65,7 @@ exports.rule = {
64
65
  'CatchClause[param.type="Identifier"]'(node) {
65
66
  const param = node.param;
66
67
  const scope = context.sourceCode.getScope(node);
67
- const variable = (0, index_js_1.getVariableFromScope)(scope, param.name);
68
+ const variable = (0, ast_js_1.getVariableFromScope)(scope, param.name);
68
69
  if (variable?.references.length === 0) {
69
70
  context.report({
70
71
  messageId: 'handleException',
package/cjs/S2589/rule.js CHANGED
@@ -51,11 +51,13 @@ 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 location_js_1 = require("../helpers/location.js");
55
57
  const meta = __importStar(require("./generated-meta.js"));
56
58
  const message = 'This always evaluates to {{value}}. Consider refactoring this code.';
57
59
  exports.rule = {
58
- meta: (0, index_js_1.generateMeta)(meta, {
60
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
59
61
  messages: {
60
62
  refactorBooleanExpression: message,
61
63
  },
@@ -76,7 +78,7 @@ exports.rule = {
76
78
  },
77
79
  ':statement': (node) => {
78
80
  const { parent } = node;
79
- if ((0, index_js_1.isIfStatement)(parent)) {
81
+ if ((0, ast_js_1.isIfStatement)(parent)) {
80
82
  // we visit 'consequent' and 'alternate' and not if-statement directly in order to get scope for 'consequent'
81
83
  const currentScope = context.sourceCode.getScope(node);
82
84
  if (parent.consequent === node) {
@@ -84,7 +86,7 @@ exports.rule = {
84
86
  truthyMap.set(parent.consequent, transformAndFilter(truthy, currentScope));
85
87
  falsyMap.set(parent.consequent, transformAndFilter(falsy, currentScope));
86
88
  }
87
- else if (parent.alternate === node && (0, index_js_1.isIdentifier)(parent.test)) {
89
+ else if (parent.alternate === node && (0, ast_js_1.isIdentifier)(parent.test)) {
88
90
  falsyMap.set(parent.alternate, transformAndFilter([parent.test], currentScope));
89
91
  }
90
92
  }
@@ -103,7 +105,7 @@ exports.rule = {
103
105
  }
104
106
  if (!isLogicalAnd(parent) &&
105
107
  !isLogicalOrLhs(id, parent) &&
106
- !(0, index_js_1.isIfStatement)(parent) &&
108
+ !(0, ast_js_1.isIfStatement)(parent) &&
107
109
  !isLogicalNegation(parent)) {
108
110
  return;
109
111
  }
@@ -129,14 +131,14 @@ function collectKnownIdentifiers(expression) {
129
131
  const truthy = [];
130
132
  const falsy = [];
131
133
  const checkExpr = (expr) => {
132
- if ((0, index_js_1.isIdentifier)(expr)) {
134
+ if ((0, ast_js_1.isIdentifier)(expr)) {
133
135
  truthy.push(expr);
134
136
  }
135
137
  else if (isLogicalNegation(expr)) {
136
- if ((0, index_js_1.isIdentifier)(expr.argument)) {
138
+ if ((0, ast_js_1.isIdentifier)(expr.argument)) {
137
139
  falsy.push(expr.argument);
138
140
  }
139
- else if (isLogicalNegation(expr.argument) && (0, index_js_1.isIdentifier)(expr.argument.argument)) {
141
+ else if (isLogicalNegation(expr.argument) && (0, ast_js_1.isIdentifier)(expr.argument.argument)) {
140
142
  truthy.push(expr.argument.argument);
141
143
  }
142
144
  }
@@ -212,11 +214,11 @@ function transformAndFilter(ids, currentScope) {
212
214
  }
213
215
  function reportIssue(id, ref, context, truthy) {
214
216
  const value = truthy ? 'truthy' : 'falsy';
215
- (0, index_js_1.report)(context, {
217
+ (0, location_js_1.report)(context, {
216
218
  message,
217
219
  data: {
218
220
  value,
219
221
  },
220
222
  node: id,
221
- }, ref?.identifier ? [(0, index_js_1.toSecondaryLocation)(ref.identifier, `Evaluated here to be ${value}`)] : []);
223
+ }, ref?.identifier ? [(0, location_js_1.toSecondaryLocation)(ref.identifier, `Evaluated here to be ${value}`)] : []);
222
224
  }
package/cjs/S2598/rule.js CHANGED
@@ -52,7 +52,10 @@ var __importStar = (this && this.__importStar) || (function () {
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.rule = void 0;
54
54
  exports.getVariablePropertyFromAssignment = getVariablePropertyFromAssignment;
55
- const index_js_1 = require("../helpers/index.js");
55
+ const location_js_1 = require("../helpers/location.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");
56
59
  const meta = __importStar(require("./generated-meta.js"));
57
60
  const FORMIDABLE_MODULE = 'formidable';
58
61
  const KEEP_EXTENSIONS = 'keepExtensions';
@@ -62,7 +65,7 @@ const STORAGE_OPTION = 'storage';
62
65
  const DESTINATION_OPTION = 'destination';
63
66
  const formidableObjects = new Map();
64
67
  exports.rule = {
65
- meta: (0, index_js_1.generateMeta)(meta),
68
+ meta: (0, generate_meta_js_1.generateMeta)(meta),
66
69
  create(context) {
67
70
  return {
68
71
  NewExpression(node) {
@@ -90,7 +93,7 @@ function checkCallExpression(context, callExpression) {
90
93
  if (callee.type !== 'Identifier') {
91
94
  return;
92
95
  }
93
- const fqn = (0, index_js_1.getFullyQualifiedName)(context, callee);
96
+ const fqn = (0, module_js_1.getFullyQualifiedName)(context, callee);
94
97
  if (!fqn) {
95
98
  return;
96
99
  }
@@ -104,7 +107,7 @@ function checkCallExpression(context, callExpression) {
104
107
  }
105
108
  function checkFormidable(context, callExpression) {
106
109
  if (callExpression.arguments.length === 0) {
107
- const formVariable = (0, index_js_1.getLhsVariable)(context, callExpression);
110
+ const formVariable = (0, ast_js_1.getLhsVariable)(context, callExpression);
108
111
  if (formVariable) {
109
112
  formidableObjects.set(formVariable, {
110
113
  uploadDirSet: false,
@@ -114,26 +117,26 @@ function checkFormidable(context, callExpression) {
114
117
  }
115
118
  return;
116
119
  }
117
- const options = (0, index_js_1.getValueOfExpression)(context, callExpression.arguments[0], 'ObjectExpression');
120
+ const options = (0, ast_js_1.getValueOfExpression)(context, callExpression.arguments[0], 'ObjectExpression');
118
121
  if (options) {
119
- report(context, !!(0, index_js_1.getProperty)(options, UPLOAD_DIR, context), keepExtensionsValue((0, index_js_1.getProperty)(options, KEEP_EXTENSIONS, context)?.value), callExpression);
122
+ report(context, !!(0, ast_js_1.getProperty)(options, UPLOAD_DIR, context), keepExtensionsValue((0, ast_js_1.getProperty)(options, KEEP_EXTENSIONS, context)?.value), callExpression);
120
123
  }
121
124
  }
122
125
  function checkMulter(context, callExpression) {
123
126
  if (callExpression.arguments.length === 0) {
124
127
  return;
125
128
  }
126
- const multerOptions = (0, index_js_1.getValueOfExpression)(context, callExpression.arguments[0], 'ObjectExpression');
129
+ const multerOptions = (0, ast_js_1.getValueOfExpression)(context, callExpression.arguments[0], 'ObjectExpression');
127
130
  if (!multerOptions) {
128
131
  return;
129
132
  }
130
- const storagePropertyValue = (0, index_js_1.getProperty)(multerOptions, STORAGE_OPTION, context)?.value;
133
+ const storagePropertyValue = (0, ast_js_1.getProperty)(multerOptions, STORAGE_OPTION, context)?.value;
131
134
  if (storagePropertyValue) {
132
- const storageValue = (0, index_js_1.getValueOfExpression)(context, storagePropertyValue, 'CallExpression');
135
+ const storageValue = (0, ast_js_1.getValueOfExpression)(context, storagePropertyValue, 'CallExpression');
133
136
  if (storageValue) {
134
137
  const diskStorageCallee = getDiskStorageCalleeIfUnsafeStorage(context, storageValue);
135
138
  if (diskStorageCallee) {
136
- report(context, false, false, callExpression, (0, index_js_1.toSecondaryLocation)(diskStorageCallee, 'no destination specified'));
139
+ report(context, false, false, callExpression, (0, location_js_1.toSecondaryLocation)(diskStorageCallee, 'no destination specified'));
137
140
  }
138
141
  }
139
142
  }
@@ -141,8 +144,8 @@ function checkMulter(context, callExpression) {
141
144
  function getDiskStorageCalleeIfUnsafeStorage(context, storageCreation) {
142
145
  const { arguments: args, callee } = storageCreation;
143
146
  if (args.length > 0 && isMemberWithProperty(callee, 'diskStorage')) {
144
- const storageOptions = (0, index_js_1.getValueOfExpression)(context, args[0], 'ObjectExpression');
145
- if (storageOptions && !(0, index_js_1.getProperty)(storageOptions, DESTINATION_OPTION, context)) {
147
+ const storageOptions = (0, ast_js_1.getValueOfExpression)(context, args[0], 'ObjectExpression');
148
+ if (storageOptions && !(0, ast_js_1.getProperty)(storageOptions, DESTINATION_OPTION, context)) {
146
149
  return callee;
147
150
  }
148
151
  }
@@ -184,7 +187,7 @@ function getVariablePropertyFromAssignment(context, assignment) {
184
187
  }
185
188
  const memberExpr = assignment.left;
186
189
  if (memberExpr.object.type === 'Identifier' && memberExpr.property.type === 'Identifier') {
187
- const objectVariable = (0, index_js_1.getVariableFromName)(context, memberExpr.object.name, memberExpr);
190
+ const objectVariable = (0, ast_js_1.getVariableFromName)(context, memberExpr.object.name, memberExpr);
188
191
  if (objectVariable) {
189
192
  return { objectVariable, property: memberExpr.property.name };
190
193
  }
@@ -203,7 +206,7 @@ function report(context, uploadDirSet, keepExtensions, callExpression, secondary
203
206
  message = 'Restrict the extension and folder destination of uploaded files.';
204
207
  }
205
208
  if (message) {
206
- (0, index_js_1.report)(context, {
209
+ (0, location_js_1.report)(context, {
207
210
  message,
208
211
  node: callExpression.callee,
209
212
  }, secondaryLocation ? [secondaryLocation] : []);
@@ -36,7 +36,7 @@ __exportStar(require("./meta.js"), exports);
36
36
  exports.meta = {
37
37
  type: 'problem',
38
38
  docs: {
39
- description: 'Setting loose POSIX file permissions is security-sensitive',
39
+ description: 'File permissions should not be set to world-accessible values',
40
40
  recommended: true,
41
41
  url: 'https://sonarsource.github.io/rspec/#/rspec/S2612/javascript',
42
42
  requiresTypeChecking: false,
package/cjs/S2612/rule.js CHANGED
@@ -51,11 +51,13 @@ 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 chmodLikeFunction = ['chmod', 'chmodSync', 'fchmod', 'fchmodSync', 'lchmod', 'lchmodSync'];
57
59
  exports.rule = {
58
- meta: (0, index_js_1.generateMeta)(meta, {
60
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
59
61
  messages: {
60
62
  safePermission: 'Make sure this permission is safe.',
61
63
  },
@@ -78,7 +80,7 @@ exports.rule = {
78
80
  };
79
81
  function modeFromMemberExpression(modeExpr) {
80
82
  const { object, property } = modeExpr;
81
- if ((0, index_js_1.isMemberExpression)(object, 'fs', 'constants') && property.type === 'Identifier') {
83
+ if ((0, ast_js_1.isMemberExpression)(object, 'fs', 'constants') && property.type === 'Identifier') {
82
84
  return FS_CONST[property.name];
83
85
  }
84
86
  return null;
@@ -94,7 +96,7 @@ exports.rule = {
94
96
  return modeFromLiteral(expr);
95
97
  }
96
98
  else if (expr.type === 'Identifier') {
97
- const usage = (0, index_js_1.getUniqueWriteUsage)(context, expr.name, expr);
99
+ const usage = (0, ast_js_1.getUniqueWriteUsage)(context, expr.name, expr);
98
100
  if (usage && !visited.has(usage)) {
99
101
  visited.add(usage);
100
102
  return modeFromExpression(usage, visited);
@@ -129,7 +131,7 @@ exports.rule = {
129
131
  checkModeArgument(callExpression.arguments[0], 0);
130
132
  checkModeArgument(callExpression.arguments[1], 0);
131
133
  }
132
- else if ((0, index_js_1.getFullyQualifiedName)(context, callExpression) === 'process.umask') {
134
+ else if ((0, module_js_1.getFullyQualifiedName)(context, callExpression) === 'process.umask') {
133
135
  checkModeArgument(callExpression.arguments[0], 7);
134
136
  }
135
137
  },
@@ -142,7 +144,7 @@ function isChmodLikeFunction(node) {
142
144
  return false;
143
145
  }
144
146
  // to support fs promises we are only checking the name of the function
145
- return (0, index_js_1.isIdentifier)(callee.property, ...chmodLikeFunction);
147
+ return (0, ast_js_1.isIdentifier)(callee.property, ...chmodLikeFunction);
146
148
  }
147
149
  function modeFromLiteral(modeExpr) {
148
150
  const modeValue = modeExpr.value;
package/cjs/S2639/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 => {
@@ -66,7 +66,7 @@ exports.rule = (0, rule_template_js_1.createRegExpRule)(context => {
66
66
  }
67
67
  },
68
68
  };
69
- }, (0, index_js_1.generateMeta)(meta, {
69
+ }, (0, generate_meta_js_1.generateMeta)(meta, {
70
70
  messages: {
71
71
  issue: "Rework this empty character class that doesn't match anything.",
72
72
  },
package/cjs/S2681/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 NestingStatementLike = new Set([
57
57
  'IfStatement',
@@ -61,7 +61,7 @@ const NestingStatementLike = new Set([
61
61
  'WhileStatement',
62
62
  ]);
63
63
  exports.rule = {
64
- meta: (0, index_js_1.generateMeta)(meta),
64
+ meta: (0, generate_meta_js_1.generateMeta)(meta),
65
65
  create(context) {
66
66
  return {
67
67
  Program: (node) => checkStatements(node.body, context),
package/cjs/S2692/rule.js CHANGED
@@ -51,17 +51,19 @@ 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 parser_services_js_1 = require("../helpers/parser-services.js");
55
+ const generate_meta_js_1 = require("../helpers/generate-meta.js");
56
+ const type_js_1 = require("../helpers/type.js");
55
57
  const meta = __importStar(require("./generated-meta.js"));
56
58
  exports.rule = {
57
- meta: (0, index_js_1.generateMeta)(meta, {
59
+ meta: (0, generate_meta_js_1.generateMeta)(meta, {
58
60
  messages: {
59
61
  considerIncludes: "This check ignores index 0; consider using 'includes' method to make this check safe and explicit.",
60
62
  },
61
63
  }),
62
64
  create(context) {
63
65
  const services = context.sourceCode.parserServices;
64
- if (!(0, index_js_1.isRequiredParserServices)(services)) {
66
+ if (!(0, parser_services_js_1.isRequiredParserServices)(services)) {
65
67
  return {};
66
68
  }
67
69
  return {
@@ -85,5 +87,5 @@ function isArrayIndexOfCall(node, services) {
85
87
  node.callee.type === 'MemberExpression' &&
86
88
  node.callee.property.type === 'Identifier' &&
87
89
  node.callee.property.name === 'indexOf' &&
88
- (0, index_js_1.isArray)(node.callee.object, services));
90
+ (0, type_js_1.isArray)(node.callee.object, services));
89
91
  }