@nitra/cursor 1.11.4 → 1.11.7

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 (66) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/bin/n-cursor.js +37 -4
  3. package/package.json +2 -1
  4. package/rules/abie/utils/http-route.mjs +1 -1
  5. package/rules/abie/utils/k8s-tree.mjs +9 -10
  6. package/rules/abie/utils/overlay-paths.mjs +1 -1
  7. package/rules/adr/adr.mdc +2 -2
  8. package/rules/adr/js/hooks/check.mjs +5 -5
  9. package/rules/docker/docker.mdc +2 -2
  10. package/rules/docker/js/run.mjs +3 -2
  11. package/rules/docker/policy/package_json/package_json.rego +1 -1
  12. package/rules/ga/js/lint.mjs +3 -26
  13. package/rules/k8s/js/run.mjs +3 -2
  14. package/rules/k8s/k8s.mdc +2 -4
  15. package/rules/npm-module/js/package_structure/check.mjs +2 -2
  16. package/rules/npm-module/npm-module.mdc +3 -3
  17. package/rules/rego/js/lint.mjs +4 -1
  18. package/rules/rego/policy/package_json/package_json.rego +5 -3
  19. package/rules/rego/rego.mdc +3 -3
  20. package/rules/style-lint/js/tooling/check.mjs +1 -1
  21. package/rules/style-lint/style-lint.mdc +1 -1
  22. package/rules/text/js/formatting/check.mjs +8 -24
  23. package/rules/text/js/lint.mjs +34 -0
  24. package/rules/text/js/run-shellcheck.mjs +2 -2
  25. package/rules/text/js/run-v8r.mjs +2 -2
  26. package/rules/text/text.mdc +5 -5
  27. package/schemas/v8r-catalog.json +6 -0
  28. package/scripts/auto-skills.mjs +1 -3
  29. package/scripts/utils/resolve-target-files.mjs +1 -1
  30. package/scripts/utils/run-lint-step.mjs +33 -0
  31. package/scripts/utils/run-rule.mjs +2 -1
  32. package/skills/abie-clean/SKILL.md +9 -5
  33. package/skills/fix/SKILL.md +6 -14
  34. package/rules/abie/policy/base_deployment_preem/base_deployment_preem_test.rego +0 -60
  35. package/rules/abie/policy/clean_merged_ignore_branches/clean_merged_ignore_branches_test.rego +0 -48
  36. package/rules/abie/policy/health_check_policy/health_check_policy_test.rego +0 -99
  37. package/rules/abie/policy/http_route_base/http_route_base_test.rego +0 -64
  38. package/rules/bun/policy/package_json/package_json_test.rego +0 -109
  39. package/rules/docker/policy/lint_docker_yml/lint_docker_yml_test.rego +0 -104
  40. package/rules/docker/policy/package_json/package_json_test.rego +0 -42
  41. package/rules/graphql/policy/vscode_extensions/vscode_extensions_test.rego +0 -34
  42. package/rules/image-avif/policy/package_json/package_json_test.rego +0 -69
  43. package/rules/js-lint/policy/package_json/package_json_test.rego +0 -130
  44. package/rules/js-run/policy/jsconfig/jsconfig_test.rego +0 -88
  45. package/rules/k8s/policy/base_kustomization/base_kustomization_test.rego +0 -73
  46. package/rules/k8s/policy/base_manifest/base_manifest_test.rego +0 -94
  47. package/rules/k8s/policy/gateway/gateway_test.rego +0 -122
  48. package/rules/k8s/policy/hasura_configmap/hasura_configmap_test.rego +0 -49
  49. package/rules/k8s/policy/hasura_httproute/hasura_httproute_test.rego +0 -148
  50. package/rules/k8s/policy/hpa_pdb/hpa_pdb_test.rego +0 -101
  51. package/rules/k8s/policy/kustomization/kustomization_test.rego +0 -128
  52. package/rules/k8s/policy/manifest/manifest_test.rego +0 -309
  53. package/rules/k8s/policy/svc_hl_yaml/svc_hl_yaml_test.rego +0 -42
  54. package/rules/k8s/policy/svc_yaml/svc_yaml_test.rego +0 -41
  55. package/rules/nginx-default-tpl/policy/vscode_extensions/vscode_extensions_test.rego +0 -30
  56. package/rules/nginx-default-tpl/policy/vscode_settings/vscode_settings_test.rego +0 -53
  57. package/rules/npm-module/policy/npm_package_json/npm_package_json_test.rego +0 -81
  58. package/rules/rego/policy/package_json/package_json_test.rego +0 -42
  59. package/rules/rego/policy/vscode_extensions/vscode_extensions_test.rego +0 -34
  60. package/rules/rego/policy/vscode_settings/vscode_settings_test.rego +0 -55
  61. package/rules/style-lint/policy/vscode_extensions/vscode_extensions_test.rego +0 -39
  62. package/rules/style-lint/policy/vscode_settings/vscode_settings_test.rego +0 -49
  63. package/rules/tauri/policy/vscode_extensions/vscode_extensions_test.rego +0 -44
  64. package/rules/text/policy/markdownlint/markdownlint_test.rego +0 -98
  65. package/rules/text/policy/vscode_extensions/vscode_extensions_test.rego +0 -51
  66. package/rules/text/policy/vscode_settings/vscode_settings_test.rego +0 -85
