@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,170 @@
|
|
|
1
|
+
import { ConfigCommentParser, Directive, TextSourceCodeBase, VisitNodeStep, } from '@eslint/plugin-kit';
|
|
2
|
+
import { getProjectIndex } from './project-index.js';
|
|
3
|
+
import { visitorKeys } from './visitor-keys.js';
|
|
4
|
+
const commentParser = new ConfigCommentParser();
|
|
5
|
+
// Maps a parsed directive label to its ESLint directive type. A comment is
|
|
6
|
+
// only a disable directive if its label is one of these keys.
|
|
7
|
+
const DIRECTIVE_TYPES = {
|
|
8
|
+
'eslint-disable': 'disable',
|
|
9
|
+
'eslint-enable': 'enable',
|
|
10
|
+
'eslint-disable-line': 'disable-line',
|
|
11
|
+
'eslint-disable-next-line': 'disable-next-line',
|
|
12
|
+
};
|
|
13
|
+
// Strips the comment delimiter so the remaining text is what
|
|
14
|
+
// ConfigCommentParser expects: `#` is one char, `//` and `/* */` are two.
|
|
15
|
+
function stripDelimiter(comment) {
|
|
16
|
+
if (comment.kind === 'block') {
|
|
17
|
+
return comment.value.slice(2, -2);
|
|
18
|
+
}
|
|
19
|
+
return comment.value.startsWith('//')
|
|
20
|
+
? comment.value.slice(2)
|
|
21
|
+
: comment.value.slice(1);
|
|
22
|
+
}
|
|
23
|
+
function spansMultipleLines(comment) {
|
|
24
|
+
return comment.range.start.line !== comment.range.end.line;
|
|
25
|
+
}
|
|
26
|
+
// Returns the disable-directive details for a comment, or undefined if it is
|
|
27
|
+
// not a disable/enable directive. Shared by getDisableDirectives (to build
|
|
28
|
+
// directives) and getInlineConfigNodes (to flag them under noInlineConfig).
|
|
29
|
+
function parseDisableDirective(comment) {
|
|
30
|
+
const parsed = commentParser.parseDirective(stripDelimiter(comment));
|
|
31
|
+
if (!parsed)
|
|
32
|
+
return undefined;
|
|
33
|
+
const type = DIRECTIVE_TYPES[parsed.label];
|
|
34
|
+
if (!type)
|
|
35
|
+
return undefined;
|
|
36
|
+
return { type, value: parsed.value, justification: parsed.justification };
|
|
37
|
+
}
|
|
38
|
+
const EMPTY_INDEX = {
|
|
39
|
+
findResource: () => undefined,
|
|
40
|
+
resolveTraversal: () => undefined,
|
|
41
|
+
resourcesByType: () => [],
|
|
42
|
+
};
|
|
43
|
+
/** the source code object rules receive as `context.sourceCode`. */
|
|
44
|
+
export class OpenTofuSourceCode extends TextSourceCodeBase {
|
|
45
|
+
#moduleDir;
|
|
46
|
+
/**
|
|
47
|
+
* every comment in the file, in source order. comments are not ast nodes
|
|
48
|
+
* and never appear in {@link OpenTofuSourceCode.traverse}; see
|
|
49
|
+
* {@link Comment}.
|
|
50
|
+
*/
|
|
51
|
+
comments;
|
|
52
|
+
#cachedServices;
|
|
53
|
+
/**
|
|
54
|
+
* builds a source code object from the parse output: raw text, ast,
|
|
55
|
+
* comments, and the module directory the file lives in.
|
|
56
|
+
*/
|
|
57
|
+
constructor({ text, ast, comments = [], moduleDir, }) {
|
|
58
|
+
super({ text, ast });
|
|
59
|
+
this.comments = comments;
|
|
60
|
+
this.#moduleDir = moduleDir;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* builds eslint disable directives from the file's comments. an
|
|
64
|
+
* `eslint-disable-line` comment spanning multiple lines is reported as a
|
|
65
|
+
* file problem instead of becoming a directive.
|
|
66
|
+
*/
|
|
67
|
+
getDisableDirectives() {
|
|
68
|
+
const directives = [];
|
|
69
|
+
const problems = [];
|
|
70
|
+
for (const comment of this.comments) {
|
|
71
|
+
const directive = parseDisableDirective(comment);
|
|
72
|
+
if (!directive)
|
|
73
|
+
continue;
|
|
74
|
+
const { type, value, justification } = directive;
|
|
75
|
+
if (type === 'disable-line' && spansMultipleLines(comment)) {
|
|
76
|
+
problems.push({
|
|
77
|
+
ruleId: null,
|
|
78
|
+
message: 'eslint-disable-line comment should not span multiple lines.',
|
|
79
|
+
loc: this.getLoc(comment),
|
|
80
|
+
});
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
directives.push(new Directive({ type, node: comment, value, justification }));
|
|
84
|
+
}
|
|
85
|
+
return { directives, problems };
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* the comments that parse as disable/enable directives; what
|
|
89
|
+
* `noInlineConfig` reports.
|
|
90
|
+
*/
|
|
91
|
+
getInlineConfigNodes() {
|
|
92
|
+
return this.comments.filter((c) => parseDisableDirective(c) !== undefined);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* services exposed to rules, built lazily and cached per file. when the
|
|
96
|
+
* file has no physical path (stdin, virtual files) there is no module
|
|
97
|
+
* directory, so rules get an empty index: `findResource` and
|
|
98
|
+
* `resolveTraversal` always return `undefined`, `resourcesByType` always
|
|
99
|
+
* returns `[]`.
|
|
100
|
+
*/
|
|
101
|
+
get parserServices() {
|
|
102
|
+
if (this.#cachedServices)
|
|
103
|
+
return this.#cachedServices;
|
|
104
|
+
const projectIndex = this.#moduleDir
|
|
105
|
+
? getProjectIndex(this.#moduleDir)
|
|
106
|
+
: EMPTY_INDEX;
|
|
107
|
+
this.#cachedServices = { projectIndex };
|
|
108
|
+
return this.#cachedServices;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* maps a node's {@link Range} to an eslint SourceLocation (1-indexed
|
|
112
|
+
* line/column).
|
|
113
|
+
*/
|
|
114
|
+
getLoc(node) {
|
|
115
|
+
return {
|
|
116
|
+
start: { line: node.range.start.line, column: node.range.start.column },
|
|
117
|
+
end: { line: node.range.end.line, column: node.range.end.column },
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** maps a node's {@link Range} to eslint's `[start, end]` byte offsets. */
|
|
121
|
+
getRange(node) {
|
|
122
|
+
return [node.range.start.offset, node.range.end.offset];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* yields enter/exit steps for every visitable node. ObjectConsItem pairs
|
|
126
|
+
* have no `type` field and are descended out-of-band: the item itself is
|
|
127
|
+
* never yielded, its `keyExpr` and `valueExpr` are.
|
|
128
|
+
*/
|
|
129
|
+
*traverse() {
|
|
130
|
+
yield* visitNode(this.ast);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function* visitNode(node) {
|
|
134
|
+
// args MUST be [node], not []. ESLint's traverser does
|
|
135
|
+
// `step.args ?? [step.target]` — a truthy empty array skips the
|
|
136
|
+
// fallback and the rule visitor receives no arguments.
|
|
137
|
+
yield new VisitNodeStep({ target: node, phase: 1, args: [node] });
|
|
138
|
+
if (node.type === 'ObjectConsExpr') {
|
|
139
|
+
// ObjectConsItem has no `type` discriminator — descend into each
|
|
140
|
+
// pair's keyExpr/valueExpr directly rather than treating items as nodes.
|
|
141
|
+
const items = node.items;
|
|
142
|
+
for (const item of items) {
|
|
143
|
+
yield* visitNode(item.keyExpr);
|
|
144
|
+
yield* visitNode(item.valueExpr);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
const keys = visitorKeys[node.type];
|
|
149
|
+
const indexed = node;
|
|
150
|
+
for (const key of keys) {
|
|
151
|
+
const child = indexed[key];
|
|
152
|
+
if (Array.isArray(child)) {
|
|
153
|
+
for (const c of child) {
|
|
154
|
+
if (isTofuNode(c))
|
|
155
|
+
yield* visitNode(c);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else if (isTofuNode(child)) {
|
|
159
|
+
yield* visitNode(child);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
yield new VisitNodeStep({ target: node, phase: 2, args: [node] });
|
|
164
|
+
}
|
|
165
|
+
function isTofuNode(value) {
|
|
166
|
+
return (typeof value === 'object' &&
|
|
167
|
+
value !== null &&
|
|
168
|
+
typeof value.type === 'string');
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=source-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-code.js","sourceRoot":"","sources":["../src/source-code.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,kBAAkB,EAClB,aAAa,GACd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,eAAe,EAAqB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,aAAa,GAAG,IAAI,mBAAmB,EAAE,CAAC;AAEhD,2EAA2E;AAC3E,8DAA8D;AAC9D,MAAM,eAAe,GAAkC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,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAAiC,CAAC,IAAI,KAAK,QAAQ,CAC5D,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { RuleDefinition } from '@eslint/core';
|
|
2
|
+
import type { Attribute, Block, Body, Expression, Traverser } from './parser/types.js';
|
|
3
|
+
import type { LintofuRuleDocs } from './rules/types.js';
|
|
4
|
+
import type { OpenTofuSourceCode, TofuNode } from './source-code.js';
|
|
5
|
+
export type { Attribute, Block, Body, Expression, LiteralValueExpr, ObjectConsExpr, ObjectConsItem, ObjectConsKeyExpr, Range, ScopeTraversalExpr, TemplateExpr, TemplateWrapExpr, TraverseAttr, Traverser, TraverseRoot, UnknownExpr, } from './parser/types.js';
|
|
6
|
+
export type { ProjectIndex, ResourceAddress } from './project-index.js';
|
|
7
|
+
export type { LintofuRuleDocs } from './rules/types.js';
|
|
8
|
+
export type { OpenTofuSourceCode, TofuParserServices } from './source-code.js';
|
|
9
|
+
type TofuVisitableNode = Body | Block | Attribute | Expression | Traverser;
|
|
10
|
+
/**
|
|
11
|
+
* the visitor object a rule's `create` returns. keys are node type names,
|
|
12
|
+
* values are visit functions typed to the narrowed node. covers every node
|
|
13
|
+
* {@link OpenTofuSourceCode.traverse} yields; there is no `ObjectConsItem`
|
|
14
|
+
* key because ObjectConsItem has no `type` field, so traverse() descends
|
|
15
|
+
* into its `keyExpr`/`valueExpr` out-of-band instead of yielding the item.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const visitor: OpenTofuRuleVisitor = {
|
|
20
|
+
* Block(node) {
|
|
21
|
+
* console.log(node.kind, node.labels);
|
|
22
|
+
* },
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type OpenTofuRuleVisitor = {
|
|
27
|
+
[N in TofuVisitableNode as N['type']]?: (node: N) => void;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* the shape of a lintofu rule. pins `context.sourceCode` to
|
|
31
|
+
* {@link OpenTofuSourceCode}, docs metadata to {@link LintofuRuleDocs}, the
|
|
32
|
+
* visitor to {@link OpenTofuRuleVisitor}, and the node type to TofuNode
|
|
33
|
+
* (not a root export; rules meet it only through this definition). the
|
|
34
|
+
* `Options` generic carries `RuleOptions` and `MessageIds`.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const rule: OpenTofuRuleDefinition = {
|
|
39
|
+
* meta: {
|
|
40
|
+
* docs: { description: 'disallow foo blocks', recommended: true },
|
|
41
|
+
* messages: { noFoo: 'no foo blocks' },
|
|
42
|
+
* },
|
|
43
|
+
* create(context) {
|
|
44
|
+
* return {
|
|
45
|
+
* Block(node) {
|
|
46
|
+
* if (node.kind === 'foo') {
|
|
47
|
+
* context.report({ node, messageId: 'noFoo' });
|
|
48
|
+
* }
|
|
49
|
+
* },
|
|
50
|
+
* };
|
|
51
|
+
* },
|
|
52
|
+
* };
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export type OpenTofuRuleDefinition<Options extends {
|
|
56
|
+
RuleOptions?: unknown[];
|
|
57
|
+
MessageIds?: string;
|
|
58
|
+
} = Record<string, never>> = RuleDefinition<{
|
|
59
|
+
LangOptions: Record<string, unknown>;
|
|
60
|
+
Code: OpenTofuSourceCode;
|
|
61
|
+
Visitor: OpenTofuRuleVisitor;
|
|
62
|
+
Node: TofuNode;
|
|
63
|
+
RuleOptions: Options['RuleOptions'] extends unknown[] ? Options['RuleOptions'] : [];
|
|
64
|
+
MessageIds: Options['MessageIds'] extends string ? Options['MessageIds'] : string;
|
|
65
|
+
ExtRuleDocs: LintofuRuleDocs;
|
|
66
|
+
}>;
|
|
67
|
+
//# sourceMappingURL=types.d.ts.map
|
|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AAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IACvB,cAAc,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,OAAO,CAAC,aAAa,CAAC,SAAS,OAAO,EAAE,GACjD,OAAO,CAAC,aAAa,CAAC,GACtB,EAAE,CAAC;IACP,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,SAAS,MAAM,GAC5C,OAAO,CAAC,YAAY,CAAC,GACrB,MAAM,CAAC;IACX,WAAW,EAAE,eAAe,CAAC;CAC9B,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor-keys.d.ts","sourceRoot":"","sources":["../src/visitor-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAMlD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAwB3D,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// The Record<NodeType, ...> constraint makes this exhaustive at compile
|
|
2
|
+
// time: adding to NodeType without an entry here is a type error.
|
|
3
|
+
// ObjectConsExpr lists "items" but those entries lack a `type` field;
|
|
4
|
+
// traverse() handles them out-of-band.
|
|
5
|
+
export const visitorKeys = {
|
|
6
|
+
Body: ['blocks', 'attributes'],
|
|
7
|
+
Block: ['body'],
|
|
8
|
+
Attribute: ['expression'],
|
|
9
|
+
TemplateExpr: ['parts'],
|
|
10
|
+
TemplateWrapExpr: ['wrapped'],
|
|
11
|
+
FunctionCallExpr: ['args'],
|
|
12
|
+
ScopeTraversalExpr: ['traversal'],
|
|
13
|
+
ObjectConsExpr: ['items'],
|
|
14
|
+
ObjectConsKeyExpr: ['wrapped'],
|
|
15
|
+
TupleConsExpr: ['exprs'],
|
|
16
|
+
ConditionalExpr: ['condition', 'trueResult', 'falseResult'],
|
|
17
|
+
ForExpr: ['collExpr', 'keyExpr', 'valExpr', 'condExpr'],
|
|
18
|
+
SplatExpr: ['source', 'each'],
|
|
19
|
+
IndexExpr: ['collection', 'key'],
|
|
20
|
+
RelativeTraversalExpr: ['source'],
|
|
21
|
+
ParenthesesExpr: ['expression'],
|
|
22
|
+
BinaryOpExpr: ['lhs', 'rhs'],
|
|
23
|
+
UnaryOpExpr: ['operand'],
|
|
24
|
+
LiteralValueExpr: [],
|
|
25
|
+
UnknownExpr: [],
|
|
26
|
+
TraverseRoot: [],
|
|
27
|
+
TraverseAttr: [],
|
|
28
|
+
TraverseIndex: [],
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=visitor-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor-keys.js","sourceRoot":"","sources":["../src/visitor-keys.ts"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,kEAAkE;AAClE,sEAAsE;AACtE,uCAAuC;AACvC,MAAM,CAAC,MAAM,WAAW,GAAwC;IAC9D,IAAI,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC;IAC9B,KAAK,EAAE,CAAC,MAAM,CAAC;IACf,SAAS,EAAE,CAAC,YAAY,CAAC;IACzB,YAAY,EAAE,CAAC,OAAO,CAAC;IACvB,gBAAgB,EAAE,CAAC,SAAS,CAAC;IAC7B,gBAAgB,EAAE,CAAC,MAAM,CAAC;IAC1B,kBAAkB,EAAE,CAAC,WAAW,CAAC;IACjC,cAAc,EAAE,CAAC,OAAO,CAAC;IACzB,iBAAiB,EAAE,CAAC,SAAS,CAAC;IAC9B,aAAa,EAAE,CAAC,OAAO,CAAC;IACxB,eAAe,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC;IAC3D,OAAO,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC;IACvD,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC;IAChC,qBAAqB,EAAE,CAAC,QAAQ,CAAC;IACjC,eAAe,EAAE,CAAC,YAAY,CAAC;IAC/B,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAC5B,WAAW,EAAE,CAAC,SAAS,CAAC;IACxB,gBAAgB,EAAE,EAAE;IACpB,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,EAAE;IAChB,aAAa,EAAE,EAAE;CAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,90 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synapsestudios/lintofu",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.9.1",
|
|
4
|
+
"description": "ESLint plugin for linting OpenTofu configurations",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/synapsestudios/lintofu.git"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": "^20.19.0 || ^22.13.0 || >=24"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build:wasm": "bash scripts/build-wasm.sh",
|
|
31
|
+
"build:js": "tsc",
|
|
32
|
+
"build:assets": "mkdir -p dist/parser && cp src/parser/wasm-exec.cjs src/parser/lintofu-parser.wasm dist/parser/",
|
|
33
|
+
"build": "npm run build:wasm && npm run build:js && npm run build:assets",
|
|
34
|
+
"pretest": "npm run build:wasm",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:ci": "vitest run",
|
|
37
|
+
"test:watch": "vitest",
|
|
38
|
+
"typecheck": "tsc --noEmit -p tsconfig.test.json",
|
|
39
|
+
"lint": "eslint \"src/**/*.ts\" \"scripts/**/*.ts\" --fix",
|
|
40
|
+
"lint:ci": "eslint \"src/**/*.ts\" \"scripts/**/*.ts\"",
|
|
41
|
+
"format": "prettier --write \"src/**/*.ts\" \"scripts/**/*.{mjs,ts}\" \"vitest.config.ts\" \"docs/.vitepress/**/*.mts\"",
|
|
42
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"scripts/**/*.{mjs,ts}\" \"vitest.config.ts\" \"docs/.vitepress/**/*.mts\"",
|
|
43
|
+
"docs:versions": "node scripts/render-tested-versions.mjs",
|
|
44
|
+
"docs:versions:check": "node scripts/render-tested-versions.mjs --check",
|
|
45
|
+
"docs:rules": "tsx scripts/render-rule-index.ts",
|
|
46
|
+
"docs:rules:check": "tsx scripts/render-rule-index.ts --check",
|
|
47
|
+
"docs:dev": "vitepress dev docs",
|
|
48
|
+
"docs:build": "vitepress build docs",
|
|
49
|
+
"docs:preview": "vitepress preview docs",
|
|
50
|
+
"clean": "rm -rf dist",
|
|
51
|
+
"prepare": "lefthook install || true",
|
|
52
|
+
"prepublishOnly": "npm run build"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"eslint": "^9.0.0 || ^10.0.0"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@eslint/core": "^1.2.1",
|
|
59
|
+
"@eslint/plugin-kit": "^0.7.2"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@eslint/js": "^10.0.1",
|
|
63
|
+
"@types/node": "^26.6.6",
|
|
64
|
+
"eslint": "^10.14.0",
|
|
65
|
+
"eslint-config-prettier": "^10.1.8",
|
|
66
|
+
"eslint-plugin-eslint-plugin": "^7.6.2",
|
|
67
|
+
"eslint-plugin-jsdoc": "^65.4.2",
|
|
68
|
+
"eslint-plugin-prettier": "^5.5.7",
|
|
69
|
+
"eslint-plugin-security": "^4.2.1",
|
|
70
|
+
"eslint-plugin-tsdoc": "^0.5.4",
|
|
71
|
+
"globals": "^17.13.0",
|
|
72
|
+
"lefthook": "^2.2.2",
|
|
73
|
+
"prettier": "^3.9.10",
|
|
74
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
75
|
+
"tsx": "^4.23.15",
|
|
76
|
+
"typescript": "^6.0.3",
|
|
77
|
+
"typescript-eslint": "^8.72.1",
|
|
78
|
+
"vitepress": "^1.6.4",
|
|
79
|
+
"vitest": "^5.0.5"
|
|
80
|
+
},
|
|
81
|
+
"keywords": [
|
|
82
|
+
"eslint",
|
|
83
|
+
"eslint-plugin",
|
|
84
|
+
"eslintplugin",
|
|
85
|
+
"opentofu",
|
|
86
|
+
"terraform",
|
|
87
|
+
"hcl",
|
|
88
|
+
"linting"
|
|
89
|
+
]
|
|
90
|
+
}
|