eslint-plugin-sonarjs 4.0.0 → 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.
- package/README.md +269 -268
- package/cjs/S100/rule.js +7 -5
- package/cjs/S101/rule.js +2 -2
- package/cjs/S104/rule.js +2 -2
- package/cjs/S105/rule.js +2 -2
- package/cjs/S1066/rule.js +5 -4
- package/cjs/S1067/rule.js +8 -6
- package/cjs/S1110/rule.js +7 -5
- package/cjs/S1119/rule.js +85 -7
- package/cjs/S1121/rule.js +4 -3
- package/cjs/S1125/rule.js +9 -8
- package/cjs/S1126/rule.js +2 -2
- package/cjs/S1128/rule.js +8 -5
- package/cjs/S1134/rule.js +2 -2
- package/cjs/S1135/rule.js +2 -2
- package/cjs/S1154/rule.js +6 -4
- package/cjs/S117/rule.js +6 -5
- package/cjs/S1172/rule.js +2 -2
- package/cjs/S1192/rule.js +5 -4
- package/cjs/S1219/rule.js +4 -3
- package/cjs/S1226/rule.js +6 -4
- package/cjs/S124/rule.js +2 -2
- package/cjs/S125/rule.js +9 -7
- package/cjs/S126/rule.js +2 -2
- package/cjs/S1264/rule.js +2 -2
- package/cjs/S128/rule.js +4 -3
- package/cjs/S1291/rule.js +2 -2
- package/cjs/S1301/rule.js +2 -2
- package/cjs/S1313/rule.js +2 -2
- package/cjs/S134/rule.js +7 -5
- package/cjs/S135/rule.js +5 -4
- package/cjs/S138/rule.js +9 -6
- package/cjs/S1439/rule.js +2 -2
- package/cjs/S1444/rule.js +2 -2
- package/cjs/S1451/rule.js +2 -2
- package/cjs/S1472/rule.js +2 -2
- package/cjs/S1479/rule.js +2 -2
- package/cjs/S1481/rule.js +2 -2
- package/cjs/S1488/generated-meta.js +1 -1
- package/cjs/S1488/rule.js +11 -7
- package/cjs/S1515/rule.js +10 -8
- package/cjs/{helpers/aws/index.js → S1523/generated-meta.js} +34 -18
- package/cjs/S1523/index.js +21 -0
- package/cjs/S1523/meta.js +21 -0
- package/cjs/S1523/rule.js +143 -0
- package/cjs/S1526/rule.js +5 -4
- package/cjs/S1527/rule.js +2 -2
- package/cjs/S1528/rule.js +2 -2
- package/cjs/S1529/generated-meta.js +1 -1
- package/cjs/S1529/rule.js +4 -3
- package/cjs/S1530/rule.js +5 -3
- package/cjs/S1533/rule.js +2 -2
- package/cjs/S1535/rule.js +2 -2
- package/cjs/S1541/rule.js +10 -7
- package/cjs/S1607/rule.js +22 -20
- package/cjs/S1764/rule.js +10 -7
- package/cjs/S1821/rule.js +2 -2
- package/cjs/S1848/rule.js +10 -7
- package/cjs/S1854/rule.js +18 -14
- package/cjs/S1862/rule.js +10 -8
- package/cjs/S1871/rule.js +21 -16
- package/cjs/S1874/rule.js +4 -3
- package/cjs/S1940/rule.js +2 -2
- package/cjs/S1994/rule.js +10 -7
- package/cjs/S2004/rule.js +9 -7
- package/cjs/S2068/rule.js +75 -12
- package/cjs/S2077/generated-meta.js +1 -1
- package/cjs/S2077/rule.js +10 -6
- package/cjs/S2092/rule.js +2 -2
- package/cjs/S2123/rule.js +2 -2
- package/cjs/S2137/rule.js +2 -2
- package/cjs/S2138/rule.js +4 -3
- package/cjs/S2187/rule.js +2 -2
- package/cjs/S2201/rule.js +47 -5
- package/cjs/S2208/rule.js +2 -2
- package/cjs/S2234/rule.js +58 -11
- package/cjs/S2245/rule.js +4 -3
- package/cjs/S2251/rule.js +5 -4
- package/cjs/S2255/rule.js +6 -5
- package/cjs/S2259/rule.js +14 -9
- package/cjs/S2301/rule.js +14 -9
- package/cjs/S2310/rule.js +80 -9
- package/cjs/S2392/rule.js +7 -5
- package/cjs/S2424/rule.js +2 -2
- package/cjs/S2428/rule.js +8 -6
- package/cjs/S2486/rule.js +4 -3
- package/cjs/S2589/rule.js +12 -10
- package/cjs/S2598/rule.js +17 -14
- package/cjs/S2612/generated-meta.js +1 -1
- package/cjs/S2612/rule.js +8 -6
- package/cjs/S2639/rule.js +2 -2
- package/cjs/S2681/rule.js +2 -2
- package/cjs/S2692/rule.js +6 -4
- package/cjs/S2699/generated-meta.js +1 -1
- package/cjs/S2699/rule.js +40 -31
- package/cjs/S2703/rule.js +2 -2
- package/cjs/S2737/rule.js +6 -4
- package/cjs/S2755/rule.js +9 -6
- package/cjs/S2757/rule.js +2 -2
- package/cjs/S2817/rule.js +10 -7
- package/cjs/S2819/rule.js +16 -12
- package/cjs/S2870/rule.js +8 -5
- package/cjs/S2871/rule.js +12 -9
- package/cjs/S2970/rule.js +9 -8
- package/cjs/S2990/rule.js +2 -2
- package/cjs/S2999/rule.js +10 -7
- package/cjs/S3001/rule.js +2 -2
- package/cjs/S3003/rule.js +10 -7
- package/cjs/S3317/rule.js +4 -3
- package/cjs/S3330/rule.js +2 -2
- package/cjs/S3358/rule.js +2 -2
- package/cjs/S3402/rule.js +14 -10
- package/cjs/S3403/rule.js +10 -7
- package/cjs/S3415/rule.js +16 -13
- package/cjs/S3499/rule.js +5 -4
- package/cjs/S3500/rule.js +5 -4
- package/cjs/S3513/rule.js +5 -4
- package/cjs/S3514/rule.js +10 -7
- package/cjs/S3516/rule.js +10 -7
- package/cjs/S3524/rule.js +2 -2
- package/cjs/S3525/rule.js +6 -4
- package/cjs/S3531/rule.js +5 -3
- package/cjs/S3533/rule.js +8 -7
- package/cjs/S3579/rule.js +6 -4
- package/cjs/S3616/rule.js +6 -4
- package/cjs/S3626/rule.js +4 -3
- package/cjs/S3686/rule.js +7 -5
- package/cjs/S3699/rule.js +4 -3
- package/cjs/S3735/rule.js +8 -5
- package/cjs/S3757/rule.js +8 -6
- package/cjs/S3758/rule.js +9 -7
- package/cjs/S3760/rule.js +24 -21
- package/cjs/S3776/rule.js +26 -22
- package/cjs/S3782/rule.js +6 -4
- package/cjs/S3785/rule.js +9 -6
- package/cjs/S3796/rule.js +12 -8
- package/cjs/S3798/rule.js +4 -3
- package/cjs/S3800/rule.js +22 -11
- package/cjs/S3801/generated-meta.js +1 -1
- package/cjs/S3801/rule.js +15 -11
- package/cjs/S3827/rule.js +9 -6
- package/cjs/S3923/rule.js +9 -6
- package/cjs/S3972/rule.js +5 -4
- package/cjs/S3973/rule.js +7 -5
- package/cjs/S3981/rule.js +4 -3
- package/cjs/S3984/rule.js +4 -3
- package/cjs/S4030/rule.js +10 -7
- package/cjs/S4036/rule.js +7 -5
- package/cjs/S4043/rule.js +12 -8
- package/cjs/S4139/rule.js +7 -5
- package/cjs/S4143/rule.js +12 -9
- package/cjs/S4144/rule.js +12 -9
- package/cjs/S4158/rule.js +11 -8
- package/cjs/S4165/rule.js +14 -12
- package/cjs/S4322/rule.js +8 -5
- package/cjs/S4323/rule.js +4 -3
- package/cjs/S4324/rule.js +7 -5
- package/cjs/S4328/rule.js +2 -2
- package/cjs/S4335/rule.js +6 -4
- package/cjs/S4423/rule.js +4 -3
- package/cjs/S4423/rule.lib.js +8 -7
- package/cjs/S4426/rule.js +11 -10
- package/cjs/S4502/rule.js +16 -13
- package/cjs/S4507/rule.js +8 -6
- package/cjs/S4524/rule.js +2 -2
- package/cjs/S4619/rule.js +6 -4
- package/cjs/S4621/rule.js +5 -4
- package/cjs/S4622/rule.js +5 -3
- package/cjs/S4623/rule.js +8 -5
- package/cjs/S4624/rule.js +6 -4
- package/cjs/S4634/rule.js +4 -3
- package/cjs/S4721/rule.js +7 -5
- package/cjs/S4782/rule.js +7 -5
- package/cjs/S4784/rule.js +5 -4
- package/cjs/S4787/rule.js +9 -7
- package/cjs/S4790/rule.js +7 -5
- package/cjs/S4798/rule.js +2 -2
- package/cjs/S4817/rule.js +10 -8
- package/cjs/S4818/rule.js +4 -3
- package/cjs/S4822/rule.js +13 -9
- package/cjs/S4823/rule.js +4 -3
- package/cjs/S4829/rule.js +4 -3
- package/cjs/S4830/rule.js +11 -8
- package/cjs/S5042/rule.js +9 -7
- package/cjs/S5122/rule.js +40 -36
- package/cjs/S5148/rule.js +9 -8
- package/cjs/S5247/rule.js +22 -18
- package/cjs/S5256/rule.js +5 -4
- package/cjs/S5257/rule.js +4 -3
- package/cjs/S5260/rule.js +4 -3
- package/cjs/S5264/rule.js +4 -3
- package/cjs/S5332/rule.js +4 -3
- package/cjs/S5332/rule.lib.js +19 -17
- package/cjs/S5443/rule.js +2 -2
- package/cjs/S5527/rule.js +18 -14
- package/cjs/S5542/rule.js +6 -4
- package/cjs/S5547/rule.js +6 -4
- package/cjs/S5604/rule.js +15 -14
- package/cjs/S5659/rule.js +15 -12
- package/cjs/S5689/rule.js +11 -8
- package/cjs/S5691/rule.js +7 -5
- package/cjs/S5693/rule.js +14 -12
- package/cjs/S5725/rule.js +9 -6
- package/cjs/S5728/rule.js +7 -4
- package/cjs/S5730/rule.js +9 -6
- package/cjs/S5732/rule.js +8 -5
- package/cjs/S5734/rule.js +7 -4
- package/cjs/S5736/rule.js +8 -5
- package/cjs/S5739/rule.js +11 -8
- package/cjs/S5742/rule.js +7 -4
- package/cjs/S5743/rule.js +8 -6
- package/cjs/S5757/rule.js +13 -10
- package/cjs/S5759/rule.js +10 -7
- package/cjs/S5842/rule.js +2 -2
- package/cjs/S5843/rule.js +22 -19
- package/cjs/S5850/rule.js +4 -3
- package/cjs/S5852/rule.js +2 -2
- package/cjs/S5856/rule.js +10 -7
- package/cjs/S5860/rule.js +30 -26
- package/cjs/S5863/rule.js +15 -11
- package/cjs/S5867/rule.js +8 -7
- package/cjs/S5868/rule.js +7 -5
- package/cjs/S5869/rule.js +6 -5
- package/cjs/S5876/rule.js +12 -8
- package/cjs/S5958/rule.js +12 -9
- package/cjs/S5973/rule.js +10 -7
- package/cjs/S6019/rule.js +4 -3
- package/cjs/S6035/rule.js +2 -2
- package/cjs/S6079/rule.js +9 -6
- package/cjs/S6080/rule.js +13 -10
- package/cjs/S6092/rule.js +9 -7
- package/cjs/S6245/rule.js +14 -9
- package/cjs/S6249/rule.js +7 -5
- package/cjs/S6252/rule.js +12 -8
- package/cjs/S6265/rule.js +27 -20
- package/cjs/S6268/rule.js +5 -4
- package/cjs/S6270/rule.js +12 -9
- package/cjs/S6275/rule.js +2 -2
- package/cjs/S6281/rule.js +22 -17
- package/cjs/S6299/rule.js +2 -2
- package/cjs/S6302/rule.js +6 -5
- package/cjs/S6303/rule.js +12 -10
- package/cjs/S6304/rule.js +6 -5
- package/cjs/S6308/rule.js +7 -5
- package/cjs/S6317/rule.js +5 -4
- package/cjs/S6319/rule.js +2 -2
- package/cjs/S6321/rule.js +25 -23
- package/cjs/S6323/rule.js +4 -3
- package/cjs/S6324/rule.js +2 -2
- package/cjs/S6326/rule.js +2 -2
- package/cjs/S6327/rule.js +2 -2
- package/cjs/S6328/rule.js +4 -3
- package/cjs/S6329/rule.js +7 -5
- package/cjs/S6330/rule.js +2 -2
- package/cjs/S6332/rule.js +2 -2
- package/cjs/S6333/rule.js +8 -6
- package/cjs/S6351/rule.js +22 -19
- package/cjs/S6353/rule.js +2 -2
- package/cjs/S6397/rule.js +2 -2
- package/cjs/S6418/config.js +1 -1
- package/cjs/S6418/rule.js +9 -24
- package/cjs/S6426/rule.js +5 -4
- package/cjs/S6437/rule.js +10 -7
- package/cjs/S6439/rule.js +9 -7
- package/cjs/S6442/rule.js +11 -8
- package/cjs/S6443/rule.js +9 -7
- package/cjs/S6486/rule.js +5 -4
- package/cjs/S6564/rule.js +4 -3
- package/cjs/S6594/rule.js +12 -8
- package/cjs/S6627/rule.js +6 -4
- package/cjs/S6759/rule.js +10 -6
- package/cjs/S6958/rule.js +2 -2
- package/cjs/S6959/rule.js +9 -6
- package/cjs/S7059/generated-meta.js +1 -1
- package/cjs/S7059/rule.js +8 -5
- package/cjs/S7639/generated-meta.js +1 -1
- package/cjs/S7639/rule.js +5 -4
- package/cjs/S7790/generated-meta.js +1 -1
- package/cjs/S7790/rule.js +7 -5
- package/cjs/S8441/generated-meta.js +1 -1
- package/cjs/S8441/rule.js +13 -9
- package/cjs/S881/rule.js +2 -2
- package/cjs/S888/rule.js +4 -3
- package/cjs/S930/rule.js +14 -12
- package/cjs/helpers/ast.js +11 -8
- package/cjs/helpers/aws/s3.js +9 -6
- package/cjs/helpers/chai.js +41 -43
- package/cjs/helpers/configs.js +92 -0
- package/cjs/helpers/cookie-flag-check.js +19 -17
- package/cjs/helpers/{decorators/index.js → entropy.js} +16 -17
- package/cjs/helpers/express.js +127 -128
- package/cjs/helpers/find-up/all-in-parent-dirs.js +0 -16
- package/cjs/helpers/mocha.js +50 -54
- package/cjs/helpers/regex/ast.js +7 -6
- package/cjs/helpers/regex/extract.js +11 -11
- package/cjs/helpers/regex/group.js +2 -2
- package/cjs/helpers/regex/location.js +2 -2
- package/cjs/helpers/regex/range.js +5 -4
- package/cjs/helpers/regex/rule-template.js +4 -3
- package/cjs/helpers/sinon.js +33 -36
- package/cjs/helpers/supertest.js +34 -37
- package/cjs/helpers/vitest.js +29 -32
- package/cjs/plugin-rules.js +452 -450
- package/docs/assertions-in-tests.md +2 -0
- package/docs/bitwise-operators.md +2 -0
- package/docs/code-eval.md +7 -0
- package/docs/file-permissions.md +1 -1
- package/docs/no-async-constructor.md +2 -0
- package/docs/no-inconsistent-returns.md +2 -0
- package/docs/prefer-immediate-return.md +2 -0
- package/docs/sql-queries.md +2 -0
- package/package.json +39 -1
- package/types/S1067/rule.d.ts +1 -1
- package/types/S1110/rule.d.ts +1 -1
- package/types/S1128/rule.d.ts +1 -1
- package/types/S1172/rule.d.ts +1 -1
- package/types/S1226/rule.d.ts +1 -1
- package/types/S134/rule.d.ts +1 -1
- package/types/S1472/rule.d.ts +1 -1
- package/types/S1481/rule.d.ts +1 -1
- package/types/S1488/generated-meta.d.ts +1 -1
- package/types/S1515/rule.d.ts +1 -1
- package/types/S1523/generated-meta.d.ts +17 -0
- package/types/S1523/index.d.ts +1 -0
- package/types/S1523/meta.d.ts +2 -0
- package/types/S1523/rule.d.ts +2 -0
- package/types/S1527/rule.d.ts +1 -1
- package/types/S1529/generated-meta.d.ts +1 -1
- package/types/S1541/rule.d.ts +1 -1
- package/types/S1862/rule.d.ts +1 -1
- package/types/S2077/generated-meta.d.ts +1 -1
- package/types/S2123/rule.d.ts +1 -1
- package/types/S2259/rule.d.ts +1 -1
- package/types/S2428/rule.d.ts +1 -1
- package/types/S2589/rule.d.ts +1 -1
- package/types/S2598/rule.d.ts +1 -1
- package/types/S2699/generated-meta.d.ts +1 -1
- package/types/S2699/rule.d.ts +1 -1
- package/types/S2737/rule.d.ts +1 -1
- package/types/S2757/rule.d.ts +1 -1
- package/types/S2819/rule.d.ts +1 -1
- package/types/S3001/rule.d.ts +1 -1
- package/types/S3317/rule.d.ts +1 -1
- package/types/S3500/rule.d.ts +1 -1
- package/types/S3513/rule.d.ts +1 -1
- package/types/S3686/rule.d.ts +1 -1
- package/types/S3801/generated-meta.d.ts +1 -1
- package/types/S3972/rule.d.ts +1 -1
- package/types/S3973/rule.d.ts +1 -1
- package/types/S4030/rule.d.ts +1 -1
- package/types/S4143/rule.d.ts +1 -1
- package/types/S4158/rule.d.ts +1 -1
- package/types/S4621/rule.d.ts +1 -1
- package/types/S4782/rule.d.ts +1 -1
- package/types/S5693/rule.d.ts +1 -1
- package/types/S5725/rule.d.ts +1 -1
- package/types/S5860/rule.d.ts +1 -1
- package/types/S5868/rule.d.ts +1 -1
- package/types/S5869/rule.d.ts +1 -1
- package/types/S6079/rule.d.ts +1 -1
- package/types/S6326/rule.d.ts +1 -1
- package/types/S6351/rule.d.ts +1 -1
- package/types/S6418/config.d.ts +1 -1
- package/types/S6443/rule.d.ts +1 -1
- package/types/S7059/generated-meta.d.ts +1 -1
- package/types/S7639/generated-meta.d.ts +1 -1
- package/types/S7790/generated-meta.d.ts +1 -1
- package/types/S8441/generated-meta.d.ts +1 -1
- package/types/S930/rule.d.ts +1 -1
- package/types/helpers/ancestor.d.ts +3 -3
- package/types/helpers/ast.d.ts +1 -1
- package/types/helpers/aws/iam.d.ts +2 -2
- package/types/helpers/aws/s3.d.ts +1 -1
- package/types/helpers/chai.d.ts +3 -5
- package/types/helpers/configs.d.ts +39 -1
- package/types/helpers/entropy.d.ts +1 -0
- package/types/helpers/equivalence.d.ts +1 -1
- package/types/helpers/express.d.ts +38 -43
- package/types/helpers/find-up/all-in-parent-dirs.d.ts +1 -1
- package/types/helpers/find-up/closest.d.ts +1 -1
- package/types/helpers/find-up/find-minimatch.d.ts +1 -1
- package/types/helpers/generate-meta.d.ts +1 -1
- package/types/helpers/mocha.d.ts +19 -21
- package/types/helpers/module.d.ts +1 -1
- package/types/helpers/package-jsons/all-in-parent-dirs.d.ts +1 -1
- package/types/helpers/package-jsons/dependencies.d.ts +1 -1
- package/types/helpers/recognizers/CodeRecognizer.d.ts +1 -1
- package/types/helpers/recognizers/JavaScriptFootPrint.d.ts +2 -2
- package/types/helpers/recognizers/LanguageFootprint.d.ts +1 -1
- package/types/helpers/regex/alternation.d.ts +1 -1
- package/types/helpers/regex/ast.d.ts +1 -1
- package/types/helpers/regex/location.d.ts +2 -2
- package/types/helpers/regex/range.d.ts +2 -2
- package/types/helpers/regex/rule-template.d.ts +1 -1
- package/types/helpers/result.d.ts +1 -1
- package/types/helpers/sinon.d.ts +4 -6
- package/types/helpers/sonar-runtime.d.ts +1 -1
- package/types/helpers/supertest.d.ts +4 -6
- package/types/helpers/type.d.ts +1 -1
- package/types/helpers/vitest.d.ts +4 -6
- package/types/plugin-rules.d.ts +1 -0
- package/cjs/helpers/decorators/interceptor.js +0 -88
- package/cjs/helpers/index.js +0 -60
- package/cjs/helpers/recognizers/index.js +0 -37
- package/cjs/helpers/rule-detect-react.js +0 -29
- package/cjs/helpers/validate-version.js +0 -94
- package/types/helpers/aws/index.d.ts +0 -3
- package/types/helpers/decorators/index.d.ts +0 -2
- package/types/helpers/decorators/interceptor.d.ts +0 -16
- package/types/helpers/index.d.ts +0 -28
- package/types/helpers/recognizers/index.d.ts +0 -2
- package/types/helpers/rule-detect-react.d.ts +0 -2
- package/types/helpers/validate-version.d.ts +0 -13
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* SonarQube JavaScript Plugin
|
|
4
|
+
* Copyright (C) 2011-2025 SonarSource Sàrl
|
|
5
|
+
* mailto:info AT sonarsource DOT com
|
|
6
|
+
*
|
|
7
|
+
* This program is free software; you can redistribute it and/or
|
|
8
|
+
* modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
* See the Sonar Source-Available License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the Sonar Source-Available License
|
|
16
|
+
* along with this program; if not, see https://sonarsource.com/license/ssal/
|
|
17
|
+
*/
|
|
18
|
+
// https://sonarsource.github.io/rspec/#/rspec/S1523/javascript
|
|
19
|
+
// SQ key 'eval'
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
32
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
33
|
+
}) : function(o, v) {
|
|
34
|
+
o["default"] = v;
|
|
35
|
+
});
|
|
36
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
37
|
+
var ownKeys = function(o) {
|
|
38
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
39
|
+
var ar = [];
|
|
40
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
41
|
+
return ar;
|
|
42
|
+
};
|
|
43
|
+
return ownKeys(o);
|
|
44
|
+
};
|
|
45
|
+
return function (mod) {
|
|
46
|
+
if (mod && mod.__esModule) return mod;
|
|
47
|
+
var result = {};
|
|
48
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
49
|
+
__setModuleDefault(result, mod);
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
})();
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.rule = void 0;
|
|
55
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
56
|
+
const module_js_1 = require("../helpers/module.js");
|
|
57
|
+
const meta = __importStar(require("./generated-meta.js"));
|
|
58
|
+
const EVAL_LIKE_FUNCTIONS = new Set([
|
|
59
|
+
'eval',
|
|
60
|
+
'Function',
|
|
61
|
+
'vm.Script',
|
|
62
|
+
'vm.SourceTextModule',
|
|
63
|
+
'vm.runInContext',
|
|
64
|
+
'vm.runInNewContext',
|
|
65
|
+
'vm.runInThisContext',
|
|
66
|
+
]);
|
|
67
|
+
exports.rule = {
|
|
68
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta, {
|
|
69
|
+
messages: {
|
|
70
|
+
safeCode: 'Make sure that this dynamic injection or execution of code is safe.',
|
|
71
|
+
unexpectedScriptURL: "Make sure that 'javascript:' code is safe as it is a form of eval().",
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
create(context) {
|
|
75
|
+
return {
|
|
76
|
+
CallExpression: (node) => checkCallExpression(node, context),
|
|
77
|
+
NewExpression: (node) => checkCallExpression(node, context),
|
|
78
|
+
TemplateLiteral: (node) => {
|
|
79
|
+
if (node.expressions.length > 0 && /^javascript:/i.exec(node.quasis[0].value.raw)) {
|
|
80
|
+
context.report({ messageId: 'unexpectedScriptURL', node });
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
BinaryExpression: (node) => {
|
|
84
|
+
const parent = node.parent;
|
|
85
|
+
if (!isConcatenation(parent) &&
|
|
86
|
+
isConcatenation(node) &&
|
|
87
|
+
isVariableConcat(node) &&
|
|
88
|
+
/^javascript:/i.exec(getLeftmostStringValue(node) ?? '')) {
|
|
89
|
+
context.report({ messageId: 'unexpectedScriptURL', node });
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
function checkCallExpression(node, context) {
|
|
96
|
+
if (['Identifier', 'MemberExpression'].includes(node.callee.type)) {
|
|
97
|
+
const name = (0, module_js_1.getFullyQualifiedName)(context, node) || '';
|
|
98
|
+
if (EVAL_LIKE_FUNCTIONS.has(name) && hasAtLeastOneVariableArgument(node.arguments)) {
|
|
99
|
+
context.report({
|
|
100
|
+
messageId: 'safeCode',
|
|
101
|
+
node: node.callee,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function hasAtLeastOneVariableArgument(args) {
|
|
107
|
+
return args.some(arg => !isLiteral(arg));
|
|
108
|
+
}
|
|
109
|
+
function isLiteral(node) {
|
|
110
|
+
if (node.type === 'Literal') {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
if (node.type === 'TemplateLiteral') {
|
|
114
|
+
return node.expressions.length === 0;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
function isConcatenation(node) {
|
|
119
|
+
return node.type === 'BinaryExpression' && node.operator === '+';
|
|
120
|
+
}
|
|
121
|
+
function isVariableConcat(node) {
|
|
122
|
+
const { left, right } = node;
|
|
123
|
+
if (!isLiteral(right)) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
if (isConcatenation(left)) {
|
|
127
|
+
return isVariableConcat(left);
|
|
128
|
+
}
|
|
129
|
+
return !isLiteral(left);
|
|
130
|
+
}
|
|
131
|
+
function getLeftmostStringValue(node) {
|
|
132
|
+
const { left } = node;
|
|
133
|
+
if (isConcatenation(left)) {
|
|
134
|
+
return getLeftmostStringValue(left);
|
|
135
|
+
}
|
|
136
|
+
if (left.type === 'Literal' && typeof left.value === 'string') {
|
|
137
|
+
return left.value;
|
|
138
|
+
}
|
|
139
|
+
if (left.type === 'TemplateLiteral' && left.expressions.length === 0) {
|
|
140
|
+
return left.quasis[0].value.raw;
|
|
141
|
+
}
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
package/cjs/S1526/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
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
|
+
const location_js_1 = require("../helpers/location.js");
|
|
55
56
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
57
|
exports.rule = {
|
|
57
|
-
meta: (0,
|
|
58
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta),
|
|
58
59
|
create(context) {
|
|
59
60
|
return {
|
|
60
61
|
"VariableDeclaration[kind='var']": (node) => {
|
|
@@ -65,10 +66,10 @@ exports.rule = {
|
|
|
65
66
|
.filter(reference => !reference.init && comesBefore(reference.identifier, declaration))
|
|
66
67
|
.map(reference => reference.identifier);
|
|
67
68
|
if (misused.length > 0) {
|
|
68
|
-
(0,
|
|
69
|
+
(0, location_js_1.report)(context, {
|
|
69
70
|
message: `Move the declaration of "${declaration.name}" before this usage.`,
|
|
70
71
|
node: misused[0],
|
|
71
|
-
}, [(0,
|
|
72
|
+
}, [(0, location_js_1.toSecondaryLocation)(declaration, 'Declaration')]);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
},
|
package/cjs/S1527/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
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
55
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
56
|
const futureReservedWords = new Set([
|
|
57
57
|
'implements',
|
|
@@ -73,7 +73,7 @@ const futureReservedWords = new Set([
|
|
|
73
73
|
'await',
|
|
74
74
|
]);
|
|
75
75
|
exports.rule = {
|
|
76
|
-
meta: (0,
|
|
76
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta, {
|
|
77
77
|
messages: {
|
|
78
78
|
renameReserved: 'Rename "{{reserved}}" identifier to prevent potential conflicts with future evolutions of the JavaScript language.',
|
|
79
79
|
},
|
package/cjs/S1528/rule.js
CHANGED
|
@@ -34,10 +34,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.rule = void 0;
|
|
37
|
-
const
|
|
37
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
38
38
|
const meta = __importStar(require("./generated-meta.js"));
|
|
39
39
|
exports.rule = {
|
|
40
|
-
meta: (0,
|
|
40
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta, {
|
|
41
41
|
hasSuggestions: true,
|
|
42
42
|
}),
|
|
43
43
|
create(context) {
|
|
@@ -39,7 +39,7 @@ exports.meta = {
|
|
|
39
39
|
description: 'Bitwise operators should not be used in boolean contexts',
|
|
40
40
|
recommended: true,
|
|
41
41
|
url: 'https://sonarsource.github.io/rspec/#/rspec/S1529/javascript',
|
|
42
|
-
requiresTypeChecking:
|
|
42
|
+
requiresTypeChecking: true,
|
|
43
43
|
},
|
|
44
44
|
fixable: undefined,
|
|
45
45
|
deprecated: false,
|
package/cjs/S1529/rule.js
CHANGED
|
@@ -55,7 +55,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
55
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
56
|
exports.rule = void 0;
|
|
57
57
|
const typescript_1 = __importDefault(require("typescript"));
|
|
58
|
-
const
|
|
58
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
59
|
+
const type_js_1 = require("../helpers/type.js");
|
|
59
60
|
const meta = __importStar(require("./generated-meta.js"));
|
|
60
61
|
const BITWISE_AND_OR = new Set(['&', '|']);
|
|
61
62
|
const BITWISE_OPERATORS = new Set([
|
|
@@ -74,7 +75,7 @@ const BITWISE_OPERATORS = new Set([
|
|
|
74
75
|
'>>>=',
|
|
75
76
|
]);
|
|
76
77
|
exports.rule = {
|
|
77
|
-
meta: (0,
|
|
78
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta),
|
|
78
79
|
create(context) {
|
|
79
80
|
const isNumeric = getNumericTypeChecker(context);
|
|
80
81
|
let lonelyBitwiseAndOr = null;
|
|
@@ -129,7 +130,7 @@ function insideCondition(node, ancestors) {
|
|
|
129
130
|
function getNumericTypeChecker(context) {
|
|
130
131
|
const services = context.sourceCode.parserServices;
|
|
131
132
|
if (!!services && !!services.program && !!services.esTreeNodeToTSNodeMap) {
|
|
132
|
-
return (node) => isNumericType((0,
|
|
133
|
+
return (node) => isNumericType((0, type_js_1.getTypeFromTreeNode)(node, services));
|
|
133
134
|
}
|
|
134
135
|
else {
|
|
135
136
|
const numericTypes = new Set(['number', 'bigint']);
|
package/cjs/S1530/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
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
|
+
const location_js_1 = require("../helpers/location.js");
|
|
56
|
+
const ancestor_js_1 = require("../helpers/ancestor.js");
|
|
55
57
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
58
|
exports.rule = {
|
|
57
|
-
meta: (0,
|
|
59
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta, {
|
|
58
60
|
messages: {
|
|
59
61
|
blockedFunction: 'Do not use function declarations within blocks.',
|
|
60
62
|
},
|
|
@@ -64,7 +66,7 @@ exports.rule = {
|
|
|
64
66
|
':not(FunctionDeclaration, FunctionExpression, ArrowFunctionExpression) > BlockStatement > FunctionDeclaration': (node) => {
|
|
65
67
|
context.report({
|
|
66
68
|
messageId: 'blockedFunction',
|
|
67
|
-
loc: (0,
|
|
69
|
+
loc: (0, location_js_1.getMainFunctionTokenLocation)(node, (0, ancestor_js_1.getParent)(context, node), context),
|
|
68
70
|
});
|
|
69
71
|
},
|
|
70
72
|
};
|
package/cjs/S1533/rule.js
CHANGED
|
@@ -51,11 +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
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
55
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
56
|
const WRAPPER_TYPES = new Set(['Boolean', 'Number', 'String']);
|
|
57
57
|
exports.rule = {
|
|
58
|
-
meta: (0,
|
|
58
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta, {
|
|
59
59
|
hasSuggestions: true,
|
|
60
60
|
messages: {
|
|
61
61
|
removeConstructor: 'Remove this use of "{{constructor}}" constructor.',
|
package/cjs/S1535/rule.js
CHANGED
|
@@ -51,10 +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
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
55
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
56
|
exports.rule = {
|
|
57
|
-
meta: (0,
|
|
57
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta, {
|
|
58
58
|
messages: {
|
|
59
59
|
restrictLoop: 'Restrict what this loop acts on by testing each property.',
|
|
60
60
|
},
|
package/cjs/S1541/rule.js
CHANGED
|
@@ -51,11 +51,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
51
51
|
})();
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
|
-
const
|
|
54
|
+
const location_js_1 = require("../helpers/location.js");
|
|
55
|
+
const ast_js_1 = require("../helpers/ast.js");
|
|
56
|
+
const ancestor_js_1 = require("../helpers/ancestor.js");
|
|
57
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
58
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
59
|
const DEFAULT_THRESHOLD = 10;
|
|
57
60
|
exports.rule = {
|
|
58
|
-
meta: (0,
|
|
61
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta),
|
|
59
62
|
create(context) {
|
|
60
63
|
const threshold = context.options[0]?.threshold ?? DEFAULT_THRESHOLD;
|
|
61
64
|
let functionsWithParent;
|
|
@@ -75,7 +78,7 @@ exports.rule = {
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
},
|
|
78
|
-
'FunctionDeclaration, FunctionExpression, ArrowFunctionExpression': (node) => functionsWithParent.set(node, (0,
|
|
81
|
+
'FunctionDeclaration, FunctionExpression, ArrowFunctionExpression': (node) => functionsWithParent.set(node, (0, ancestor_js_1.getParent)(context, node)),
|
|
79
82
|
"CallExpression[callee.type='Identifier'][callee.name='define'] FunctionExpression": (node) => functionsDefiningModule.push(node),
|
|
80
83
|
"NewExpression[callee.type='FunctionExpression'], CallExpression[callee.type='FunctionExpression']": (node) => functionsImmediatelyInvoked.push(node.callee),
|
|
81
84
|
};
|
|
@@ -87,7 +90,7 @@ function raiseOnUnauthorizedComplexity(node, parent, threshold, context) {
|
|
|
87
90
|
if (complexity > threshold) {
|
|
88
91
|
context.report({
|
|
89
92
|
message: toEncodedMessage(complexity, threshold, tokens),
|
|
90
|
-
loc: (0,
|
|
93
|
+
loc: (0, location_js_1.getMainFunctionTokenLocation)(node, parent, context),
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
96
|
}
|
|
@@ -124,10 +127,10 @@ class FunctionComplexityVisitor {
|
|
|
124
127
|
const visitNode = (node) => {
|
|
125
128
|
const { sourceCode } = this.context;
|
|
126
129
|
let token;
|
|
127
|
-
if ((0,
|
|
130
|
+
if ((0, ast_js_1.isFunctionNode)(node)) {
|
|
128
131
|
if (node === this.root) {
|
|
129
132
|
token = {
|
|
130
|
-
loc: (0,
|
|
133
|
+
loc: (0, location_js_1.getMainFunctionTokenLocation)(node, this.parent, this.context),
|
|
131
134
|
};
|
|
132
135
|
}
|
|
133
136
|
else {
|
|
@@ -160,7 +163,7 @@ class FunctionComplexityVisitor {
|
|
|
160
163
|
if (token) {
|
|
161
164
|
this.tokens.push(token);
|
|
162
165
|
}
|
|
163
|
-
for (const childNode of (0,
|
|
166
|
+
for (const childNode of (0, ancestor_js_1.childrenOf)(node, sourceCode.visitorKeys)) {
|
|
164
167
|
visitNode(childNode);
|
|
165
168
|
}
|
|
166
169
|
};
|
package/cjs/S1607/rule.js
CHANGED
|
@@ -51,12 +51,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
51
51
|
})();
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.rule = void 0;
|
|
54
|
-
const
|
|
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 dependencies_js_1 = require("../helpers/package-jsons/dependencies.js");
|
|
57
59
|
const all_in_parent_dirs_js_1 = require("../helpers/package-jsons/all-in-parent-dirs.js");
|
|
58
60
|
exports.rule = {
|
|
59
|
-
meta: (0,
|
|
61
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta, {
|
|
60
62
|
messages: {
|
|
61
63
|
removeOrExplainTest: 'Remove this unit test or explain why it is ignored.',
|
|
62
64
|
},
|
|
@@ -136,7 +138,7 @@ exports.rule = {
|
|
|
136
138
|
function nodejsListener() {
|
|
137
139
|
return {
|
|
138
140
|
CallExpression: (node) => {
|
|
139
|
-
const fqn = (0,
|
|
141
|
+
const fqn = (0, module_js_1.getFullyQualifiedName)(context, node.callee);
|
|
140
142
|
if (fqn !== 'test') {
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
@@ -157,12 +159,12 @@ exports.rule = {
|
|
|
157
159
|
* Handle the pattern `test('name', t => { t.skip(); })`.
|
|
158
160
|
*/
|
|
159
161
|
function handleSkipMethod(node) {
|
|
160
|
-
const fn = (0,
|
|
162
|
+
const fn = (0, ast_js_1.resolveFunction)(context, node.arguments[1]);
|
|
161
163
|
if (!fn) {
|
|
162
164
|
return;
|
|
163
165
|
}
|
|
164
166
|
const testCtxParam = fn.params[0];
|
|
165
|
-
if (!testCtxParam || !(0,
|
|
167
|
+
if (!testCtxParam || !(0, ast_js_1.isIdentifier)(testCtxParam)) {
|
|
166
168
|
return;
|
|
167
169
|
}
|
|
168
170
|
const scopeVariables = context.sourceCode.scopeManager.getDeclaredVariables(fn);
|
|
@@ -177,11 +179,11 @@ exports.rule = {
|
|
|
177
179
|
continue;
|
|
178
180
|
}
|
|
179
181
|
const skipCall = maybeSkipCall;
|
|
180
|
-
if (!(0,
|
|
182
|
+
if (!(0, ast_js_1.isMethodInvocation)(skipCall, testCtxIden.name, 'skip', 0)) {
|
|
181
183
|
continue;
|
|
182
184
|
}
|
|
183
185
|
const skipArg = skipCall.arguments[0];
|
|
184
|
-
if (!skipArg || ((0,
|
|
186
|
+
if (!skipArg || ((0, ast_js_1.isLiteral)(skipArg) && skipArg.value === '')) {
|
|
185
187
|
context.report({
|
|
186
188
|
node: skipCall.callee,
|
|
187
189
|
messageId: 'removeOrExplainTest',
|
|
@@ -194,15 +196,15 @@ exports.rule = {
|
|
|
194
196
|
* Handle the pattern `test('name', { skip: true }, () => {})`.
|
|
195
197
|
*/
|
|
196
198
|
function handleSkipOption(node) {
|
|
197
|
-
const options = (0,
|
|
199
|
+
const options = (0, ast_js_1.getValueOfExpression)(context, node.arguments[1], 'ObjectExpression');
|
|
198
200
|
if (!options) {
|
|
199
201
|
return;
|
|
200
202
|
}
|
|
201
|
-
const skipProperty = (0,
|
|
203
|
+
const skipProperty = (0, ast_js_1.getProperty)(options, 'skip', context);
|
|
202
204
|
if (!skipProperty) {
|
|
203
205
|
return;
|
|
204
206
|
}
|
|
205
|
-
const skipValue = (0,
|
|
207
|
+
const skipValue = (0, ast_js_1.getValueOfExpression)(context, skipProperty.value, 'Literal');
|
|
206
208
|
if (!skipValue || (skipValue.value !== true && skipValue.value !== '')) {
|
|
207
209
|
return;
|
|
208
210
|
}
|
|
@@ -229,18 +231,18 @@ exports.rule = {
|
|
|
229
231
|
},
|
|
230
232
|
};
|
|
231
233
|
function isJasmineIgnoredTest(node) {
|
|
232
|
-
return (0,
|
|
234
|
+
return (0, ast_js_1.isIdentifier)(node.callee, 'xit', 'xdescribe', 'xcontext');
|
|
233
235
|
}
|
|
234
236
|
function isJestIgnoredTest(node) {
|
|
235
|
-
return ((0,
|
|
236
|
-
(0,
|
|
237
|
-
(0,
|
|
238
|
-
(0,
|
|
239
|
-
(0,
|
|
240
|
-
(0,
|
|
237
|
+
return ((0, ast_js_1.isMethodInvocation)(node, 'test', 'skip', 0) ||
|
|
238
|
+
(0, ast_js_1.isMethodInvocation)(node, 'it', 'skip', 0) ||
|
|
239
|
+
(0, ast_js_1.isMethodInvocation)(node, 'describe', 'skip', 0) ||
|
|
240
|
+
(0, ast_js_1.isFunctionInvocation)(node, 'xtest', 0) ||
|
|
241
|
+
(0, ast_js_1.isFunctionInvocation)(node, 'xit', 0) ||
|
|
242
|
+
(0, ast_js_1.isFunctionInvocation)(node, 'xdescribe', 0));
|
|
241
243
|
}
|
|
242
244
|
function isMochaIgnoredTest(node) {
|
|
243
|
-
return ((0,
|
|
244
|
-
(0,
|
|
245
|
-
(0,
|
|
245
|
+
return ((0, ast_js_1.isMethodInvocation)(node, 'it', 'skip', 0) ||
|
|
246
|
+
(0, ast_js_1.isMethodInvocation)(node, 'describe', 'skip', 0) ||
|
|
247
|
+
(0, ast_js_1.isMethodInvocation)(node, 'context', 'skip', 0));
|
|
246
248
|
}
|
package/cjs/S1764/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
|
|
54
|
+
const location_js_1 = require("../helpers/location.js");
|
|
55
|
+
const equivalence_js_1 = require("../helpers/equivalence.js");
|
|
56
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
57
|
+
const ast_js_1 = require("../helpers/ast.js");
|
|
55
58
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
59
|
const sonar_runtime_js_1 = require("../helpers/sonar-runtime.js");
|
|
57
60
|
const EQUALITY_OPERATOR_TOKEN_KINDS = new Set(['==', '===', '!=', '!==']);
|
|
@@ -73,16 +76,16 @@ function hasRelevantOperator(node) {
|
|
|
73
76
|
(EQUALITY_OPERATOR_TOKEN_KINDS.has(node.operator) && !hasIdentifierOperands(node)));
|
|
74
77
|
}
|
|
75
78
|
function hasIdentifierOperands(node) {
|
|
76
|
-
return (0,
|
|
79
|
+
return (0, ast_js_1.isIdentifier)(node.left) && (0, ast_js_1.isIdentifier)(node.right);
|
|
77
80
|
}
|
|
78
81
|
function isOneOntoOneShifting(node) {
|
|
79
82
|
return (node.operator === '<<' &&
|
|
80
|
-
(0,
|
|
83
|
+
(0, ast_js_1.isLiteral)(node.left) &&
|
|
81
84
|
(node.left.value === 1 || node.left.value === 1n));
|
|
82
85
|
}
|
|
83
86
|
const message = 'Correct one of the identical sub-expressions on both sides of operator "{{operator}}"';
|
|
84
87
|
exports.rule = {
|
|
85
|
-
meta: (0,
|
|
88
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta, {
|
|
86
89
|
messages: {
|
|
87
90
|
correctIdenticalSubExpressions: message,
|
|
88
91
|
},
|
|
@@ -99,12 +102,12 @@ exports.rule = {
|
|
|
99
102
|
function check(expr) {
|
|
100
103
|
if (hasRelevantOperator(expr) &&
|
|
101
104
|
!isOneOntoOneShifting(expr) &&
|
|
102
|
-
(0,
|
|
105
|
+
(0, equivalence_js_1.areEquivalent)(expr.left, expr.right, context.sourceCode)) {
|
|
103
106
|
const secondaryLocations = [];
|
|
104
107
|
if (expr.left.loc) {
|
|
105
|
-
secondaryLocations.push((0,
|
|
108
|
+
secondaryLocations.push((0, location_js_1.toSecondaryLocation)(expr.left));
|
|
106
109
|
}
|
|
107
|
-
(0,
|
|
110
|
+
(0, location_js_1.report)(context, {
|
|
108
111
|
message,
|
|
109
112
|
messageId: 'correctIdenticalSubExpressions',
|
|
110
113
|
data: {
|
package/cjs/S1821/rule.js
CHANGED
|
@@ -51,10 +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
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
55
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
56
|
exports.rule = {
|
|
57
|
-
meta: (0,
|
|
57
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta, {
|
|
58
58
|
messages: {
|
|
59
59
|
removeNestedSwitch: 'Refactor the code to eliminate this nested "switch".',
|
|
60
60
|
},
|
package/cjs/S1848/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
|
|
54
|
+
const generate_meta_js_1 = require("../helpers/generate-meta.js");
|
|
55
|
+
const module_js_1 = require("../helpers/module.js");
|
|
56
|
+
const reaching_definitions_js_1 = require("../helpers/reaching-definitions.js");
|
|
57
|
+
const ast_js_1 = require("../helpers/ast.js");
|
|
55
58
|
const meta = __importStar(require("./generated-meta.js"));
|
|
56
59
|
/** DOM selection method names commonly used for element selection */
|
|
57
60
|
const DOM_SELECTION_METHODS = [
|
|
@@ -65,7 +68,7 @@ const DOM_SELECTION_METHODS = [
|
|
|
65
68
|
/** jQuery/$ function names */
|
|
66
69
|
const JQUERY_IDENTIFIERS = ['$', 'jQuery'];
|
|
67
70
|
exports.rule = {
|
|
68
|
-
meta: (0,
|
|
71
|
+
meta: (0, generate_meta_js_1.generateMeta)(meta, {
|
|
69
72
|
messages: {
|
|
70
73
|
removeInstantiationOf: 'Either remove this useless object instantiation of "{{constructor}}" or use it.',
|
|
71
74
|
removeInstantiation: 'Either remove this useless object instantiation or use it.',
|
|
@@ -130,7 +133,7 @@ function isException(context, node, name) {
|
|
|
130
133
|
if (name === 'Notification') {
|
|
131
134
|
return true;
|
|
132
135
|
}
|
|
133
|
-
const fqn = (0,
|
|
136
|
+
const fqn = (0, module_js_1.getFullyQualifiedName)(context, node);
|
|
134
137
|
if (!fqn) {
|
|
135
138
|
return false;
|
|
136
139
|
}
|
|
@@ -185,7 +188,7 @@ function containsDomSelection(node, scope) {
|
|
|
185
188
|
* Checks if a variable was initialized from a DOM selection call.
|
|
186
189
|
*/
|
|
187
190
|
function isVariableFromDomSelection(node, scope) {
|
|
188
|
-
const variable = (0,
|
|
191
|
+
const variable = (0, reaching_definitions_js_1.getVariableFromIdentifier)(node, scope);
|
|
189
192
|
if (!variable) {
|
|
190
193
|
return false;
|
|
191
194
|
}
|
|
@@ -222,19 +225,19 @@ function unwrapTypeAssertion(node) {
|
|
|
222
225
|
function isDomSelectionCall(node) {
|
|
223
226
|
const { callee } = node;
|
|
224
227
|
// Check for $() or jQuery()
|
|
225
|
-
if ((0,
|
|
228
|
+
if ((0, ast_js_1.isIdentifier)(callee, ...JQUERY_IDENTIFIERS)) {
|
|
226
229
|
return true;
|
|
227
230
|
}
|
|
228
231
|
// Check for *.querySelector, *.getElementById, etc. on any object
|
|
229
232
|
// This covers document.querySelector, myDocument.querySelector, this.document.querySelector, etc.
|
|
230
233
|
if (callee.type === 'MemberExpression' &&
|
|
231
|
-
(0,
|
|
234
|
+
(0, ast_js_1.isIdentifier)(callee.property, ...DOM_SELECTION_METHODS)) {
|
|
232
235
|
return true;
|
|
233
236
|
}
|
|
234
237
|
// Check for this.$() - common in Backbone/Marionette views
|
|
235
238
|
if (callee.type === 'MemberExpression' &&
|
|
236
239
|
callee.object.type === 'ThisExpression' &&
|
|
237
|
-
(0,
|
|
240
|
+
(0, ast_js_1.isIdentifier)(callee.property, ...JQUERY_IDENTIFIERS)) {
|
|
238
241
|
return true;
|
|
239
242
|
}
|
|
240
243
|
return false;
|