Skip to content

Commit de9ee25

Browse files
committedFeb 28, 2025
Add comments highlighting code duplication in parameter removal logic
1 parent 681cdd1 commit de9ee25

File tree

2 files changed

+6
-1
lines changed
  • packages/theme-check-common/src/checks
    • duplicate-render-snippet-params
    • unrecognized-render-snippet-params

2 files changed

+6
-1
lines changed
 

‎packages/theme-check-common/src/checks/duplicate-render-snippet-params/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export const DuplicateRenderSnippetParams: LiquidCheckDefinition = {
4040
{
4141
message: `Remove duplicate parameter '${paramName}'`,
4242
fix: (fixer) => {
43+
// This parameter removal logic is duplicated in UnrecognizedRenderSnippetParams
44+
// Consider extracting to a shared utility or simplifying the removal approach in the parsing steps.
45+
// I chose not to do so here as I would like more examples to see how this should be done.
4346
const sourceBeforeArg = node.source.slice(0, param.position.start);
4447
const matches = sourceBeforeArg.match(/,\s*/g);
4548
const lastWhitespaceMatch = matches ? matches[matches.length - 1] : null;

‎packages/theme-check-common/src/checks/unrecognized-render-snippet-params/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ export const UnrecognizedRenderSnippetParams: LiquidCheckDefinition = {
3636
{
3737
message: `Remove '${param.name}'`,
3838
fix: (fixer) => {
39-
// This is a bit messy, but it allows us to strip leading and trailing whitespaces and commas
39+
// This parameter removal logic is duplicated in DuplicateRenderSnippetParams
40+
// Consider extracting to a shared utility or simplifying the removal approach in the parsing steps.
41+
// I chose not to do so here as I would like more examples to see how this should be done.
4042
const sourceBeforeArg = node.source.slice(0, param.position.start);
4143
const matches = sourceBeforeArg.match(/,\s*/g);
4244
const lastWhitespaceMatch = matches ? matches[matches.length - 1] : null;

0 commit comments

Comments
 (0)