@platformos/platformos-check-common 0.0.17 → 0.0.19
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/CHANGELOG.md +16 -0
- package/dist/checks/index.d.ts +1 -1
- package/dist/checks/index.js +6 -2
- package/dist/checks/index.js.map +1 -1
- package/dist/checks/json-literal-quote-style/index.d.ts +2 -0
- package/dist/checks/json-literal-quote-style/index.js +42 -0
- package/dist/checks/json-literal-quote-style/index.js.map +1 -0
- package/dist/checks/liquid-html-syntax-error/checks/InvalidAssignSyntax.d.ts +32 -0
- package/dist/checks/liquid-html-syntax-error/checks/InvalidAssignSyntax.js +93 -0
- package/dist/checks/liquid-html-syntax-error/checks/InvalidAssignSyntax.js.map +1 -0
- package/dist/checks/liquid-html-syntax-error/checks/InvalidOutputPush.d.ts +17 -0
- package/dist/checks/liquid-html-syntax-error/checks/InvalidOutputPush.js +37 -0
- package/dist/checks/liquid-html-syntax-error/checks/InvalidOutputPush.js.map +1 -0
- package/dist/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.js +1 -1
- package/dist/checks/liquid-html-syntax-error/index.js +25 -0
- package/dist/checks/liquid-html-syntax-error/index.js.map +1 -1
- package/dist/checks/partial-call-arguments/extract-undefined-variables.d.ts +14 -0
- package/dist/checks/partial-call-arguments/extract-undefined-variables.js +234 -0
- package/dist/checks/partial-call-arguments/extract-undefined-variables.js.map +1 -0
- package/dist/checks/partial-call-arguments/index.d.ts +2 -0
- package/dist/checks/partial-call-arguments/index.js +117 -0
- package/dist/checks/partial-call-arguments/index.js.map +1 -0
- package/dist/checks/unused-assign/index.js +17 -0
- package/dist/checks/unused-assign/index.js.map +1 -1
- package/dist/checks/valid-frontmatter/index.d.ts +2 -0
- package/dist/checks/valid-frontmatter/index.js +279 -0
- package/dist/checks/valid-frontmatter/index.js.map +1 -0
- package/dist/frontmatter/index.d.ts +1 -59
- package/dist/frontmatter/index.js +6 -298
- package/dist/frontmatter/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/checks/index.ts +6 -2
- package/src/checks/json-literal-quote-style/index.spec.ts +129 -0
- package/src/checks/json-literal-quote-style/index.ts +45 -0
- package/src/checks/liquid-html-syntax-error/checks/InvalidAssignSyntax.spec.ts +471 -0
- package/src/checks/liquid-html-syntax-error/checks/InvalidAssignSyntax.ts +97 -0
- package/src/checks/liquid-html-syntax-error/checks/InvalidOutputPush.spec.ts +104 -0
- package/src/checks/liquid-html-syntax-error/checks/InvalidOutputPush.ts +39 -0
- package/src/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.spec.ts +86 -2
- package/src/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.ts +1 -1
- package/src/checks/liquid-html-syntax-error/index.ts +30 -0
- package/src/checks/partial-call-arguments/extract-undefined-variables.spec.ts +218 -0
- package/src/checks/{metadata-params → partial-call-arguments}/extract-undefined-variables.ts +31 -6
- package/src/checks/partial-call-arguments/index.spec.ts +436 -0
- package/src/checks/{metadata-params → partial-call-arguments}/index.ts +18 -11
- package/src/checks/undefined-object/index.spec.ts +101 -0
- package/src/checks/unused-assign/index.spec.ts +48 -0
- package/src/checks/unused-assign/index.ts +15 -0
- package/src/checks/valid-frontmatter/index.spec.ts +666 -0
- package/src/checks/valid-frontmatter/index.ts +344 -0
- package/src/frontmatter/index.ts +9 -344
- package/src/checks/metadata-params/extract-undefined-variables.spec.ts +0 -115
- package/src/checks/metadata-params/index.spec.ts +0 -257
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @platformos/theme-check-common
|
|
2
2
|
|
|
3
|
+
## 0.0.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Improved checks
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @platformos/liquid-html-parser@0.0.17
|
|
10
|
+
|
|
11
|
+
## 0.0.18
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Additional checks and improvements
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @platformos/liquid-html-parser@0.0.16
|
|
18
|
+
|
|
3
19
|
## 0.0.17
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/checks/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export declare const allChecks: (LiquidCheckDefinition | JSONCheckDefinition | G
|
|
|
5
5
|
* - meta.docs.recommended: true
|
|
6
6
|
* - Either no meta.targets list exist or if it does exist then Recommended is a target
|
|
7
7
|
*/
|
|
8
|
-
export declare const recommended: (LiquidCheckDefinition | JSONCheckDefinition |
|
|
8
|
+
export declare const recommended: (LiquidCheckDefinition | JSONCheckDefinition | GraphQLCheckDefinition | YAMLCheckDefinition)[];
|
package/dist/checks/index.js
CHANGED
|
@@ -26,7 +26,7 @@ const valid_json_1 = require("./valid-json");
|
|
|
26
26
|
const valid_doc_param_types_1 = require("./valid-doc-param-types");
|
|
27
27
|
const valid_render_partial_argument_types_1 = require("./valid-render-partial-argument-types");
|
|
28
28
|
const variable_name_1 = require("./variable-name");
|
|
29
|
-
const
|
|
29
|
+
const partial_call_arguments_1 = require("./partial-call-arguments");
|
|
30
30
|
const graphql_variables_1 = require("./graphql-variables");
|
|
31
31
|
const graphql_1 = require("./graphql");
|
|
32
32
|
const unknown_property_1 = require("./unknown-property");
|
|
@@ -35,6 +35,8 @@ const duplicate_function_arguments_1 = require("./duplicate-function-arguments")
|
|
|
35
35
|
const missing_render_partial_arguments_1 = require("./missing-render-partial-arguments");
|
|
36
36
|
const nested_graphql_query_1 = require("./nested-graphql-query");
|
|
37
37
|
const missing_page_1 = require("./missing-page");
|
|
38
|
+
const valid_frontmatter_1 = require("./valid-frontmatter");
|
|
39
|
+
const json_literal_quote_style_1 = require("./json-literal-quote-style");
|
|
38
40
|
exports.allChecks = [
|
|
39
41
|
deprecated_filter_1.DeprecatedFilter,
|
|
40
42
|
deprecated_tag_1.DeprecatedTag,
|
|
@@ -61,7 +63,7 @@ exports.allChecks = [
|
|
|
61
63
|
valid_doc_param_types_1.ValidDocParamTypes,
|
|
62
64
|
valid_render_partial_argument_types_1.ValidRenderPartialArgumentTypes,
|
|
63
65
|
variable_name_1.VariableName,
|
|
64
|
-
|
|
66
|
+
partial_call_arguments_1.PartialCallArguments,
|
|
65
67
|
graphql_variables_1.GraphQLVariablesCheck,
|
|
66
68
|
graphql_1.GraphQLCheck,
|
|
67
69
|
unknown_property_1.UnknownProperty,
|
|
@@ -69,6 +71,8 @@ exports.allChecks = [
|
|
|
69
71
|
missing_render_partial_arguments_1.MissingRenderPartialArguments,
|
|
70
72
|
nested_graphql_query_1.NestedGraphQLQuery,
|
|
71
73
|
missing_page_1.MissingPage,
|
|
74
|
+
valid_frontmatter_1.ValidFrontmatter,
|
|
75
|
+
json_literal_quote_style_1.JsonLiteralQuoteStyle,
|
|
72
76
|
];
|
|
73
77
|
/**
|
|
74
78
|
* The recommended checks is populated by all checks with the following conditions:
|
package/dist/checks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/checks/index.ts"],"names":[],"mappings":";;;AAAA,oCAMkB;AAElB,2DAAuD;AACvD,qDAAiD;AACjD,6FAAuF;AACvF,iEAA2D;AAC3D,2DAAsD;AACtD,yEAAmE;AACnE,mEAA+D;AAC/D,mDAA+C;AAC/C,uDAAmD;AACnD,yDAAqD;AACrD,qEAAgE;AAChE,qEAAgE;AAChE,mEAA8D;AAC9D,yDAAqD;AACrD,qEAA+D;AAC/D,qDAAiD;AACjD,mGAA6F;AAC7F,mDAA+C;AAC/C,yDAAoD;AACpD,qEAAgE;AAChE,6CAAyC;AACzC,mEAA6D;AAC7D,+FAAwF;AACxF,mDAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/checks/index.ts"],"names":[],"mappings":";;;AAAA,oCAMkB;AAElB,2DAAuD;AACvD,qDAAiD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;QACnB,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM;QAC1B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,oBAAY,CAAC,WAAW,CAAC,CAAC;IAExD,OAAO,aAAa,IAAI,aAAa,CAAC;AACxC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonLiteralQuoteStyle = void 0;
|
|
4
|
+
const liquid_html_parser_1 = require("@platformos/liquid-html-parser");
|
|
5
|
+
const types_1 = require("../../types");
|
|
6
|
+
exports.JsonLiteralQuoteStyle = {
|
|
7
|
+
meta: {
|
|
8
|
+
code: 'JsonLiteralQuoteStyle',
|
|
9
|
+
name: 'Use double quotes in JSON literals',
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'Enforces double-quoted string literals inside inline object/array literals (e.g. {% assign a = {"a": 5} %}). Single-quoted strings inside these literals are not valid JSON.',
|
|
12
|
+
recommended: true,
|
|
13
|
+
url: undefined,
|
|
14
|
+
},
|
|
15
|
+
type: types_1.SourceCodeType.LiquidHtml,
|
|
16
|
+
severity: types_1.Severity.ERROR,
|
|
17
|
+
schema: {},
|
|
18
|
+
targets: [],
|
|
19
|
+
},
|
|
20
|
+
create(context) {
|
|
21
|
+
return {
|
|
22
|
+
async String(node, ancestors) {
|
|
23
|
+
if (!node.single)
|
|
24
|
+
return;
|
|
25
|
+
// Only flag strings that are inside an inline object/array literal.
|
|
26
|
+
const insideJsonLiteral = ancestors.some((ancestor) => ancestor.type === liquid_html_parser_1.NodeTypes.JsonHashLiteral ||
|
|
27
|
+
ancestor.type === liquid_html_parser_1.NodeTypes.JsonArrayLiteral);
|
|
28
|
+
if (!insideJsonLiteral)
|
|
29
|
+
return;
|
|
30
|
+
context.report({
|
|
31
|
+
message: 'Use double quotes for string literals inside object/array literals (e.g. \'{"key": "value"}\', not "{\'key\': \'value\'}").',
|
|
32
|
+
startIndex: node.position.start,
|
|
33
|
+
endIndex: node.position.end,
|
|
34
|
+
fix: (corrector) => {
|
|
35
|
+
corrector.replace(node.position.start, node.position.end, JSON.stringify(node.value));
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/checks/json-literal-quote-style/index.ts"],"names":[],"mappings":";;;AAAA,uEAA2D;AAC3D,uCAA8E;AAEjE,QAAA,qBAAqB,GAA0B;IAC1D,IAAI,EAAE;QACJ,IAAI,EAAE,uBAAuB;QAC7B,IAAI,EAAE,oCAAoC;QAC1C,IAAI,EAAE;YACJ,WAAW,EACT,8KAA8K;YAChL,WAAW,EAAE,IAAI;YACjB,GAAG,EAAE,SAAS;SACf;QACD,IAAI,EAAE,sBAAc,CAAC,UAAU;QAC/B,QAAQ,EAAE,gBAAQ,CAAC,KAAK;QACxB,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,EAAE;KACZ;IAED,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS;gBAC1B,IAAI,CAAC,IAAI,CAAC,MAAM;oBAAE,OAAO;gBAEzB,oEAAoE;gBACpE,MAAM,iBAAiB,GAAG,SAAS,CAAC,IAAI,CACtC,CAAC,QAAQ,EAAE,EAAE,CACX,QAAQ,CAAC,IAAI,KAAK,8BAAS,CAAC,eAAe;oBAC3C,QAAQ,CAAC,IAAI,KAAK,8BAAS,CAAC,gBAAgB,CAC/C,CAAC;gBACF,IAAI,CAAC,iBAAiB;oBAAE,OAAO;gBAE/B,OAAO,CAAC,MAAM,CAAC;oBACb,OAAO,EACL,6HAA6H;oBAC/H,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK;oBAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG;oBAC3B,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE;wBACjB,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;oBACxF,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LiquidTag } from '@platformos/liquid-html-parser';
|
|
2
|
+
import { Problem, SourceCodeType } from '../../..';
|
|
3
|
+
/**
|
|
4
|
+
* Detects structurally-invalid `assign` tags that neither `MultipleAssignValues` nor
|
|
5
|
+
* `InvalidPipeSyntax`/`InvalidFilterName` catch:
|
|
6
|
+
*
|
|
7
|
+
* {% assign %} — empty markup
|
|
8
|
+
* {% assign x %} — target only, no operator
|
|
9
|
+
* {% assign x "var" %} — missing `=`
|
|
10
|
+
* {% assign = 'v' %} — missing target
|
|
11
|
+
* {% assign x = %} — empty RHS
|
|
12
|
+
* {% assign 'str' = 'v' %} — target is a literal
|
|
13
|
+
* {% assign x := 'v' %} — operator is not `=`
|
|
14
|
+
*
|
|
15
|
+
* When the strict grammar rule `liquidTagAssignMarkup` fails, the parser falls back to
|
|
16
|
+
* the base case and stores markup as a raw string. That string almost always still
|
|
17
|
+
* contains `=`-plus-RHS with a filter or pipe issue (handled elsewhere). This check
|
|
18
|
+
* targets the cases where the `target = value` skeleton itself is broken, so it
|
|
19
|
+
* complements rather than duplicates the other sub-checks.
|
|
20
|
+
*/
|
|
21
|
+
export declare function detectInvalidAssignSyntax(node: LiquidTag): Problem<SourceCodeType.LiquidHtml> | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Fallback for assign tags where the tolerant parser landed in string markup even
|
|
24
|
+
* though the `target = value` skeleton looks fine — meaning the value or filter
|
|
25
|
+
* chain has parse-breaking characters (e.g. a stray `}` before `%}`) that no other
|
|
26
|
+
* dedicated sub-check (MultipleAssignValues, InvalidFilterName, InvalidPipeSyntax)
|
|
27
|
+
* surfaced. Re-parses the tag source in strict mode and reports on failure.
|
|
28
|
+
*
|
|
29
|
+
* Must run ONLY when no other sub-check already reported on this tag, otherwise
|
|
30
|
+
* it double-flags the same problem. The orchestrator enforces that gate.
|
|
31
|
+
*/
|
|
32
|
+
export declare function detectInvalidAssignFallback(node: LiquidTag): Problem<SourceCodeType.LiquidHtml> | undefined;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectInvalidAssignSyntax = detectInvalidAssignSyntax;
|
|
4
|
+
exports.detectInvalidAssignFallback = detectInvalidAssignFallback;
|
|
5
|
+
const liquid_html_parser_1 = require("@platformos/liquid-html-parser");
|
|
6
|
+
const INVALID_ASSIGN_MESSAGE = `Invalid syntax for tag 'assign'. Expected syntax: {% assign <var> = <value> %}`;
|
|
7
|
+
/**
|
|
8
|
+
* Detects structurally-invalid `assign` tags that neither `MultipleAssignValues` nor
|
|
9
|
+
* `InvalidPipeSyntax`/`InvalidFilterName` catch:
|
|
10
|
+
*
|
|
11
|
+
* {% assign %} — empty markup
|
|
12
|
+
* {% assign x %} — target only, no operator
|
|
13
|
+
* {% assign x "var" %} — missing `=`
|
|
14
|
+
* {% assign = 'v' %} — missing target
|
|
15
|
+
* {% assign x = %} — empty RHS
|
|
16
|
+
* {% assign 'str' = 'v' %} — target is a literal
|
|
17
|
+
* {% assign x := 'v' %} — operator is not `=`
|
|
18
|
+
*
|
|
19
|
+
* When the strict grammar rule `liquidTagAssignMarkup` fails, the parser falls back to
|
|
20
|
+
* the base case and stores markup as a raw string. That string almost always still
|
|
21
|
+
* contains `=`-plus-RHS with a filter or pipe issue (handled elsewhere). This check
|
|
22
|
+
* targets the cases where the `target = value` skeleton itself is broken, so it
|
|
23
|
+
* complements rather than duplicates the other sub-checks.
|
|
24
|
+
*/
|
|
25
|
+
function detectInvalidAssignSyntax(node) {
|
|
26
|
+
if (node.name !== 'assign')
|
|
27
|
+
return;
|
|
28
|
+
if (typeof node.markup !== 'string')
|
|
29
|
+
return;
|
|
30
|
+
const markup = node.markup.trim();
|
|
31
|
+
const eqIndex = markup.indexOf('=');
|
|
32
|
+
const hasEquals = eqIndex !== -1;
|
|
33
|
+
const lhs = hasEquals ? markup.slice(0, eqIndex).trim() : markup;
|
|
34
|
+
const rhs = hasEquals ? markup.slice(eqIndex + 1).trim() : '';
|
|
35
|
+
const isStructurallyBroken = markup === '' || !hasEquals || lhs === '' || rhs === '' || !isValidAssignTarget(lhs);
|
|
36
|
+
if (!isStructurallyBroken)
|
|
37
|
+
return;
|
|
38
|
+
return {
|
|
39
|
+
message: INVALID_ASSIGN_MESSAGE,
|
|
40
|
+
startIndex: node.position.start,
|
|
41
|
+
endIndex: node.position.end,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Fallback for assign tags where the tolerant parser landed in string markup even
|
|
46
|
+
* though the `target = value` skeleton looks fine — meaning the value or filter
|
|
47
|
+
* chain has parse-breaking characters (e.g. a stray `}` before `%}`) that no other
|
|
48
|
+
* dedicated sub-check (MultipleAssignValues, InvalidFilterName, InvalidPipeSyntax)
|
|
49
|
+
* surfaced. Re-parses the tag source in strict mode and reports on failure.
|
|
50
|
+
*
|
|
51
|
+
* Must run ONLY when no other sub-check already reported on this tag, otherwise
|
|
52
|
+
* it double-flags the same problem. The orchestrator enforces that gate.
|
|
53
|
+
*/
|
|
54
|
+
function detectInvalidAssignFallback(node) {
|
|
55
|
+
if (node.name !== 'assign' || typeof node.markup !== 'string')
|
|
56
|
+
return;
|
|
57
|
+
// Digit-starting targets (e.g. `23_hours_ago`) are accepted by the platformOS
|
|
58
|
+
// runtime but rejected by the Ohm grammar's `variableSegment` rule. Skipping
|
|
59
|
+
// them here mirrors the intentional tolerance in isValidAssignTarget above.
|
|
60
|
+
if (/^\s*\d/.test(node.markup))
|
|
61
|
+
return;
|
|
62
|
+
const tagSource = node.source.slice(node.position.start, node.position.end);
|
|
63
|
+
try {
|
|
64
|
+
(0, liquid_html_parser_1.toLiquidAST)(tagSource, { mode: 'strict', allowUnclosedDocumentNode: true });
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return {
|
|
68
|
+
message: INVALID_ASSIGN_MESSAGE,
|
|
69
|
+
startIndex: node.position.start,
|
|
70
|
+
endIndex: node.position.end,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Rejects an LHS that is obviously not an assign target.
|
|
76
|
+
*
|
|
77
|
+
* NOTE: the parser's `variableSegment` rule is stricter than the platformOS runtime —
|
|
78
|
+
* Liquify (see assign_tag_test.rb "allow variable names to start with digit") accepts
|
|
79
|
+
* `23_hours_ago` as a valid name, but our grammar requires `(letter | "_")` at the
|
|
80
|
+
* start and falls back to the base case for digit-starting names. To avoid
|
|
81
|
+
* false-positive lint errors on code that runs fine, this shape check only rejects
|
|
82
|
+
* LHS forms that are never valid: literal delimiters at the start (`'`, `"`, `[`, `{`)
|
|
83
|
+
* and stray operator characters (`:` or a second `=`) that indicate the operator
|
|
84
|
+
* itself is malformed (e.g. `:=`).
|
|
85
|
+
*/
|
|
86
|
+
function isValidAssignTarget(lhs) {
|
|
87
|
+
if (/^['"[{]/.test(lhs))
|
|
88
|
+
return false;
|
|
89
|
+
if (/[:=]/.test(lhs))
|
|
90
|
+
return false;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=InvalidAssignSyntax.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvalidAssignSyntax.js","sourceRoot":"","sources":["../../../../src/checks/liquid-html-syntax-error/checks/InvalidAssignSyntax.ts"],"names":[],"mappings":";;AAuBA,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QAAQ;QAAE,OAAO;IAEtE,8EAA8E;IAC9E,6EAA6E;IAC7E,4EAA4E;IAC5E,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO;IAEvC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC5E,IAAI,CAAC;QACH,IAAA,gCAAW,EAAC,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,yBAAyB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,OAAO,EAAE,sBAAsB;YAC/B,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK;YAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG;SAC5B,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,mBAAmB,CAAC,GAAW;IACtC,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACnC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LiquidTag, LiquidVariableOutput } from '@platformos/liquid-html-parser';
|
|
2
|
+
import { Problem, SourceCodeType } from '../../..';
|
|
3
|
+
/**
|
|
4
|
+
* Detects misuse of the `<<` (array push) operator inside output positions:
|
|
5
|
+
*
|
|
6
|
+
* {{ arr << "el" }} — invalid
|
|
7
|
+
* {% echo arr << "el" %} — invalid
|
|
8
|
+
*
|
|
9
|
+
* `<<` is only accepted as the top-level operator in an assign tag:
|
|
10
|
+
*
|
|
11
|
+
* {% assign arr << "el" %} — valid (pushes "el" onto arr)
|
|
12
|
+
*
|
|
13
|
+
* Runtime rejects output-position push with a hard syntax error; this check
|
|
14
|
+
* mirrors that with a clearer, actionable message than the generic
|
|
15
|
+
* `InvalidEchoValue` fallback ("Syntax is not supported").
|
|
16
|
+
*/
|
|
17
|
+
export declare function detectInvalidOutputPush(node: LiquidTag | LiquidVariableOutput): Problem<SourceCodeType.LiquidHtml> | undefined;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectInvalidOutputPush = detectInvalidOutputPush;
|
|
4
|
+
const liquid_html_parser_1 = require("@platformos/liquid-html-parser");
|
|
5
|
+
const PUSH_OPERATOR_MESSAGE = "The '<<' (push) operator is only valid inside '{% assign target << value %}'. Remove it or move the expression into an assign tag.";
|
|
6
|
+
/**
|
|
7
|
+
* Detects misuse of the `<<` (array push) operator inside output positions:
|
|
8
|
+
*
|
|
9
|
+
* {{ arr << "el" }} — invalid
|
|
10
|
+
* {% echo arr << "el" %} — invalid
|
|
11
|
+
*
|
|
12
|
+
* `<<` is only accepted as the top-level operator in an assign tag:
|
|
13
|
+
*
|
|
14
|
+
* {% assign arr << "el" %} — valid (pushes "el" onto arr)
|
|
15
|
+
*
|
|
16
|
+
* Runtime rejects output-position push with a hard syntax error; this check
|
|
17
|
+
* mirrors that with a clearer, actionable message than the generic
|
|
18
|
+
* `InvalidEchoValue` fallback ("Syntax is not supported").
|
|
19
|
+
*/
|
|
20
|
+
function detectInvalidOutputPush(node) {
|
|
21
|
+
if (node.type === liquid_html_parser_1.NodeTypes.LiquidTag && node.name !== 'echo')
|
|
22
|
+
return;
|
|
23
|
+
const markup = node.markup;
|
|
24
|
+
if (typeof markup !== 'string' || !markup)
|
|
25
|
+
return;
|
|
26
|
+
// Strip quoted strings so literal `<<` inside a string doesn't trigger the check
|
|
27
|
+
// (e.g. `{{ "a << b" }}` is a harmless string with no push operator).
|
|
28
|
+
const stripped = markup.replace(/'[^']*'|"[^"]*"/g, '');
|
|
29
|
+
if (!/<</.test(stripped))
|
|
30
|
+
return;
|
|
31
|
+
return {
|
|
32
|
+
message: PUSH_OPERATOR_MESSAGE,
|
|
33
|
+
startIndex: node.position.start,
|
|
34
|
+
endIndex: node.position.end,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=InvalidOutputPush.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvalidOutputPush.js","sourceRoot":"","sources":["../../../../src/checks/liquid-html-syntax-error/checks/InvalidOutputPush.ts"],"names":[],"mappings":";;AAoBA,0DAkBC;AAtCD,uEAA4F;AAG5F,MAAM,qBAAqB,GACzB,oIAAoI,CAAC;AAEvI;;;;;;;;;;;;;GAaG;AACH,SAAgB,uBAAuB,CACrC,IAAsC;IAEtC,IAAI,IAAI,CAAC,IAAI,KAAK,8BAAS,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO;IAEtE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM;QAAE,OAAO;IAElD,iFAAiF;IACjF,sEAAsE;IACtE,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACxD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO;IAEjC,OAAO;QACL,OAAO,EAAE,qBAAqB;QAC9B,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK;QAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG;KAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -12,7 +12,7 @@ const TAGS_WITH_NO_EXPECTED_MARKUP = new Set(liquid_html_parser_1.TAGS_WITHOUT_M
|
|
|
12
12
|
* more specific error messages and autofixes. This check should NOT fire on these
|
|
13
13
|
* to avoid double-reporting or overriding their nuanced decisions.
|
|
14
14
|
*
|
|
15
|
-
* - assign → MultipleAssignValues, InvalidFilterName, InvalidPipeSyntax
|
|
15
|
+
* - assign → MultipleAssignValues, InvalidAssignSyntax, InvalidFilterName, InvalidPipeSyntax
|
|
16
16
|
* - echo → InvalidEchoValue, InvalidFilterName, InvalidPipeSyntax
|
|
17
17
|
* - if/elsif/unless → InvalidConditionalNode, InvalidConditionalNodeParenthesis
|
|
18
18
|
* - for/tablerow → InvalidLoopRange, InvalidLoopArguments
|
|
@@ -4,6 +4,7 @@ exports.LiquidHTMLSyntaxError = void 0;
|
|
|
4
4
|
const types_1 = require("../../types");
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const MultipleAssignValues_1 = require("./checks/MultipleAssignValues");
|
|
7
|
+
const InvalidAssignSyntax_1 = require("./checks/InvalidAssignSyntax");
|
|
7
8
|
const InvalidBooleanExpressions_1 = require("./checks/InvalidBooleanExpressions");
|
|
8
9
|
const InvalidEchoValue_1 = require("./checks/InvalidEchoValue");
|
|
9
10
|
const InvalidConditionalNode_1 = require("./checks/InvalidConditionalNode");
|
|
@@ -14,6 +15,7 @@ const InvalidFilterName_1 = require("./checks/InvalidFilterName");
|
|
|
14
15
|
const InvalidPipeSyntax_1 = require("./checks/InvalidPipeSyntax");
|
|
15
16
|
const UnknownTag_1 = require("./checks/UnknownTag");
|
|
16
17
|
const InvalidTagSyntax_1 = require("./checks/InvalidTagSyntax");
|
|
18
|
+
const InvalidOutputPush_1 = require("./checks/InvalidOutputPush");
|
|
17
19
|
const utils_2 = require("../utils");
|
|
18
20
|
function isParsingErrorWithLocation(error) {
|
|
19
21
|
return 'name' in error && error.name === 'LiquidHTMLParsingError' && 'loc' in error;
|
|
@@ -62,9 +64,17 @@ exports.LiquidHTMLSyntaxError = {
|
|
|
62
64
|
context.report(unknownTagProblem);
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
67
|
+
// Push-operator misuse in `{% echo … << … %}` — dedicated message.
|
|
68
|
+
// Short-circuit so InvalidEchoValue doesn't duplicate with a generic message.
|
|
69
|
+
const outputPushProblem = (0, InvalidOutputPush_1.detectInvalidOutputPush)(node);
|
|
70
|
+
if (outputPushProblem) {
|
|
71
|
+
context.report(outputPushProblem);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
65
74
|
// Run specific sub-checks first — they provide better error messages and autofixes.
|
|
66
75
|
const problems = [
|
|
67
76
|
(0, MultipleAssignValues_1.detectMultipleAssignValues)(node),
|
|
77
|
+
(0, InvalidAssignSyntax_1.detectInvalidAssignSyntax)(node),
|
|
68
78
|
(0, InvalidEchoValue_1.detectInvalidEchoValue)(node),
|
|
69
79
|
(0, InvalidLoopRange_1.detectInvalidLoopRange)(node),
|
|
70
80
|
(0, InvalidLoopArguments_1.detectInvalidLoopArguments)(node, tags),
|
|
@@ -92,6 +102,14 @@ exports.LiquidHTMLSyntaxError = {
|
|
|
92
102
|
if (pipeProblems.length > 0) {
|
|
93
103
|
pipeProblems.forEach((pipeProblem) => context.report(pipeProblem));
|
|
94
104
|
}
|
|
105
|
+
// Last-chance check for assign tags whose tolerant parse fell back to
|
|
106
|
+
// string markup (e.g. stray `}` before `%}`). Gated on "nothing else
|
|
107
|
+
// reported on this tag" to avoid double-flagging.
|
|
108
|
+
if (problems.length + filterProblems.length + pipeProblems.length === 0) {
|
|
109
|
+
const fallback = (0, InvalidAssignSyntax_1.detectInvalidAssignFallback)(node);
|
|
110
|
+
if (fallback)
|
|
111
|
+
context.report(fallback);
|
|
112
|
+
}
|
|
95
113
|
},
|
|
96
114
|
async LiquidBranch(node, ancestors) {
|
|
97
115
|
if ((0, utils_2.isWithinRawTagThatDoesNotParseItsContents)(ancestors))
|
|
@@ -105,6 +123,13 @@ exports.LiquidHTMLSyntaxError = {
|
|
|
105
123
|
async LiquidVariableOutput(node, ancestors) {
|
|
106
124
|
if ((0, utils_2.isWithinRawTagThatDoesNotParseItsContents)(ancestors))
|
|
107
125
|
return;
|
|
126
|
+
// Push-operator misuse in `{{ … << … }}` — dedicated message.
|
|
127
|
+
// Short-circuit so InvalidEchoValue doesn't duplicate with a generic message.
|
|
128
|
+
const outputPushProblem = (0, InvalidOutputPush_1.detectInvalidOutputPush)(node);
|
|
129
|
+
if (outputPushProblem) {
|
|
130
|
+
context.report(outputPushProblem);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
108
133
|
const filterProblems = await (0, InvalidFilterName_1.detectInvalidFilterName)(node, (await filtersPromise) ?? []);
|
|
109
134
|
if (filterProblems.length > 0) {
|
|
110
135
|
filterProblems.forEach((problem) => context.report(problem));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/checks/liquid-html-syntax-error/index.ts"],"names":[],"mappings":";;;AAAA,uCAAuF;AACvF,uCAAiD;AACjD,wEAA2E;AAC3E,kFAAqF;AACrF,gEAAmE;AACnE,4EAA+E;AAC/E,gEAAmE;AACnE,wEAA2E;AAC3E,kGAAyG;AACzG,kEAAqE;AACrE,kEAAqE;AACrE,oDAAuD;AACvD,gEAAmE;AACnE,oCAAqE;AAOrE,SAAS,0BAA0B,CACjC,KAAY;IAEZ,OAAO,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,wBAAwB,IAAI,KAAK,IAAI,KAAK,CAAC;AACtF,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAe,EAAE,SAAiB;IAC3D,OAAO,OAAO;SACX,OAAO,CAAC,uBAAuB,EAAE,eAAe,CAAC;SACjD,OAAO,CAAC,4BAA4B,EAAE,SAAS,SAAS,GAAG,CAAC,CAAC;AAClE,CAAC;AAEY,QAAA,qBAAqB,GAA0B;IAC1D,IAAI,EAAE;QACJ,IAAI,EAAE,uBAAuB;QAC7B,OAAO,EAAE,CAAC,aAAa,EAAE,kBAAkB,CAAC;QAC5C,IAAI,EAAE,kCAAkC;QACxC,IAAI,EAAE;YACJ,WAAW,EAAE,oEAAoE;YACjF,WAAW,EAA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OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBAC1B,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;QAED,OAAO;YACL,KAAK,CAAC,eAAe,CAAC,IAAI;gBACxB,IAAI,0BAA0B,CAAC,GAAG,CAAC,EAAE,CAAC;oBACpC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC;oBAC/B,MAAM,UAAU,GAAG,IAAA,iBAAS,EAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;oBACpE,IAAI,QAAQ,GAAG,IAAA,iBAAS,EAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;oBAC5D,IAAI,UAAU,KAAK,QAAQ;wBAAE,QAAQ,IAAI,CAAC,CAAC;oBAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;oBAC1D,OAAO,CAAC,MAAM,CAAC;wBACb,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC;wBAClD,UAAU;wBACV,QAAQ,EAAE,QAAQ;qBACnB,CAAC,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,MAAM,CAAC;wBACb,OAAO,EAAE,GAAG,CAAC,OAAO;wBACpB,UAAU,EAAE,CAAC;wBACb,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;qBAC7B,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a Liquid source string and returns a deduplicated list of variable names
|
|
3
|
+
* that are used but never defined. Returns `{ required: [], optional: [] }` on parse errors.
|
|
4
|
+
*
|
|
5
|
+
* Variables used exclusively with `| default` filter (e.g. `assign x = x | default: val`)
|
|
6
|
+
* are returned in `optional` — the partial handles the missing-argument case itself.
|
|
7
|
+
*
|
|
8
|
+
* This mirrors the variable tracking logic from the UndefinedObject check but
|
|
9
|
+
* packaged as a standalone synchronous function.
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractUndefinedVariables(source: string, globalObjectNames?: string[]): {
|
|
12
|
+
required: string[];
|
|
13
|
+
optional: string[];
|
|
14
|
+
};
|