@synapsestudios/lintofu 0.0.0-stage → 0.9.1
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/LICENSE +661 -0
- package/README.md +151 -2
- package/dist/configs/category-recommended.d.ts +3 -0
- package/dist/configs/category-recommended.d.ts.map +1 -0
- package/dist/configs/category-recommended.js +12 -0
- package/dist/configs/category-recommended.js.map +1 -0
- package/dist/configs/recommended.d.ts +3 -0
- package/dist/configs/recommended.d.ts.map +1 -0
- package/dist/configs/recommended.js +12 -0
- package/dist/configs/recommended.js.map +1 -0
- package/dist/index.d.ts +198 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/language.d.ts +34 -0
- package/dist/language.d.ts.map +1 -0
- package/dist/language.js +72 -0
- package/dist/language.js.map +1 -0
- package/dist/parser/index.d.ts +10 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +43 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/lintofu-parser.wasm +0 -0
- package/dist/parser/types.d.ts +261 -0
- package/dist/parser/types.d.ts.map +1 -0
- package/dist/parser/types.js +3 -0
- package/dist/parser/types.js.map +1 -0
- package/dist/parser/wasm-exec.cjs +575 -0
- package/dist/project-index.d.ts +40 -0
- package/dist/project-index.d.ts.map +1 -0
- package/dist/project-index.js +89 -0
- package/dist/project-index.js.map +1 -0
- package/dist/rules/aws/acm-certificate-create-before-destroy-required.d.ts +6 -0
- package/dist/rules/aws/acm-certificate-create-before-destroy-required.d.ts.map +1 -0
- package/dist/rules/aws/acm-certificate-create-before-destroy-required.js +47 -0
- package/dist/rules/aws/acm-certificate-create-before-destroy-required.js.map +1 -0
- package/dist/rules/aws/no-api-gateway-deployment-stage-args.d.ts +6 -0
- package/dist/rules/aws/no-api-gateway-deployment-stage-args.d.ts.map +1 -0
- package/dist/rules/aws/no-api-gateway-deployment-stage-args.js +56 -0
- package/dist/rules/aws/no-api-gateway-deployment-stage-args.js.map +1 -0
- package/dist/rules/aws/no-aurora-pinned-minor-with-auto-upgrade.d.ts +6 -0
- package/dist/rules/aws/no-aurora-pinned-minor-with-auto-upgrade.d.ts.map +1 -0
- package/dist/rules/aws/no-aurora-pinned-minor-with-auto-upgrade.js +88 -0
- package/dist/rules/aws/no-aurora-pinned-minor-with-auto-upgrade.js.map +1 -0
- package/dist/rules/aws/no-db-instance-name-attribute.d.ts +6 -0
- package/dist/rules/aws/no-db-instance-name-attribute.d.ts.map +1 -0
- package/dist/rules/aws/no-db-instance-name-attribute.js +45 -0
- package/dist/rules/aws/no-db-instance-name-attribute.js.map +1 -0
- package/dist/rules/aws/no-deprecated-lambda-runtime.d.ts +6 -0
- package/dist/rules/aws/no-deprecated-lambda-runtime.d.ts.map +1 -0
- package/dist/rules/aws/no-deprecated-lambda-runtime.js +91 -0
- package/dist/rules/aws/no-deprecated-lambda-runtime.js.map +1 -0
- package/dist/rules/aws/no-eip-vpc-attribute.d.ts +6 -0
- package/dist/rules/aws/no-eip-vpc-attribute.d.ts.map +1 -0
- package/dist/rules/aws/no-eip-vpc-attribute.js +66 -0
- package/dist/rules/aws/no-eip-vpc-attribute.js.map +1 -0
- package/dist/rules/aws/no-eks-addon-resolve-conflicts.d.ts +6 -0
- package/dist/rules/aws/no-eks-addon-resolve-conflicts.d.ts.map +1 -0
- package/dist/rules/aws/no-eks-addon-resolve-conflicts.js +36 -0
- package/dist/rules/aws/no-eks-addon-resolve-conflicts.js.map +1 -0
- package/dist/rules/aws/no-hardcoded-provider-credentials.d.ts +6 -0
- package/dist/rules/aws/no-hardcoded-provider-credentials.d.ts.map +1 -0
- package/dist/rules/aws/no-hardcoded-provider-credentials.js +42 -0
- package/dist/rules/aws/no-hardcoded-provider-credentials.js.map +1 -0
- package/dist/rules/aws/no-iam-policy-attachment.d.ts +6 -0
- package/dist/rules/aws/no-iam-policy-attachment.d.ts.map +1 -0
- package/dist/rules/aws/no-iam-policy-attachment.js +28 -0
- package/dist/rules/aws/no-iam-policy-attachment.js.map +1 -0
- package/dist/rules/aws/no-iam-role-inline-policies.d.ts +6 -0
- package/dist/rules/aws/no-iam-role-inline-policies.d.ts.map +1 -0
- package/dist/rules/aws/no-iam-role-inline-policies.js +43 -0
- package/dist/rules/aws/no-iam-role-inline-policies.js.map +1 -0
- package/dist/rules/aws/no-instance-cpu-count-attributes.d.ts +6 -0
- package/dist/rules/aws/no-instance-cpu-count-attributes.d.ts.map +1 -0
- package/dist/rules/aws/no-instance-cpu-count-attributes.js +94 -0
- package/dist/rules/aws/no-instance-cpu-count-attributes.js.map +1 -0
- package/dist/rules/aws/no-legacy-security-group-rules.d.ts +6 -0
- package/dist/rules/aws/no-legacy-security-group-rules.d.ts.map +1 -0
- package/dist/rules/aws/no-legacy-security-group-rules.js +39 -0
- package/dist/rules/aws/no-legacy-security-group-rules.js.map +1 -0
- package/dist/rules/aws/no-mixed-security-group-rule-forms.d.ts +6 -0
- package/dist/rules/aws/no-mixed-security-group-rule-forms.d.ts.map +1 -0
- package/dist/rules/aws/no-mixed-security-group-rule-forms.js +63 -0
- package/dist/rules/aws/no-mixed-security-group-rule-forms.js.map +1 -0
- package/dist/rules/aws/no-pinned-minor-with-auto-upgrade.d.ts +6 -0
- package/dist/rules/aws/no-pinned-minor-with-auto-upgrade.d.ts.map +1 -0
- package/dist/rules/aws/no-pinned-minor-with-auto-upgrade.js +100 -0
- package/dist/rules/aws/no-pinned-minor-with-auto-upgrade.js.map +1 -0
- package/dist/rules/aws/no-s3-bucket-inline-config.d.ts +6 -0
- package/dist/rules/aws/no-s3-bucket-inline-config.d.ts.map +1 -0
- package/dist/rules/aws/no-s3-bucket-inline-config.js +67 -0
- package/dist/rules/aws/no-s3-bucket-inline-config.js.map +1 -0
- package/dist/rules/aws/no-s3-bucket-object.d.ts +6 -0
- package/dist/rules/aws/no-s3-bucket-object.d.ts.map +1 -0
- package/dist/rules/aws/no-s3-bucket-object.js +41 -0
- package/dist/rules/aws/no-s3-bucket-object.js.map +1 -0
- package/dist/rules/aws/utils.d.ts +4 -0
- package/dist/rules/aws/utils.d.ts.map +1 -0
- package/dist/rules/aws/utils.js +17 -0
- package/dist/rules/aws/utils.js.map +1 -0
- package/dist/rules/cloudflare/access-rule-country-block-requires-enterprise.d.ts +6 -0
- package/dist/rules/cloudflare/access-rule-country-block-requires-enterprise.d.ts.map +1 -0
- package/dist/rules/cloudflare/access-rule-country-block-requires-enterprise.js +66 -0
- package/dist/rules/cloudflare/access-rule-country-block-requires-enterprise.js.map +1 -0
- package/dist/rules/cloudflare/dns-record-requires-managed-by-annotation.d.ts +10 -0
- package/dist/rules/cloudflare/dns-record-requires-managed-by-annotation.d.ts.map +1 -0
- package/dist/rules/cloudflare/dns-record-requires-managed-by-annotation.js +104 -0
- package/dist/rules/cloudflare/dns-record-requires-managed-by-annotation.js.map +1 -0
- package/dist/rules/cloudflare/ruleset-requires-managed-by-description.d.ts +9 -0
- package/dist/rules/cloudflare/ruleset-requires-managed-by-description.d.ts.map +1 -0
- package/dist/rules/cloudflare/ruleset-requires-managed-by-description.js +52 -0
- package/dist/rules/cloudflare/ruleset-requires-managed-by-description.js.map +1 -0
- package/dist/rules/cloudflare/utils.d.ts +17 -0
- package/dist/rules/cloudflare/utils.d.ts.map +1 -0
- package/dist/rules/cloudflare/utils.js +37 -0
- package/dist/rules/cloudflare/utils.js.map +1 -0
- package/dist/rules/core/documented-outputs.d.ts +6 -0
- package/dist/rules/core/documented-outputs.d.ts.map +1 -0
- package/dist/rules/core/documented-outputs.js +41 -0
- package/dist/rules/core/documented-outputs.js.map +1 -0
- package/dist/rules/core/documented-variables.d.ts +6 -0
- package/dist/rules/core/documented-variables.d.ts.map +1 -0
- package/dist/rules/core/documented-variables.js +41 -0
- package/dist/rules/core/documented-variables.js.map +1 -0
- package/dist/rules/core/module-source-pinned.d.ts +6 -0
- package/dist/rules/core/module-source-pinned.d.ts.map +1 -0
- package/dist/rules/core/module-source-pinned.js +47 -0
- package/dist/rules/core/module-source-pinned.js.map +1 -0
- package/dist/rules/core/no-bool-as-count.d.ts +6 -0
- package/dist/rules/core/no-bool-as-count.d.ts.map +1 -0
- package/dist/rules/core/no-bool-as-count.js +69 -0
- package/dist/rules/core/no-bool-as-count.js.map +1 -0
- package/dist/rules/core/no-duplicate-map-keys.d.ts +6 -0
- package/dist/rules/core/no-duplicate-map-keys.d.ts.map +1 -0
- package/dist/rules/core/no-duplicate-map-keys.js +42 -0
- package/dist/rules/core/no-duplicate-map-keys.js.map +1 -0
- package/dist/rules/core/no-empty-list-equality.d.ts +6 -0
- package/dist/rules/core/no-empty-list-equality.d.ts.map +1 -0
- package/dist/rules/core/no-empty-list-equality.js +48 -0
- package/dist/rules/core/no-empty-list-equality.js.map +1 -0
- package/dist/rules/core/no-external-refs-in-destroy-provisioner.d.ts +6 -0
- package/dist/rules/core/no-external-refs-in-destroy-provisioner.d.ts.map +1 -0
- package/dist/rules/core/no-external-refs-in-destroy-provisioner.js +74 -0
- package/dist/rules/core/no-external-refs-in-destroy-provisioner.js.map +1 -0
- package/dist/rules/core/no-legacy-count-attribute.d.ts +6 -0
- package/dist/rules/core/no-legacy-count-attribute.d.ts.map +1 -0
- package/dist/rules/core/no-legacy-count-attribute.js +64 -0
- package/dist/rules/core/no-legacy-count-attribute.js.map +1 -0
- package/dist/rules/core/no-legacy-dot-index.d.ts +6 -0
- package/dist/rules/core/no-legacy-dot-index.d.ts.map +1 -0
- package/dist/rules/core/no-legacy-dot-index.js +79 -0
- package/dist/rules/core/no-legacy-dot-index.js.map +1 -0
- package/dist/rules/core/no-legacy-ignore-changes-wildcard.d.ts +6 -0
- package/dist/rules/core/no-legacy-ignore-changes-wildcard.d.ts.map +1 -0
- package/dist/rules/core/no-legacy-ignore-changes-wildcard.js +40 -0
- package/dist/rules/core/no-legacy-ignore-changes-wildcard.js.map +1 -0
- package/dist/rules/core/no-legacy-list-function.d.ts +6 -0
- package/dist/rules/core/no-legacy-list-function.d.ts.map +1 -0
- package/dist/rules/core/no-legacy-list-function.js +67 -0
- package/dist/rules/core/no-legacy-list-function.js.map +1 -0
- package/dist/rules/core/no-legacy-lookup.d.ts +6 -0
- package/dist/rules/core/no-legacy-lookup.d.ts.map +1 -0
- package/dist/rules/core/no-legacy-lookup.js +53 -0
- package/dist/rules/core/no-legacy-lookup.js.map +1 -0
- package/dist/rules/core/no-legacy-map-function.d.ts +6 -0
- package/dist/rules/core/no-legacy-map-function.d.ts.map +1 -0
- package/dist/rules/core/no-legacy-map-function.js +90 -0
- package/dist/rules/core/no-legacy-map-function.js.map +1 -0
- package/dist/rules/core/no-legacy-provider-proxy.d.ts +6 -0
- package/dist/rules/core/no-legacy-provider-proxy.d.ts.map +1 -0
- package/dist/rules/core/no-legacy-provider-proxy.js +43 -0
- package/dist/rules/core/no-legacy-provider-proxy.js.map +1 -0
- package/dist/rules/core/no-provider-version-constraint.d.ts +6 -0
- package/dist/rules/core/no-provider-version-constraint.d.ts.map +1 -0
- package/dist/rules/core/no-provider-version-constraint.js +33 -0
- package/dist/rules/core/no-provider-version-constraint.js.map +1 -0
- package/dist/rules/core/no-quoted-depends-on.d.ts +6 -0
- package/dist/rules/core/no-quoted-depends-on.d.ts.map +1 -0
- package/dist/rules/core/no-quoted-depends-on.js +55 -0
- package/dist/rules/core/no-quoted-depends-on.js.map +1 -0
- package/dist/rules/core/no-quoted-ignore-changes.d.ts +6 -0
- package/dist/rules/core/no-quoted-ignore-changes.d.ts.map +1 -0
- package/dist/rules/core/no-quoted-ignore-changes.js +63 -0
- package/dist/rules/core/no-quoted-ignore-changes.js.map +1 -0
- package/dist/rules/core/no-quoted-provider-reference.d.ts +6 -0
- package/dist/rules/core/no-quoted-provider-reference.d.ts.map +1 -0
- package/dist/rules/core/no-quoted-provider-reference.js +69 -0
- package/dist/rules/core/no-quoted-provider-reference.js.map +1 -0
- package/dist/rules/core/no-quoted-type-constraints.d.ts +6 -0
- package/dist/rules/core/no-quoted-type-constraints.d.ts.map +1 -0
- package/dist/rules/core/no-quoted-type-constraints.js +55 -0
- package/dist/rules/core/no-quoted-type-constraints.js.map +1 -0
- package/dist/rules/core/no-reserved-variable-names.d.ts +6 -0
- package/dist/rules/core/no-reserved-variable-names.d.ts.map +1 -0
- package/dist/rules/core/no-reserved-variable-names.js +41 -0
- package/dist/rules/core/no-reserved-variable-names.js.map +1 -0
- package/dist/rules/core/no-splat-bracket-index.d.ts +6 -0
- package/dist/rules/core/no-splat-bracket-index.d.ts.map +1 -0
- package/dist/rules/core/no-splat-bracket-index.js +30 -0
- package/dist/rules/core/no-splat-bracket-index.js.map +1 -0
- package/dist/rules/core/no-template-provider.d.ts +6 -0
- package/dist/rules/core/no-template-provider.d.ts.map +1 -0
- package/dist/rules/core/no-template-provider.js +63 -0
- package/dist/rules/core/no-template-provider.js.map +1 -0
- package/dist/rules/core/no-terraform-env-reference.d.ts +6 -0
- package/dist/rules/core/no-terraform-env-reference.d.ts.map +1 -0
- package/dist/rules/core/no-terraform-env-reference.js +35 -0
- package/dist/rules/core/no-terraform-env-reference.js.map +1 -0
- package/dist/rules/core/no-winrm-connection.d.ts +6 -0
- package/dist/rules/core/no-winrm-connection.d.ts.map +1 -0
- package/dist/rules/core/no-winrm-connection.js +31 -0
- package/dist/rules/core/no-winrm-connection.js.map +1 -0
- package/dist/rules/core/prefer-bare-expression.d.ts +6 -0
- package/dist/rules/core/prefer-bare-expression.d.ts.map +1 -0
- package/dist/rules/core/prefer-bare-expression.js +23 -0
- package/dist/rules/core/prefer-bare-expression.js.map +1 -0
- package/dist/rules/core/provider-source-required.d.ts +6 -0
- package/dist/rules/core/provider-source-required.d.ts.map +1 -0
- package/dist/rules/core/provider-source-required.js +45 -0
- package/dist/rules/core/provider-source-required.js.map +1 -0
- package/dist/rules/core/remote-state-outputs-prefix.d.ts +6 -0
- package/dist/rules/core/remote-state-outputs-prefix.d.ts.map +1 -0
- package/dist/rules/core/remote-state-outputs-prefix.js +54 -0
- package/dist/rules/core/remote-state-outputs-prefix.js.map +1 -0
- package/dist/rules/core/required-providers-pinned.d.ts +6 -0
- package/dist/rules/core/required-providers-pinned.d.ts.map +1 -0
- package/dist/rules/core/required-providers-pinned.js +37 -0
- package/dist/rules/core/required-providers-pinned.js.map +1 -0
- package/dist/rules/core/required-version-declared.d.ts +6 -0
- package/dist/rules/core/required-version-declared.d.ts.map +1 -0
- package/dist/rules/core/required-version-declared.js +38 -0
- package/dist/rules/core/required-version-declared.js.map +1 -0
- package/dist/rules/core/typed-variables.d.ts +6 -0
- package/dist/rules/core/typed-variables.d.ts.map +1 -0
- package/dist/rules/core/typed-variables.js +32 -0
- package/dist/rules/core/typed-variables.js.map +1 -0
- package/dist/rules/core/utils.d.ts +31 -0
- package/dist/rules/core/utils.d.ts.map +1 -0
- package/dist/rules/core/utils.js +185 -0
- package/dist/rules/core/utils.js.map +1 -0
- package/dist/rules/index.d.ts +157 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +101 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/types.d.ts +57 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/types.js +15 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/source-code.d.ts +84 -0
- package/dist/source-code.d.ts.map +1 -0
- package/dist/source-code.js +170 -0
- package/dist/source-code.js.map +1 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/visitor-keys.d.ts +3 -0
- package/dist/visitor-keys.d.ts.map +1 -0
- package/dist/visitor-keys.js +30 -0
- package/dist/visitor-keys.js.map +1 -0
- package/package.json +88 -4
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { visitorKeys } from '../../visitor-keys.js';
|
|
2
|
+
// Collects every ScopeTraversalExpr reachable from expr, descending via
|
|
3
|
+
// visitorKeys so new expression types are handled as soon as they have an
|
|
4
|
+
// entry there.
|
|
5
|
+
export function collectTraversals(expr) {
|
|
6
|
+
const out = [];
|
|
7
|
+
gather(expr, out, new Set());
|
|
8
|
+
return out;
|
|
9
|
+
}
|
|
10
|
+
function gather(expr, out, bound) {
|
|
11
|
+
if (expr.type === 'ScopeTraversalExpr') {
|
|
12
|
+
const root = expr.traversal[0];
|
|
13
|
+
if (root?.type === 'TraverseRoot' && bound.has(root.name))
|
|
14
|
+
return;
|
|
15
|
+
out.push(expr);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// A bareword object key (`FOO = ...`) arrives as ObjectConsKeyExpr wrapping a
|
|
19
|
+
// single-step ScopeTraversalExpr; that's a name, never a reference.
|
|
20
|
+
if (expr.type === 'ObjectConsKeyExpr')
|
|
21
|
+
return;
|
|
22
|
+
if (expr.type === 'ObjectConsExpr') {
|
|
23
|
+
for (const item of expr.items) {
|
|
24
|
+
gather(item.keyExpr, out, bound);
|
|
25
|
+
gather(item.valueExpr, out, bound);
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (expr.type === 'ForExpr') {
|
|
30
|
+
// The collection is evaluated in the outer scope; keyVar/valVar only bind
|
|
31
|
+
// inside the key/value/cond exprs, so refs there rooted on them are local.
|
|
32
|
+
gather(expr.collExpr, out, bound);
|
|
33
|
+
const inner = new Set(bound);
|
|
34
|
+
if (expr.keyVar)
|
|
35
|
+
inner.add(expr.keyVar);
|
|
36
|
+
if (expr.valVar)
|
|
37
|
+
inner.add(expr.valVar);
|
|
38
|
+
if (expr.keyExpr)
|
|
39
|
+
gather(expr.keyExpr, out, inner);
|
|
40
|
+
gather(expr.valExpr, out, inner);
|
|
41
|
+
if (expr.condExpr)
|
|
42
|
+
gather(expr.condExpr, out, inner);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const indexed = expr;
|
|
46
|
+
for (const key of visitorKeys[expr.type]) {
|
|
47
|
+
const child = indexed[key];
|
|
48
|
+
if (Array.isArray(child)) {
|
|
49
|
+
for (const c of child)
|
|
50
|
+
if (isExpression(c))
|
|
51
|
+
gather(c, out, bound);
|
|
52
|
+
}
|
|
53
|
+
else if (isExpression(child)) {
|
|
54
|
+
gather(child, out, bound);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function isExpression(value) {
|
|
59
|
+
return (typeof value === 'object' &&
|
|
60
|
+
value !== null &&
|
|
61
|
+
typeof value.type === 'string');
|
|
62
|
+
}
|
|
63
|
+
// Renders a traversal back to source-like text: `var.commands[0]`,
|
|
64
|
+
// `local.map["region"]`. Index steps are bracketed; attr/root steps dotted.
|
|
65
|
+
export function traversalText(expr) {
|
|
66
|
+
let out = '';
|
|
67
|
+
for (const step of expr.traversal) {
|
|
68
|
+
if (step.type === 'TraverseIndex') {
|
|
69
|
+
out += `[${typeof step.key === 'string' ? JSON.stringify(step.key) : String(step.key)}]`;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
out += out === '' ? step.name : `.${step.name}`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
// Returns the concatenated string only when expr is a TemplateExpr made
|
|
78
|
+
// entirely of literal string parts. Returns undefined for interpolated or
|
|
79
|
+
// otherwise dynamic values so rules can opt out of judging them.
|
|
80
|
+
export function literalStringValue(expr) {
|
|
81
|
+
if (expr.type !== 'TemplateExpr')
|
|
82
|
+
return undefined;
|
|
83
|
+
let out = '';
|
|
84
|
+
for (const part of expr.parts) {
|
|
85
|
+
if (part.type !== 'LiteralValueExpr')
|
|
86
|
+
return undefined;
|
|
87
|
+
if (typeof part.value !== 'string')
|
|
88
|
+
return undefined;
|
|
89
|
+
out += part.value;
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
export function findAttribute(attrs, name) {
|
|
94
|
+
return attrs.find((a) => a.name === name);
|
|
95
|
+
}
|
|
96
|
+
export function literalAttributeValue(block, name) {
|
|
97
|
+
const attr = findAttribute(block.body.attributes, name);
|
|
98
|
+
return attr ? literalStringValue(attr.expression) : undefined;
|
|
99
|
+
}
|
|
100
|
+
// Returns the node to report when the attribute is missing (the block) or is
|
|
101
|
+
// a literal other than expected (the attribute). Dynamic values return
|
|
102
|
+
// undefined because they cannot be judged at lint time.
|
|
103
|
+
export function findLiteralMismatch(block, name, expected) {
|
|
104
|
+
const attr = findAttribute(block.body.attributes, name);
|
|
105
|
+
if (!attr)
|
|
106
|
+
return block;
|
|
107
|
+
const value = literalStringValue(attr.expression);
|
|
108
|
+
return value === undefined || value === expected ? undefined : attr;
|
|
109
|
+
}
|
|
110
|
+
export function trimNumericVersion(version, depth) {
|
|
111
|
+
const parts = version.split('.');
|
|
112
|
+
if (!parts.every((p) => /^\d+$/.test(p)))
|
|
113
|
+
return undefined;
|
|
114
|
+
if (parts.length <= depth)
|
|
115
|
+
return undefined;
|
|
116
|
+
return parts.slice(0, depth).join('.');
|
|
117
|
+
}
|
|
118
|
+
export function traversalHead(expr) {
|
|
119
|
+
const [root, name] = expr.traversal;
|
|
120
|
+
if (root?.type !== 'TraverseRoot')
|
|
121
|
+
return undefined;
|
|
122
|
+
if (name?.type !== 'TraverseAttr')
|
|
123
|
+
return undefined;
|
|
124
|
+
return [root.name, name.name];
|
|
125
|
+
}
|
|
126
|
+
export function blockLabel(block) {
|
|
127
|
+
return block.labels[0] ?? '<unnamed>';
|
|
128
|
+
}
|
|
129
|
+
export function checkDescription(block) {
|
|
130
|
+
const attr = findAttribute(block.body.attributes, 'description');
|
|
131
|
+
if (!attr)
|
|
132
|
+
return { status: 'missing' };
|
|
133
|
+
const value = literalStringValue(attr.expression);
|
|
134
|
+
if (value === undefined)
|
|
135
|
+
return { status: 'dynamic' };
|
|
136
|
+
if (value.trim() === '')
|
|
137
|
+
return { status: 'empty', attr };
|
|
138
|
+
return { status: 'ok' };
|
|
139
|
+
}
|
|
140
|
+
// Bare-identifier keys (`version = "x"`) come through as ObjectConsKeyExpr
|
|
141
|
+
// wrapping a single-step ScopeTraversalExpr. Quoted keys (`"version" = "x"`)
|
|
142
|
+
// wrap a TemplateExpr instead.
|
|
143
|
+
export function objectItemKeyName(item) {
|
|
144
|
+
const inner = item.keyExpr.type === 'ObjectConsKeyExpr'
|
|
145
|
+
? item.keyExpr.wrapped
|
|
146
|
+
: item.keyExpr;
|
|
147
|
+
if (inner.type === 'ScopeTraversalExpr' && inner.traversal.length === 1) {
|
|
148
|
+
const t = inner.traversal[0];
|
|
149
|
+
if (t?.type === 'TraverseRoot')
|
|
150
|
+
return t.name;
|
|
151
|
+
}
|
|
152
|
+
if (inner.type === 'TemplateExpr') {
|
|
153
|
+
return literalStringValue(inner);
|
|
154
|
+
}
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
export function requiredProviderEntries(terraform) {
|
|
158
|
+
const blockForm = terraform.body.blocks.find((b) => b.kind === 'required_providers');
|
|
159
|
+
if (blockForm) {
|
|
160
|
+
return blockForm.body.attributes.map((attr) => ({
|
|
161
|
+
name: attr.name,
|
|
162
|
+
value: attr.expression,
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
const attrForm = findAttribute(terraform.body.attributes, 'required_providers');
|
|
166
|
+
if (attrForm?.expression.type !== 'ObjectConsExpr')
|
|
167
|
+
return [];
|
|
168
|
+
const out = [];
|
|
169
|
+
for (const item of attrForm.expression.items) {
|
|
170
|
+
const name = objectItemKeyName(item);
|
|
171
|
+
if (name === undefined)
|
|
172
|
+
continue;
|
|
173
|
+
out.push({ name, value: item.valueExpr });
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
}
|
|
177
|
+
export function objectSetting(value) {
|
|
178
|
+
return typeof value === 'object' && value !== null
|
|
179
|
+
? value
|
|
180
|
+
: {};
|
|
181
|
+
}
|
|
182
|
+
export function lintofuSettings(settings) {
|
|
183
|
+
return objectSetting(settings.lintofu);
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sour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ACb,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAChD,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,QAAwB;IAExB,OAAO,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
export declare const rules: {
|
|
2
|
+
'documented-variables': import("../types.js").OpenTofuRuleDefinition<{
|
|
3
|
+
MessageIds: "missingDescription";
|
|
4
|
+
}>;
|
|
5
|
+
'no-reserved-variable-names': import("../types.js").OpenTofuRuleDefinition<{
|
|
6
|
+
MessageIds: "reservedName";
|
|
7
|
+
}>;
|
|
8
|
+
'documented-outputs': import("../types.js").OpenTofuRuleDefinition<{
|
|
9
|
+
MessageIds: "missingDescription";
|
|
10
|
+
}>;
|
|
11
|
+
'required-providers-pinned': import("../types.js").OpenTofuRuleDefinition<{
|
|
12
|
+
MessageIds: "unpinnedProvider";
|
|
13
|
+
}>;
|
|
14
|
+
'provider-source-required': import("../types.js").OpenTofuRuleDefinition<{
|
|
15
|
+
MessageIds: "missingSource" | "legacyStringForm";
|
|
16
|
+
}>;
|
|
17
|
+
'module-source-pinned': import("../types.js").OpenTofuRuleDefinition<{
|
|
18
|
+
MessageIds: "unpinnedSource";
|
|
19
|
+
}>;
|
|
20
|
+
'prefer-bare-expression': import("../types.js").OpenTofuRuleDefinition<{
|
|
21
|
+
MessageIds: "preferBareExpression";
|
|
22
|
+
}>;
|
|
23
|
+
'no-legacy-list-function': import("../types.js").OpenTofuRuleDefinition<{
|
|
24
|
+
MessageIds: "legacyListFunction";
|
|
25
|
+
}>;
|
|
26
|
+
'no-legacy-map-function': import("../types.js").OpenTofuRuleDefinition<{
|
|
27
|
+
MessageIds: "legacyMapFunction";
|
|
28
|
+
}>;
|
|
29
|
+
'no-bool-as-count': import("../types.js").OpenTofuRuleDefinition<{
|
|
30
|
+
MessageIds: "boolAsCount";
|
|
31
|
+
}>;
|
|
32
|
+
'no-legacy-provider-proxy': import("../types.js").OpenTofuRuleDefinition<{
|
|
33
|
+
MessageIds: "legacyProviderProxy";
|
|
34
|
+
}>;
|
|
35
|
+
'no-template-provider': import("../types.js").OpenTofuRuleDefinition<{
|
|
36
|
+
MessageIds: "useTemplatefile" | "useCloudinitProvider" | "archivedTemplateProvider";
|
|
37
|
+
}>;
|
|
38
|
+
'no-terraform-env-reference': import("../types.js").OpenTofuRuleDefinition<{
|
|
39
|
+
MessageIds: "terraformEnvReference";
|
|
40
|
+
}>;
|
|
41
|
+
'no-quoted-type-constraints': import("../types.js").OpenTofuRuleDefinition<{
|
|
42
|
+
MessageIds: "quotedTypeConstraint";
|
|
43
|
+
}>;
|
|
44
|
+
'no-splat-bracket-index': import("../types.js").OpenTofuRuleDefinition<{
|
|
45
|
+
MessageIds: "splatBracketIndex";
|
|
46
|
+
}>;
|
|
47
|
+
'remote-state-outputs-prefix': import("../types.js").OpenTofuRuleDefinition<{
|
|
48
|
+
MessageIds: "missingOutputsPrefix";
|
|
49
|
+
}>;
|
|
50
|
+
'no-external-refs-in-destroy-provisioner': import("../types.js").OpenTofuRuleDefinition<{
|
|
51
|
+
MessageIds: "disallowedReference";
|
|
52
|
+
}>;
|
|
53
|
+
'no-legacy-ignore-changes-wildcard': import("../types.js").OpenTofuRuleDefinition<{
|
|
54
|
+
MessageIds: "legacyIgnoreChangesWildcard";
|
|
55
|
+
}>;
|
|
56
|
+
'no-legacy-count-attribute': import("../types.js").OpenTofuRuleDefinition<{
|
|
57
|
+
MessageIds: "legacyCountAttribute";
|
|
58
|
+
}>;
|
|
59
|
+
'no-iam-role-inline-policies': import("../types.js").OpenTofuRuleDefinition<{
|
|
60
|
+
MessageIds: "inlinePolicy" | "managedPolicyArns";
|
|
61
|
+
}>;
|
|
62
|
+
'no-legacy-security-group-rules': import("../types.js").OpenTofuRuleDefinition<{
|
|
63
|
+
MessageIds: "legacySecurityGroupRule";
|
|
64
|
+
}>;
|
|
65
|
+
'no-mixed-security-group-rule-forms': import("../types.js").OpenTofuRuleDefinition<{
|
|
66
|
+
MessageIds: "mixedForms";
|
|
67
|
+
}>;
|
|
68
|
+
'no-pinned-minor-with-auto-upgrade': import("../types.js").OpenTofuRuleDefinition<{
|
|
69
|
+
MessageIds: "pinnedMinorWithAutoUpgrade";
|
|
70
|
+
}>;
|
|
71
|
+
'no-aurora-pinned-minor-with-auto-upgrade': import("../types.js").OpenTofuRuleDefinition<{
|
|
72
|
+
MessageIds: "pinnedMinorWithAutoUpgrade";
|
|
73
|
+
}>;
|
|
74
|
+
'no-iam-policy-attachment': import("../types.js").OpenTofuRuleDefinition<{
|
|
75
|
+
MessageIds: "iamPolicyAttachment";
|
|
76
|
+
}>;
|
|
77
|
+
'no-s3-bucket-inline-config': import("../types.js").OpenTofuRuleDefinition<{
|
|
78
|
+
MessageIds: "inlineConfig";
|
|
79
|
+
}>;
|
|
80
|
+
'no-legacy-dot-index': import("../types.js").OpenTofuRuleDefinition<{
|
|
81
|
+
MessageIds: "dotIndex" | "dotSplat";
|
|
82
|
+
}>;
|
|
83
|
+
'no-legacy-lookup': import("../types.js").OpenTofuRuleDefinition<{
|
|
84
|
+
MessageIds: "legacyLookup";
|
|
85
|
+
}>;
|
|
86
|
+
'no-quoted-depends-on': import("../types.js").OpenTofuRuleDefinition<{
|
|
87
|
+
MessageIds: "quotedDependsOn";
|
|
88
|
+
}>;
|
|
89
|
+
'no-quoted-provider-reference': import("../types.js").OpenTofuRuleDefinition<{
|
|
90
|
+
MessageIds: "quotedProviderReference";
|
|
91
|
+
}>;
|
|
92
|
+
'no-quoted-ignore-changes': import("../types.js").OpenTofuRuleDefinition<{
|
|
93
|
+
MessageIds: "quotedIgnoreChanges";
|
|
94
|
+
}>;
|
|
95
|
+
'no-empty-list-equality': import("../types.js").OpenTofuRuleDefinition<{
|
|
96
|
+
MessageIds: "emptyListEquality";
|
|
97
|
+
}>;
|
|
98
|
+
'no-winrm-connection': import("../types.js").OpenTofuRuleDefinition<{
|
|
99
|
+
MessageIds: "winrmConnection";
|
|
100
|
+
}>;
|
|
101
|
+
'typed-variables': import("../types.js").OpenTofuRuleDefinition<{
|
|
102
|
+
MessageIds: "missingType";
|
|
103
|
+
}>;
|
|
104
|
+
'no-eip-vpc-attribute': import("../types.js").OpenTofuRuleDefinition<{
|
|
105
|
+
MessageIds: "eipVpcAttribute";
|
|
106
|
+
}>;
|
|
107
|
+
'no-instance-cpu-count-attributes': import("../types.js").OpenTofuRuleDefinition<{
|
|
108
|
+
MessageIds: "cpuCountAttribute";
|
|
109
|
+
}>;
|
|
110
|
+
'required-version-declared': import("../types.js").OpenTofuRuleDefinition<{
|
|
111
|
+
MessageIds: "missingRequiredVersion";
|
|
112
|
+
}>;
|
|
113
|
+
'no-duplicate-map-keys': import("../types.js").OpenTofuRuleDefinition<{
|
|
114
|
+
MessageIds: "duplicateMapKey";
|
|
115
|
+
}>;
|
|
116
|
+
'no-provider-version-constraint': import("../types.js").OpenTofuRuleDefinition<{
|
|
117
|
+
MessageIds: "providerVersionConstraint";
|
|
118
|
+
}>;
|
|
119
|
+
'no-db-instance-name-attribute': import("../types.js").OpenTofuRuleDefinition<{
|
|
120
|
+
MessageIds: "dbInstanceName";
|
|
121
|
+
}>;
|
|
122
|
+
'no-eks-addon-resolve-conflicts': import("../types.js").OpenTofuRuleDefinition<{
|
|
123
|
+
MessageIds: "resolveConflicts";
|
|
124
|
+
}>;
|
|
125
|
+
'no-api-gateway-deployment-stage-args': import("../types.js").OpenTofuRuleDefinition<{
|
|
126
|
+
MessageIds: "deploymentStageArg";
|
|
127
|
+
}>;
|
|
128
|
+
'no-s3-bucket-object': import("../types.js").OpenTofuRuleDefinition<{
|
|
129
|
+
MessageIds: "deprecatedS3BucketObject";
|
|
130
|
+
}>;
|
|
131
|
+
'no-hardcoded-provider-credentials': import("../types.js").OpenTofuRuleDefinition<{
|
|
132
|
+
MessageIds: "hardcodedCredential";
|
|
133
|
+
}>;
|
|
134
|
+
'no-deprecated-lambda-runtime': import("../types.js").OpenTofuRuleDefinition<{
|
|
135
|
+
MessageIds: "deprecatedRuntime";
|
|
136
|
+
}>;
|
|
137
|
+
'acm-certificate-create-before-destroy-required': import("../types.js").OpenTofuRuleDefinition<{
|
|
138
|
+
MessageIds: "missingCreateBeforeDestroy";
|
|
139
|
+
}>;
|
|
140
|
+
'access-rule-country-block-requires-enterprise': import("../types.js").OpenTofuRuleDefinition<{
|
|
141
|
+
MessageIds: "countryBlockRequiresEnterprise" | "invalidPlan";
|
|
142
|
+
}>;
|
|
143
|
+
'ruleset-requires-managed-by-description': import("../types.js").OpenTofuRuleDefinition<{
|
|
144
|
+
RuleOptions: [{
|
|
145
|
+
description?: string;
|
|
146
|
+
}?];
|
|
147
|
+
MessageIds: "missingDescription";
|
|
148
|
+
}>;
|
|
149
|
+
'dns-record-requires-managed-by-annotation': import("../types.js").OpenTofuRuleDefinition<{
|
|
150
|
+
RuleOptions: [{
|
|
151
|
+
comment?: string;
|
|
152
|
+
tag?: string;
|
|
153
|
+
}?];
|
|
154
|
+
MessageIds: "missingComment" | "missingTag" | "invalidPlan";
|
|
155
|
+
}>;
|
|
156
|
+
};
|
|
157
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAkDA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAhDqC,CAAC;;;;;;mBAc7C,CAAC;eAAa,CAAC;;;;CAyFzB,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import acmCertificateCreateBeforeDestroyRequired from './aws/acm-certificate-create-before-destroy-required.js';
|
|
2
|
+
import noApiGatewayDeploymentStageArgs from './aws/no-api-gateway-deployment-stage-args.js';
|
|
3
|
+
import noAuroraPinnedMinorWithAutoUpgrade from './aws/no-aurora-pinned-minor-with-auto-upgrade.js';
|
|
4
|
+
import noDbInstanceNameAttribute from './aws/no-db-instance-name-attribute.js';
|
|
5
|
+
import noDeprecatedLambdaRuntime from './aws/no-deprecated-lambda-runtime.js';
|
|
6
|
+
import noEipVpcAttribute from './aws/no-eip-vpc-attribute.js';
|
|
7
|
+
import noEksAddonResolveConflicts from './aws/no-eks-addon-resolve-conflicts.js';
|
|
8
|
+
import noHardcodedProviderCredentials from './aws/no-hardcoded-provider-credentials.js';
|
|
9
|
+
import noIamPolicyAttachment from './aws/no-iam-policy-attachment.js';
|
|
10
|
+
import noIamRoleInlinePolicies from './aws/no-iam-role-inline-policies.js';
|
|
11
|
+
import noInstanceCpuCountAttributes from './aws/no-instance-cpu-count-attributes.js';
|
|
12
|
+
import noLegacySecurityGroupRules from './aws/no-legacy-security-group-rules.js';
|
|
13
|
+
import noMixedSecurityGroupRuleForms from './aws/no-mixed-security-group-rule-forms.js';
|
|
14
|
+
import noPinnedMinorWithAutoUpgrade from './aws/no-pinned-minor-with-auto-upgrade.js';
|
|
15
|
+
import noS3BucketInlineConfig from './aws/no-s3-bucket-inline-config.js';
|
|
16
|
+
import noS3BucketObject from './aws/no-s3-bucket-object.js';
|
|
17
|
+
import accessRuleCountryBlockRequiresEnterprise from './cloudflare/access-rule-country-block-requires-enterprise.js';
|
|
18
|
+
import dnsRecordRequiresManagedByAnnotation from './cloudflare/dns-record-requires-managed-by-annotation.js';
|
|
19
|
+
import rulesetRequiresManagedByDescription from './cloudflare/ruleset-requires-managed-by-description.js';
|
|
20
|
+
import documentedOutputs from './core/documented-outputs.js';
|
|
21
|
+
import documentedVariables from './core/documented-variables.js';
|
|
22
|
+
import moduleSourcePinned from './core/module-source-pinned.js';
|
|
23
|
+
import noBoolAsCount from './core/no-bool-as-count.js';
|
|
24
|
+
import noDuplicateMapKeys from './core/no-duplicate-map-keys.js';
|
|
25
|
+
import noEmptyListEquality from './core/no-empty-list-equality.js';
|
|
26
|
+
import noExternalRefsInDestroyProvisioner from './core/no-external-refs-in-destroy-provisioner.js';
|
|
27
|
+
import noLegacyCountAttribute from './core/no-legacy-count-attribute.js';
|
|
28
|
+
import noLegacyDotIndex from './core/no-legacy-dot-index.js';
|
|
29
|
+
import noLegacyIgnoreChangesWildcard from './core/no-legacy-ignore-changes-wildcard.js';
|
|
30
|
+
import noLegacyListFunction from './core/no-legacy-list-function.js';
|
|
31
|
+
import noLegacyLookup from './core/no-legacy-lookup.js';
|
|
32
|
+
import noLegacyMapFunction from './core/no-legacy-map-function.js';
|
|
33
|
+
import noLegacyProviderProxy from './core/no-legacy-provider-proxy.js';
|
|
34
|
+
import noProviderVersionConstraint from './core/no-provider-version-constraint.js';
|
|
35
|
+
import noQuotedDependsOn from './core/no-quoted-depends-on.js';
|
|
36
|
+
import noQuotedIgnoreChanges from './core/no-quoted-ignore-changes.js';
|
|
37
|
+
import noQuotedProviderReference from './core/no-quoted-provider-reference.js';
|
|
38
|
+
import noQuotedTypeConstraints from './core/no-quoted-type-constraints.js';
|
|
39
|
+
import noReservedVariableNames from './core/no-reserved-variable-names.js';
|
|
40
|
+
import noSplatBracketIndex from './core/no-splat-bracket-index.js';
|
|
41
|
+
import noTemplateProvider from './core/no-template-provider.js';
|
|
42
|
+
import noTerraformEnvReference from './core/no-terraform-env-reference.js';
|
|
43
|
+
import noWinrmConnection from './core/no-winrm-connection.js';
|
|
44
|
+
import preferBareExpression from './core/prefer-bare-expression.js';
|
|
45
|
+
import providerSourceRequired from './core/provider-source-required.js';
|
|
46
|
+
import remoteStateOutputsPrefix from './core/remote-state-outputs-prefix.js';
|
|
47
|
+
import requiredProvidersPinned from './core/required-providers-pinned.js';
|
|
48
|
+
import requiredVersionDeclared from './core/required-version-declared.js';
|
|
49
|
+
import typedVariables from './core/typed-variables.js';
|
|
50
|
+
export const rules = {
|
|
51
|
+
'documented-variables': documentedVariables,
|
|
52
|
+
'no-reserved-variable-names': noReservedVariableNames,
|
|
53
|
+
'documented-outputs': documentedOutputs,
|
|
54
|
+
'required-providers-pinned': requiredProvidersPinned,
|
|
55
|
+
'provider-source-required': providerSourceRequired,
|
|
56
|
+
'module-source-pinned': moduleSourcePinned,
|
|
57
|
+
'prefer-bare-expression': preferBareExpression,
|
|
58
|
+
'no-legacy-list-function': noLegacyListFunction,
|
|
59
|
+
'no-legacy-map-function': noLegacyMapFunction,
|
|
60
|
+
'no-bool-as-count': noBoolAsCount,
|
|
61
|
+
'no-legacy-provider-proxy': noLegacyProviderProxy,
|
|
62
|
+
'no-template-provider': noTemplateProvider,
|
|
63
|
+
'no-terraform-env-reference': noTerraformEnvReference,
|
|
64
|
+
'no-quoted-type-constraints': noQuotedTypeConstraints,
|
|
65
|
+
'no-splat-bracket-index': noSplatBracketIndex,
|
|
66
|
+
'remote-state-outputs-prefix': remoteStateOutputsPrefix,
|
|
67
|
+
'no-external-refs-in-destroy-provisioner': noExternalRefsInDestroyProvisioner,
|
|
68
|
+
'no-legacy-ignore-changes-wildcard': noLegacyIgnoreChangesWildcard,
|
|
69
|
+
'no-legacy-count-attribute': noLegacyCountAttribute,
|
|
70
|
+
'no-iam-role-inline-policies': noIamRoleInlinePolicies,
|
|
71
|
+
'no-legacy-security-group-rules': noLegacySecurityGroupRules,
|
|
72
|
+
'no-mixed-security-group-rule-forms': noMixedSecurityGroupRuleForms,
|
|
73
|
+
'no-pinned-minor-with-auto-upgrade': noPinnedMinorWithAutoUpgrade,
|
|
74
|
+
'no-aurora-pinned-minor-with-auto-upgrade': noAuroraPinnedMinorWithAutoUpgrade,
|
|
75
|
+
'no-iam-policy-attachment': noIamPolicyAttachment,
|
|
76
|
+
'no-s3-bucket-inline-config': noS3BucketInlineConfig,
|
|
77
|
+
'no-legacy-dot-index': noLegacyDotIndex,
|
|
78
|
+
'no-legacy-lookup': noLegacyLookup,
|
|
79
|
+
'no-quoted-depends-on': noQuotedDependsOn,
|
|
80
|
+
'no-quoted-provider-reference': noQuotedProviderReference,
|
|
81
|
+
'no-quoted-ignore-changes': noQuotedIgnoreChanges,
|
|
82
|
+
'no-empty-list-equality': noEmptyListEquality,
|
|
83
|
+
'no-winrm-connection': noWinrmConnection,
|
|
84
|
+
'typed-variables': typedVariables,
|
|
85
|
+
'no-eip-vpc-attribute': noEipVpcAttribute,
|
|
86
|
+
'no-instance-cpu-count-attributes': noInstanceCpuCountAttributes,
|
|
87
|
+
'required-version-declared': requiredVersionDeclared,
|
|
88
|
+
'no-duplicate-map-keys': noDuplicateMapKeys,
|
|
89
|
+
'no-provider-version-constraint': noProviderVersionConstraint,
|
|
90
|
+
'no-db-instance-name-attribute': noDbInstanceNameAttribute,
|
|
91
|
+
'no-eks-addon-resolve-conflicts': noEksAddonResolveConflicts,
|
|
92
|
+
'no-api-gateway-deployment-stage-args': noApiGatewayDeploymentStageArgs,
|
|
93
|
+
'no-s3-bucket-object': noS3BucketObject,
|
|
94
|
+
'no-hardcoded-provider-credentials': noHardcodedProviderCredentials,
|
|
95
|
+
'no-deprecated-lambda-runtime': noDeprecatedLambdaRuntime,
|
|
96
|
+
'acm-certificate-create-before-destroy-required': acmCertificateCreateBeforeDestroyRequired,
|
|
97
|
+
'access-rule-country-block-requires-enterprise': accessRuleCountryBlockRequiresEnterprise,
|
|
98
|
+
'ruleset-requires-managed-by-description': rulesetRequiresManagedByDescription,
|
|
99
|
+
'dns-record-requires-managed-by-annotation': dnsRecordRequiresManagedByAnnotation,
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,yCAAyC,MAAM,yDAAyD,CAA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6BAA6B,EAAE,wBAAwB;IACvD,yCAAyC,EAAE,kCAAkC;IAC7E,mCAAmC,EAAE,6BAA6B;IAClE,2BAA2B,EAAE,sBAAsB;IACnD,6BAA6B,EAAE,uBAAuB;IACtD,gCAAgC,EAAE,0BAA0B;IAC5D,oCAAoC,EAAE,6BAA6B;IACnE,mCAAmC,EAAE,4BAA4B;IACjE,0CAA0C,EACxC,kCAAkC;IACpC,0BAA0B,EAAE,qBAAqB;IACjD,4BAA4B,EAAE,sBAAsB;IACpD,qBAAqB,EAAE,gBAAgB;IACvC,kBAAkB,EAAE,cAAc;IAClC,sBAAsB,EAAE,iBAAiB;IACzC,8BAA8B,EAAE,yBAAyB;IACzD,0BAA0B,EAAE,qBAAqB;IACjD,wBAAwB,EAAE,mBAAmB;IAC7C,qBAAqB,EAAE,iBAAiB;IACxC,iBAAiB,EAAE,cAAc;IACjC,sBAAsB,EAAE,iBAAiB;IACzC,kCAAkC,EAAE,4BAA4B;IAChE,2BAA2B,EAAE,uBAAuB;IACpD,uBAAuB,EAAE,kBAAkB;IAC3C,gCAAgC,EAAE,2BAA2B;IAC7D,+BAA+B,EAAE,yBAAyB;IAC1D,gCAAgC,EAAE,0BAA0B;IAC5D,sCAAsC,EAAE,+BAA+B;IACvE,qBAAqB,EAAE,gBAAgB;IACvC,mCAAmC,EAAE,8BAA8B;IACnE,8BAA8B,EAAE,yBAAyB;IACzD,gDAAgD,EAC9C,yCAAyC;IAC3C,+CAA+C,EAC7C,wCAAwC;IAC1C,yCAAyC,EACvC,mCAAmC;IACrC,2CAA2C,EACzC,oCAAoC;CACvC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata on a rule's `meta.docs` that drives the generated config tiers
|
|
3
|
+
* (adr 0002).
|
|
4
|
+
*/
|
|
5
|
+
export interface LintofuRuleDocs {
|
|
6
|
+
/** What the rule enforces. Shown by docs tooling. */
|
|
7
|
+
description?: string;
|
|
8
|
+
/**
|
|
9
|
+
* `true` puts the rule in `configs.recommended`. A rule that omits this
|
|
10
|
+
* (or sets it false) is in no generated tier at all, so it silently ships
|
|
11
|
+
* unreachable unless users enable it by hand.
|
|
12
|
+
*/
|
|
13
|
+
recommended?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Severity the generated configs assign. Defaults to `'error'` when
|
|
16
|
+
* omitted.
|
|
17
|
+
*/
|
|
18
|
+
severity?: 'error' | 'warn';
|
|
19
|
+
/**
|
|
20
|
+
* Provider grouping. With `recommended: true` the rule also lands in the
|
|
21
|
+
* `<category>/recommended` config (`aws/recommended` is the only one built
|
|
22
|
+
* today).
|
|
23
|
+
*/
|
|
24
|
+
category?: string;
|
|
25
|
+
appliesTo?: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A rule seen through the metadata its readers need: the generated config
|
|
29
|
+
* tiers and the generated rule index. Structural rather than the full
|
|
30
|
+
* `OpenTofuRuleDefinition`, because the rule barrel's entries are
|
|
31
|
+
* heterogeneous generic instantiations with differing `MessageIds` unions.
|
|
32
|
+
*/
|
|
33
|
+
export interface RuleWithDocs {
|
|
34
|
+
/** Rule metadata. Optional so a stub or partial rule still type-checks. */
|
|
35
|
+
meta?: {
|
|
36
|
+
/** The block driving config tiers and the generated docs. */
|
|
37
|
+
docs?: LintofuRuleDocs;
|
|
38
|
+
/**
|
|
39
|
+
* Set by a rule that ships a fixer. Mirrors eslint's own `meta.fixable`;
|
|
40
|
+
* the generated rule index reports it as the fixable column.
|
|
41
|
+
*/
|
|
42
|
+
fixable?: 'code' | 'whitespace';
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Resolves the severity a rule is applied at, supplying the `'error'` default
|
|
47
|
+
* that {@link LintofuRuleDocs.severity} documents for a rule omitting it.
|
|
48
|
+
*
|
|
49
|
+
* Both generated config tiers and the generated rule index read severity
|
|
50
|
+
* through this function, so the documented severity cannot disagree with the
|
|
51
|
+
* severity the shipped configs assign (adr 0002, adr 0007).
|
|
52
|
+
*
|
|
53
|
+
* @param docs - a rule's `meta.docs`, absent when the rule declares none.
|
|
54
|
+
* @returns the resolved severity.
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolveRuleSeverity(docs: LintofuRuleDocs | undefined): 'error' | 'warn';
|
|
57
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/rules/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,2EAA2E;IAC3E,IAAI,CAAC,EAAE;QACL,6DAA6D;QAC7D,IAAI,CAAC,EAAE,eAAe,CAAC;QACvB;;;WAGG;QACH,OAAO,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;KACjC,CAAC;CACH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,eAAe,GAAG,SAAS,GAChC,OAAO,GAAG,MAAM,CAElB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the severity a rule is applied at, supplying the `'error'` default
|
|
3
|
+
* that {@link LintofuRuleDocs.severity} documents for a rule omitting it.
|
|
4
|
+
*
|
|
5
|
+
* Both generated config tiers and the generated rule index read severity
|
|
6
|
+
* through this function, so the documented severity cannot disagree with the
|
|
7
|
+
* severity the shipped configs assign (adr 0002, adr 0007).
|
|
8
|
+
*
|
|
9
|
+
* @param docs - a rule's `meta.docs`, absent when the rule declares none.
|
|
10
|
+
* @returns the resolved severity.
|
|
11
|
+
*/
|
|
12
|
+
export function resolveRuleSeverity(docs) {
|
|
13
|
+
return docs?.severity ?? 'error';
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/rules/types.ts"],"names":[],"mappings":"AA8CA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAiC;IAEjC,OAAO,IAAI,EAAE,QAAQ,IAAI,OAAO,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { FileProblem, SourceLocation, SourceRange, TraversalStep } from '@eslint/core';
|
|
2
|
+
import { Directive, TextSourceCodeBase } from '@eslint/plugin-kit';
|
|
3
|
+
import type { Body, Comment, Range } from './parser/types.js';
|
|
4
|
+
import { type ProjectIndex } from './project-index.js';
|
|
5
|
+
/** what a rule gets from `context.sourceCode.parserServices`. */
|
|
6
|
+
export interface TofuParserServices {
|
|
7
|
+
/** index over the linted file's module directory. see {@link ProjectIndex}. */
|
|
8
|
+
projectIndex: ProjectIndex;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* base shape every ast node satisfies: a `type` discriminator plus a source
|
|
12
|
+
* {@link Range}. no index signature on purpose: it would break structural
|
|
13
|
+
* compatibility with the concrete node interfaces (Block, Attribute, ...);
|
|
14
|
+
* generic walkers cast to `Record<string, unknown>` locally instead. not a
|
|
15
|
+
* root export: rules meet it as the node parameter type in
|
|
16
|
+
* OpenTofuRuleDefinition.
|
|
17
|
+
*/
|
|
18
|
+
export interface TofuNode {
|
|
19
|
+
type: string;
|
|
20
|
+
range: Range;
|
|
21
|
+
}
|
|
22
|
+
interface TofuSourceCodeOptions {
|
|
23
|
+
LangOptions: Record<string, unknown>;
|
|
24
|
+
RootNode: Body;
|
|
25
|
+
SyntaxElementWithLoc: TofuNode;
|
|
26
|
+
ConfigNode: Comment;
|
|
27
|
+
}
|
|
28
|
+
/** the source code object rules receive as `context.sourceCode`. */
|
|
29
|
+
export declare class OpenTofuSourceCode extends TextSourceCodeBase<TofuSourceCodeOptions> {
|
|
30
|
+
#private;
|
|
31
|
+
/**
|
|
32
|
+
* every comment in the file, in source order. comments are not ast nodes
|
|
33
|
+
* and never appear in {@link OpenTofuSourceCode.traverse}; see
|
|
34
|
+
* {@link Comment}.
|
|
35
|
+
*/
|
|
36
|
+
readonly comments: Comment[];
|
|
37
|
+
/**
|
|
38
|
+
* builds a source code object from the parse output: raw text, ast,
|
|
39
|
+
* comments, and the module directory the file lives in.
|
|
40
|
+
*/
|
|
41
|
+
constructor({ text, ast, comments, moduleDir, }: {
|
|
42
|
+
text: string;
|
|
43
|
+
ast: Body;
|
|
44
|
+
comments?: Comment[];
|
|
45
|
+
moduleDir?: string;
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* builds eslint disable directives from the file's comments. an
|
|
49
|
+
* `eslint-disable-line` comment spanning multiple lines is reported as a
|
|
50
|
+
* file problem instead of becoming a directive.
|
|
51
|
+
*/
|
|
52
|
+
getDisableDirectives(): {
|
|
53
|
+
directives: Directive[];
|
|
54
|
+
problems: FileProblem[];
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* the comments that parse as disable/enable directives; what
|
|
58
|
+
* `noInlineConfig` reports.
|
|
59
|
+
*/
|
|
60
|
+
getInlineConfigNodes(): Comment[];
|
|
61
|
+
/**
|
|
62
|
+
* services exposed to rules, built lazily and cached per file. when the
|
|
63
|
+
* file has no physical path (stdin, virtual files) there is no module
|
|
64
|
+
* directory, so rules get an empty index: `findResource` and
|
|
65
|
+
* `resolveTraversal` always return `undefined`, `resourcesByType` always
|
|
66
|
+
* returns `[]`.
|
|
67
|
+
*/
|
|
68
|
+
get parserServices(): TofuParserServices;
|
|
69
|
+
/**
|
|
70
|
+
* maps a node's {@link Range} to an eslint SourceLocation (1-indexed
|
|
71
|
+
* line/column).
|
|
72
|
+
*/
|
|
73
|
+
getLoc(node: TofuNode): SourceLocation;
|
|
74
|
+
/** maps a node's {@link Range} to eslint's `[start, end]` byte offsets. */
|
|
75
|
+
getRange(node: TofuNode): SourceRange;
|
|
76
|
+
/**
|
|
77
|
+
* yields enter/exit steps for every visitable node. ObjectConsItem pairs
|
|
78
|
+
* have no `type` field and are descended out-of-band: the item itself is
|
|
79
|
+
* never yielded, its `keyExpr` and `valueExpr` are.
|
|
80
|
+
*/
|
|
81
|
+
traverse(): Generator<TraversalStep>;
|
|
82
|
+
}
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=source-code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-code.d.ts","sourceRoot":"","sources":["../src/source-code.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,cAAc,EACd,WAAW,EACX,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,SAAS,EACT,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAY,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA0CxE,iEAAiE;AACjE,MAAM,WAAW,kBAAkB;IACjC,+EAA+E;IAC/E,YAAY,EAAE,YAAY,CAAC;CAC5B;AAQD;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;CACd;AAED,UAAU,qBAAqB;IAC7B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,EAAE,IAAI,CAAC;IACf,oBAAoB,EAAE,QAAQ,CAAC;IAC/B,UAAU,EAA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