@@ -1,309 +0,0 @@
1
- # Тести для `k8s.manifest`. Запуск:
2
- # conftest verify -p npm/policy/k8s/manifest --namespace k8s.manifest
3
- #
4
- # Покриваємо deny-правила: Ingress, autoscaling/v1, Service GCP-анотації,
5
- # Deployment cpu/memory/image (Hasura), topologySpreadConstraints. Тести
6
- # перевіряють як спрацювання правила (count(deny) > 0), так і його відсутність
7
- # для коректного маніфесту.
8
- package k8s.manifest_test
9
-
10
- import rego.v1
11
-
12
- import data.k8s.manifest
13
-
14
- # ── Ingress / autoscaling/v1 ──────────────────────────────────────────────
15
-
16
- test_deny_ingress if {
17
- count(manifest.deny) > 0 with input as {
18
- "apiVersion": "networking.k8s.io/v1",
19
- "kind": "Ingress",
20
- "metadata": {"name": "x"},
21
- }
22
- }
23
-
24
- test_deny_autoscaling_v1 if {
25
- count(manifest.deny) > 0 with input as {
26
- "apiVersion": "autoscaling/v1",
27
- "kind": "HorizontalPodAutoscaler",
28
- "metadata": {"name": "x"},
29
- }
30
- }
31
-
32
- test_allow_autoscaling_v2 if {
33
- count(manifest.deny) == 0 with input as {
34
- "apiVersion": "autoscaling/v2",
35
- "kind": "HorizontalPodAutoscaler",
36
- "metadata": {"name": "x"},
37
- }
38
- }
39
-
40
- # ── Service: GCP-анотації ─────────────────────────────────────────────────
41
-
42
- test_deny_service_neg_annotation if {
43
- count(manifest.deny) > 0 with input as {
44
- "apiVersion": "v1",
45
- "kind": "Service",
46
- "metadata": {
47
- "name": "api",
48
- "annotations": {"cloud.google.com/neg": "{}"},
49
- },
50
- }
51
- }
52
-
53
- test_deny_service_backend_config_annotation if {
54
- count(manifest.deny) > 0 with input as {
55
- "apiVersion": "v1",
56
- "kind": "Service",
57
- "metadata": {
58
- "name": "api",
59
- "annotations": {"cloud.google.com/backend-config": "{}"},
60
- },
61
- }
62
- }
63
-
64
- test_allow_service_clean_annotations if {
65
- count(manifest.deny) == 0 with input as {
66
- "apiVersion": "v1",
67
- "kind": "Service",
68
- "metadata": {
69
- "name": "api",
70
- "namespace": "dev",
71
- "annotations": {"foo": "bar"},
72
- },
73
- "spec": {"type": "ClusterIP"},
74
- }
75
- }
76
-
77
- # ── Deployment: resources.requests.cpu ────────────────────────────────────
78
-
79
- test_deny_deployment_missing_cpu if {
80
- count(manifest.deny) > 0 with input as {
81
- "apiVersion": "apps/v1",
82
- "kind": "Deployment",
83
- "metadata": {"name": "api", "namespace": "dev"},
84
- "spec": {
85
- "selector": {"matchLabels": {"app": "api"}},
86
- "template": {"spec": {"containers": [{
87
- "name": "main",
88
- "image": "registry.example.com/api:1.0",
89
- "resources": {"requests": {"memory": "64Mi"}},
90
- }]}},
91
- },
92
- }
93
- }
94
-
95
- test_deny_deployment_empty_cpu if {
96
- count(manifest.deny) > 0 with input as {
97
- "apiVersion": "apps/v1",
98
- "kind": "Deployment",
99
- "metadata": {"name": "api", "namespace": "dev"},
100
- "spec": {
101
- "selector": {"matchLabels": {"app": "api"}},
102
- "template": {"spec": {"containers": [{
103
- "name": "main",
104
- "image": "registry.example.com/api:1.0",
105
- "resources": {"requests": {"cpu": "", "memory": "64Mi"}},
106
- }]}},
107
- },
108
- }
109
- }
110
-
111
- # ── Deployment: resources.requests.memory ─────────────────────────────────
112
-
113
- test_deny_deployment_missing_memory if {
114
- count(manifest.deny) > 0 with input as {
115
- "apiVersion": "apps/v1",
116
- "kind": "Deployment",
117
- "metadata": {"name": "api", "namespace": "dev"},
118
- "spec": {
119
- "selector": {"matchLabels": {"app": "api"}},
120
- "template": {"spec": {"containers": [{
121
- "name": "main",
122
- "image": "registry.example.com/api:1.0",
123
- "resources": {"requests": {"cpu": "100m"}},
124
- }]}},
125
- },
126
- }
127
- }
128
-
129
- test_deny_deployment_empty_memory if {
130
- count(manifest.deny) > 0 with input as {
131
- "apiVersion": "apps/v1",
132
- "kind": "Deployment",
133
- "metadata": {"name": "api", "namespace": "dev"},
134
- "spec": {
135
- "selector": {"matchLabels": {"app": "api"}},
136
- "template": {"spec": {"containers": [{
137
- "name": "main",
138
- "image": "registry.example.com/api:1.0",
139
- "resources": {"requests": {"cpu": "100m", "memory": ""}},
140
- }]}},
141
- },
142
- }
143
- }
144
-
145
- test_deny_init_container_missing_resources if {
146
- count(manifest.deny) > 0 with input as {
147
- "apiVersion": "apps/v1",
148
- "kind": "Deployment",
149
- "metadata": {"name": "api", "namespace": "dev"},
150
- "spec": {
151
- "selector": {"matchLabels": {"app": "api"}},
152
- "template": {"spec": {
153
- "containers": [{
154
- "name": "main",
155
- "image": "registry.example.com/api:1.0",
156
- "resources": {"requests": {"cpu": "100m", "memory": "64Mi"}},
157
- }],
158
- "initContainers": [{"name": "wait", "image": "busybox:1"}],
159
- }},
160
- },
161
- }
162
- }
163
-
164
- # ── Deployment: образ hasura/graphql-engine ──────────────────────────────
165
-
166
- test_deny_deployment_hasura_unpinned_image if {
167
- count(manifest.deny) > 0 with input as {
168
- "apiVersion": "apps/v1",
169
- "kind": "Deployment",
170
- "metadata": {"name": "db-h", "namespace": "dev"},
171
- "spec": {
172
- "selector": {"matchLabels": {"app": "db-h"}},
173
- "template": {"spec": {"containers": [{
174
- "name": "graphql-engine",
175
- "image": "hasura/graphql-engine:latest",
176
- "resources": {"requests": {"cpu": "100m", "memory": "64Mi"}},
177
- }]}},
178
- },
179
- }
180
- }
181
-
182
- test_allow_deployment_hasura_canonical_image if {
183
- count(manifest.deny) == 0 with input as {
184
- "apiVersion": "apps/v1",
185
- "kind": "Deployment",
186
- "metadata": {"name": "db-h", "namespace": "dev"},
187
- "spec": {
188
- "selector": {"matchLabels": {"app": "db-h"}},
189
- "template": {"spec": {
190
- "containers": [{
191
- "name": "graphql-engine",
192
- "image": "hasura/graphql-engine:v2.48.15.ubi.amd64",
193
- "resources": {"requests": {"cpu": "100m", "memory": "64Mi"}},
194
- }],
195
- "topologySpreadConstraints": [{
196
- "maxSkew": 1,
197
- "topologyKey": "kubernetes.io/hostname",
198
- "whenUnsatisfiable": "ScheduleAnyway",
199
- "labelSelector": {"matchLabels": {"app": "db-h"}},
200
- }],
201
- }},
202
- },
203
- }
204
- }
205
-
206
- test_allow_deployment_hasura_canonical_image_with_digest if {
207
- count(manifest.deny) == 0 with input as {
208
- "apiVersion": "apps/v1",
209
- "kind": "Deployment",
210
- "metadata": {"name": "db-h", "namespace": "dev"},
211
- "spec": {
212
- "selector": {"matchLabels": {"app": "db-h"}},
213
- "template": {"spec": {
214
- "containers": [{
215
- "name": "graphql-engine",
216
- "image": "docker.io/hasura/graphql-engine:v2.48.15.ubi.amd64@sha256:0000",
217
- "resources": {"requests": {"cpu": "100m", "memory": "64Mi"}},
218
- }],
219
- "topologySpreadConstraints": [{
220
- "maxSkew": 1,
221
- "topologyKey": "kubernetes.io/hostname",
222
- "whenUnsatisfiable": "ScheduleAnyway",
223
- "labelSelector": {"matchLabels": {"app": "db-h"}},
224
- }],
225
- }},
226
- },
227
- }
228
- }
229
-
230
- # ── Deployment: topologySpreadConstraints ────────────────────────────────
231
-
232
- test_deny_deployment_missing_topology_spread if {
233
- count(manifest.deny) > 0 with input as {
234
- "apiVersion": "apps/v1",
235
- "kind": "Deployment",
236
- "metadata": {"name": "api", "namespace": "dev"},
237
- "spec": {
238
- "selector": {"matchLabels": {"app": "api"}},
239
- "template": {"spec": {"containers": [{
240
- "name": "main",
241
- "image": "registry.example.com/api:1.0",
242
- "resources": {"requests": {"cpu": "100m", "memory": "64Mi"}},
243
- }]}},
244
- },
245
- }
246
- }
247
-
248
- test_deny_deployment_topology_spread_wrong_app_label if {
249
- count(manifest.deny) > 0 with input as {
250
- "apiVersion": "apps/v1",
251
- "kind": "Deployment",
252
- "metadata": {"name": "api", "namespace": "dev"},
253
- "spec": {
254
- "selector": {"matchLabels": {"app": "api"}},
255
- "template": {"spec": {
256
- "containers": [{
257
- "name": "main",
258
- "image": "registry.example.com/api:1.0",
259
- "resources": {"requests": {"cpu": "100m", "memory": "64Mi"}},
260
- }],
261
- "topologySpreadConstraints": [{
262
- "maxSkew": 1,
263
- "topologyKey": "kubernetes.io/hostname",
264
- "whenUnsatisfiable": "ScheduleAnyway",
265
- "labelSelector": {"matchLabels": {"app": "wrong"}},
266
- }],
267
- }},
268
- },
269
- }
270
- }
271
-
272
- test_allow_deployment_canonical_topology_spread if {
273
- count(manifest.deny) == 0 with input as {
274
- "apiVersion": "apps/v1",
275
- "kind": "Deployment",
276
- "metadata": {"name": "api", "namespace": "dev"},
277
- "spec": {
278
- "selector": {"matchLabels": {"app": "api"}},
279
- "template": {"spec": {
280
- "containers": [{
281
- "name": "main",
282
- "image": "registry.example.com/api:1.0",
283
- "resources": {"requests": {"cpu": "100m", "memory": "64Mi"}},
284
- }],
285
- "topologySpreadConstraints": [{
286
- "maxSkew": 1,
287
- "topologyKey": "kubernetes.io/hostname",
288
- "whenUnsatisfiable": "ScheduleAnyway",
289
- "labelSelector": {"matchLabels": {"app": "api"}},
290
- }],
291
- }},
292
- },
293
- }
294
- }
295
-
296
- # Без app-мітки топологічна перевірка не запускається — JS-парність
297
- # (k8sEnvSegmentFromRelPath без appLabel skipує перевірку).
298
- test_allow_deployment_without_app_label_skips_topology if {
299
- count(manifest.deny) == 0 with input as {
300
- "apiVersion": "apps/v1",
301
- "kind": "Deployment",
302
- "metadata": {"name": "api", "namespace": "dev"},
303
- "spec": {"template": {"spec": {"containers": [{
304
- "name": "main",
305
- "image": "registry.example.com/api:1.0",
306
- "resources": {"requests": {"cpu": "100m", "memory": "64Mi"}},
307
- }]}}},
308
- }
309
- }
@@ -1,42 +0,0 @@
1
- # Тести для `k8s.svc_hl_yaml`. Запуск:
2
- # conftest verify -p npm/policy/k8s/svc_hl_yaml --namespace k8s.svc_hl_yaml
3
- package k8s.svc_hl_yaml_test
4
-
5
- import rego.v1
6
-
7
- import data.k8s.svc_hl_yaml
8
-
9
- test_deny_service_name_without_hl if {
10
- count(svc_hl_yaml.deny) > 0 with input as {
11
- "apiVersion": "v1",
12
- "kind": "Service",
13
- "metadata": {"name": "api"},
14
- "spec": {"clusterIP": "None"},
15
- }
16
- }
17
-
18
- test_deny_service_clusterip_not_none if {
19
- count(svc_hl_yaml.deny) > 0 with input as {
20
- "apiVersion": "v1",
21
- "kind": "Service",
22
- "metadata": {"name": "api-hl"},
23
- "spec": {"clusterIP": "1.2.3.4"},
24
- }
25
- }
26
-
27
- test_allow_headless_service if {
28
- count(svc_hl_yaml.deny) == 0 with input as {
29
- "apiVersion": "v1",
30
- "kind": "Service",
31
- "metadata": {"name": "api-hl"},
32
- "spec": {"clusterIP": "None"},
33
- }
34
- }
35
-
36
- test_allow_non_service if {
37
- count(svc_hl_yaml.deny) == 0 with input as {
38
- "apiVersion": "apps/v1",
39
- "kind": "Deployment",
40
- "metadata": {"name": "api"},
41
- }
42
- }
@@ -1,41 +0,0 @@
1
- # Тести для `k8s.svc_yaml`. Запуск:
2
- # conftest verify -p npm/policy/k8s/svc_yaml --namespace k8s.svc_yaml
3
- package k8s.svc_yaml_test
4
-
5
- import rego.v1
6
-
7
- import data.k8s.svc_yaml
8
-
9
- test_deny_service_missing_spec if {
10
- count(svc_yaml.deny) > 0 with input as {
11
- "apiVersion": "v1",
12
- "kind": "Service",
13
- "metadata": {"name": "api"},
14
- }
15
- }
16
-
17
- test_deny_service_wrong_type if {
18
- count(svc_yaml.deny) > 0 with input as {
19
- "apiVersion": "v1",
20
- "kind": "Service",
21
- "metadata": {"name": "api"},
22
- "spec": {"type": "LoadBalancer"},
23
- }
24
- }
25
-
26
- test_allow_service_clusterip if {
27
- count(svc_yaml.deny) == 0 with input as {
28
- "apiVersion": "v1",
29
- "kind": "Service",
30
- "metadata": {"name": "api"},
31
- "spec": {"type": "ClusterIP"},
32
- }
33
- }
34
-
35
- test_allow_non_service if {
36
- count(svc_yaml.deny) == 0 with input as {
37
- "apiVersion": "apps/v1",
38
- "kind": "Deployment",
39
- "metadata": {"name": "api"},
40
- }
41
- }
@@ -1,30 +0,0 @@
1
- # Тести для `nginx_default_tpl.vscode_extensions`. Запуск:
2
- # conftest verify -p npm/policy/nginx_default_tpl/vscode_extensions
3
- package nginx_default_tpl.vscode_extensions_test
4
-
5
- import rego.v1
6
-
7
- import data.nginx_default_tpl.vscode_extensions
8
-
9
- test_allow_with_required_extension if {
10
- cfg := {"recommendations": ["ahmadalli.vscode-nginx-conf"]}
11
- count(vscode_extensions.deny) == 0 with input as cfg
12
- }
13
-
14
- test_allow_with_additional_extensions if {
15
- cfg := {"recommendations": ["dbaeumer.vscode-eslint", "ahmadalli.vscode-nginx-conf"]}
16
- count(vscode_extensions.deny) == 0 with input as cfg
17
- }
18
-
19
- test_deny_missing_extension if {
20
- cfg := {"recommendations": ["dbaeumer.vscode-eslint"]}
21
- count(vscode_extensions.deny) > 0 with input as cfg
22
- }
23
-
24
- test_deny_empty_recommendations if {
25
- count(vscode_extensions.deny) > 0 with input as {"recommendations": []}
26
- }
27
-
28
- test_deny_no_recommendations_field if {
29
- count(vscode_extensions.deny) > 0 with input as {}
30
- }
@@ -1,53 +0,0 @@
1
- # Тести для `nginx_default_tpl.vscode_settings`. Запуск:
2
- # conftest verify -p npm/policy/nginx_default_tpl/vscode_settings
3
- package nginx_default_tpl.vscode_settings_test
4
-
5
- import rego.v1
6
-
7
- import data.nginx_default_tpl.vscode_settings
8
-
9
- valid_cfg := {
10
- "editor.formatOnSave": true,
11
- "[nginx]": {"editor.defaultFormatter": "ahmadalli.vscode-nginx-conf"},
12
- }
13
-
14
- test_allow_canonical if {
15
- count(vscode_settings.deny) == 0 with input as valid_cfg
16
- }
17
-
18
- test_allow_with_additional_keys if {
19
- cfg := json.patch(valid_cfg, [{
20
- "op": "add",
21
- "path": "/[javascript]",
22
- "value": {"editor.defaultFormatter": "oxc.oxc-vscode"},
23
- }])
24
- count(vscode_settings.deny) == 0 with input as cfg
25
- }
26
-
27
- test_deny_format_on_save_false if {
28
- cfg := json.patch(valid_cfg, [{"op": "replace", "path": "/editor.formatOnSave", "value": false}])
29
- count(vscode_settings.deny) > 0 with input as cfg
30
- }
31
-
32
- test_deny_format_on_save_missing if {
33
- cfg := json.patch(valid_cfg, [{"op": "remove", "path": "/editor.formatOnSave"}])
34
- count(vscode_settings.deny) > 0 with input as cfg
35
- }
36
-
37
- test_deny_nginx_block_missing if {
38
- cfg := json.patch(valid_cfg, [{"op": "remove", "path": "/[nginx]"}])
39
- count(vscode_settings.deny) > 0 with input as cfg
40
- }
41
-
42
- test_deny_nginx_block_wrong_type if {
43
- cfg := json.patch(valid_cfg, [{"op": "replace", "path": "/[nginx]", "value": "ahmadalli.vscode-nginx-conf"}])
44
- count(vscode_settings.deny) > 0 with input as cfg
45
- }
46
-
47
- test_deny_nginx_wrong_formatter if {
48
- cfg := json.patch(
49
- valid_cfg,
50
- [{"op": "replace", "path": "/[nginx]/editor.defaultFormatter", "value": "ms-vscode.cpptools"}],
51
- )
52
- count(vscode_settings.deny) > 0 with input as cfg
53
- }
@@ -1,81 +0,0 @@
1
- # Тести для `npm_module.npm_package_json`. Запуск:
2
- # conftest verify -p npm/policy/npm_module/npm_package_json
3
- package npm_module.npm_package_json_test
4
-
5
- import rego.v1
6
-
7
- import data.npm_module.npm_package_json
8
-
9
- valid_pkg := {
10
- "name": "@nitra/cursor",
11
- "version": "1.9.5",
12
- "types": "./types/bin/n-cursor.d.ts",
13
- "files": [
14
- "types",
15
- "mdc",
16
- "bin",
17
- "CHANGELOG.md",
18
- ],
19
- "dependencies": {"oxc-parser": "^0.128.0"},
20
- }
21
-
22
- # ── happy path ────────────────────────────────────────────────────────────
23
-
24
- test_allow_canonical if {
25
- count(npm_package_json.deny) == 0 with input as valid_pkg
26
- }
27
-
28
- test_allow_types_index_d_ts if {
29
- pkg := json.patch(valid_pkg, [{"op": "replace", "path": "/types", "value": "./types/index.d.ts"}])
30
- count(npm_package_json.deny) == 0 with input as pkg
31
- }
32
-
33
- # ── types ─────────────────────────────────────────────────────────────────
34
-
35
- test_deny_types_outside_types_dir if {
36
- pkg := json.patch(valid_pkg, [{"op": "replace", "path": "/types", "value": "./dist/index.d.ts"}])
37
- count(npm_package_json.deny) > 0 with input as pkg
38
- }
39
-
40
- test_deny_types_wrong_extension if {
41
- pkg := json.patch(valid_pkg, [{"op": "replace", "path": "/types", "value": "./types/index.ts"}])
42
- count(npm_package_json.deny) > 0 with input as pkg
43
- }
44
-
45
- # ── files ─────────────────────────────────────────────────────────────────
46
-
47
- test_deny_missing_files if {
48
- pkg := json.patch(valid_pkg, [{"op": "remove", "path": "/files"}])
49
- count(npm_package_json.deny) > 0 with input as pkg
50
- }
51
-
52
- test_deny_files_not_array if {
53
- pkg := json.patch(valid_pkg, [{"op": "replace", "path": "/files", "value": "types"}])
54
- count(npm_package_json.deny) > 0 with input as pkg
55
- }
56
-
57
- test_deny_files_empty if {
58
- pkg := json.patch(valid_pkg, [{"op": "replace", "path": "/files", "value": []}])
59
- count(npm_package_json.deny) > 0 with input as pkg
60
- }
61
-
62
- test_deny_files_without_types if {
63
- pkg := json.patch(valid_pkg, [{"op": "replace", "path": "/files", "value": ["bin", "mdc"]}])
64
- count(npm_package_json.deny) > 0 with input as pkg
65
- }
66
-
67
- # ── devDependencies ──────────────────────────────────────────────────────
68
-
69
- test_allow_no_dev_dependencies if {
70
- count(npm_package_json.deny) == 0 with input as valid_pkg
71
- }
72
-
73
- test_allow_empty_dev_dependencies if {
74
- pkg := json.patch(valid_pkg, [{"op": "add", "path": "/devDependencies", "value": {}}])
75
- count(npm_package_json.deny) == 0 with input as pkg
76
- }
77
-
78
- test_deny_dev_dependencies_present if {
79
- pkg := json.patch(valid_pkg, [{"op": "add", "path": "/devDependencies", "value": {"@nitra/cursor": "^1.9.5"}}])
80
- count(npm_package_json.deny) > 0 with input as pkg
81
- }
@@ -1,42 +0,0 @@
1
- # Тести для `rego.package_json`. Запуск:
2
- # conftest verify -p npm/policy/rego/package_json
3
- package rego.package_json_test
4
-
5
- import rego.v1
6
-
7
- import data.rego.package_json
8
-
9
- canonical_lint_rego := "bun ./npm/scripts/lint-rego.mjs"
10
-
11
- test_allow_canonical if {
12
- pkg := {"scripts": {"lint-rego": canonical_lint_rego}}
13
- count(package_json.deny) == 0 with input as pkg
14
- }
15
-
16
- test_allow_with_other_scripts if {
17
- pkg := {"scripts": {"lint-rego": canonical_lint_rego, "test": "bun test"}}
18
- count(package_json.deny) == 0 with input as pkg
19
- }
20
-
21
- test_allow_with_whitespace if {
22
- pkg := {"scripts": {"lint-rego": concat("", [" ", canonical_lint_rego, " "])}}
23
- count(package_json.deny) == 0 with input as pkg
24
- }
25
-
26
- test_deny_missing_lint_rego if {
27
- count(package_json.deny) > 0 with input as {"scripts": {}}
28
- }
29
-
30
- test_deny_no_scripts if {
31
- count(package_json.deny) > 0 with input as {"name": "x"}
32
- }
33
-
34
- test_deny_wrong_value if {
35
- pkg := {"scripts": {"lint-rego": "opa check ."}}
36
- count(package_json.deny) > 0 with input as pkg
37
- }
38
-
39
- test_deny_npx_form if {
40
- pkg := {"scripts": {"lint-rego": "npx opa check ."}}
41
- count(package_json.deny) > 0 with input as pkg
42
- }
@@ -1,34 +0,0 @@
1
- # Тести для `rego.vscode_extensions`. Запуск:
2
- # conftest verify -p npm/policy/rego/vscode_extensions
3
- package rego.vscode_extensions_test
4
-
5
- import rego.v1
6
-
7
- import data.rego.vscode_extensions
8
-
9
- test_allow_with_required_extension if {
10
- cfg := {"recommendations": ["tsandall.opa"]}
11
- count(vscode_extensions.deny) == 0 with input as cfg
12
- }
13
-
14
- test_allow_with_additional_extensions if {
15
- cfg := {"recommendations": [
16
- "dbaeumer.vscode-eslint",
17
- "tsandall.opa",
18
- "oxc.oxc-vscode",
19
- ]}
20
- count(vscode_extensions.deny) == 0 with input as cfg
21
- }
22
-
23
- test_deny_missing_extension if {
24
- cfg := {"recommendations": ["dbaeumer.vscode-eslint"]}
25
- count(vscode_extensions.deny) > 0 with input as cfg
26
- }
27
-
28
- test_deny_empty_recommendations if {
29
- count(vscode_extensions.deny) > 0 with input as {"recommendations": []}
30
- }
31
-
32
- test_deny_no_recommendations_field if {
33
- count(vscode_extensions.deny) > 0 with input as {}
34
- }