@shopify/theme-check-common
Advanced tools
Comparing version 1.14.1 to 1.15.0
# @shopify/theme-check-common | ||
## 1.15.0 | ||
### Patch Changes | ||
- 6c2c00f: `UndefinedObject` should not show any offenses when themeDocset is not given | ||
- f1a642f: Improve resilience of theme check pipeline by preventing entire failure if an individual check fails | ||
## 1.14.1 | ||
@@ -4,0 +11,0 @@ |
@@ -29,2 +29,9 @@ "use strict"; | ||
} | ||
/** | ||
* Skip this check when definitions for global objects are unavailable. | ||
*/ | ||
if (!context.themeDocset) { | ||
return {}; | ||
} | ||
const themeDocset = context.themeDocset; | ||
const variableScopes = new Map(); | ||
@@ -66,6 +73,4 @@ const variables = []; | ||
async onCodePathEnd() { | ||
if (context.themeDocset) { | ||
const objects = await globalObjects(context.themeDocset); | ||
objects.forEach((obj) => variableScopes.set(obj.name, [])); | ||
} | ||
const objects = await globalObjects(themeDocset); | ||
objects.forEach((obj) => variableScopes.set(obj.name, [])); | ||
variables.forEach((variable) => { | ||
@@ -72,0 +77,0 @@ if (!variable.name) |
@@ -168,3 +168,12 @@ "use strict"; | ||
}); | ||
(0, vitest_1.it)('should not report an offenses when definitions for global objects are unavailable', async () => { | ||
const sourceCode = ` | ||
{{ my_var }} | ||
`; | ||
const offenses = await (0, test_1.runLiquidCheck)(index_1.UndefinedObject, sourceCode, 'file.liquid', { | ||
themeDocset: null, | ||
}); | ||
(0, vitest_1.expect)(offenses).toHaveLength(0); | ||
}); | ||
}); | ||
//# sourceMappingURL=index.spec.js.map |
@@ -41,2 +41,5 @@ "use strict"; | ||
__exportStar(require("./ignore"), exports); | ||
const defaultErrorHandler = (_error) => { | ||
// Silently ignores errors by default. | ||
}; | ||
async function check(sourceCodes, config, dependencies) { | ||
@@ -76,3 +79,4 @@ const pipelines = []; | ||
} | ||
await Promise.all(pipelines); | ||
const onRejected = config.onError || defaultErrorHandler; | ||
await Promise.all(pipelines.map((pipeline) => pipeline.catch(onRejected))); | ||
return offenses.filter((offense) => !isDisabled(offense)); | ||
@@ -79,0 +83,0 @@ } |
@@ -62,2 +62,3 @@ import { NodeTypes as LiquidHtmlNodeTypes, LiquidHtmlNode } from '@shopify/liquid-html-parser'; | ||
ignore?: string[]; | ||
onError?: (error: Error) => void; | ||
} | ||
@@ -64,0 +65,0 @@ export type NodeOfType<T extends SourceCodeType, NT> = Extract<AST[T], { |
{ | ||
"name": "@shopify/theme-check-common", | ||
"version": "1.14.1", | ||
"version": "1.15.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/Shopify/theme-tools/blob/main/packages/theme-check-common/README.md", |
@@ -216,2 +216,14 @@ import { expect, describe, it } from 'vitest'; | ||
}); | ||
it('should not report an offenses when definitions for global objects are unavailable', async () => { | ||
const sourceCode = ` | ||
{{ my_var }} | ||
`; | ||
const offenses = await runLiquidCheck(UndefinedObject, sourceCode, 'file.liquid', { | ||
themeDocset: null, | ||
}); | ||
expect(offenses).toHaveLength(0); | ||
}); | ||
}); |
@@ -42,2 +42,10 @@ import { | ||
/** | ||
* Skip this check when definitions for global objects are unavailable. | ||
*/ | ||
if (!context.themeDocset) { | ||
return {}; | ||
} | ||
const themeDocset = context.themeDocset; | ||
const variableScopes: Map<string, Scope[]> = new Map(); | ||
@@ -84,7 +92,5 @@ const variables: LiquidVariableLookup[] = []; | ||
async onCodePathEnd() { | ||
if (context.themeDocset) { | ||
const objects = await globalObjects(context.themeDocset); | ||
const objects = await globalObjects(themeDocset); | ||
objects.forEach((obj) => variableScopes.set(obj.name, [])); | ||
} | ||
objects.forEach((obj) => variableScopes.set(obj.name, [])); | ||
@@ -91,0 +97,0 @@ variables.forEach((variable) => { |
@@ -34,2 +34,6 @@ import { | ||
const defaultErrorHandler = (_error: Error): void => { | ||
// Silently ignores errors by default. | ||
}; | ||
export async function check( | ||
@@ -73,3 +77,4 @@ sourceCodes: Theme, | ||
await Promise.all(pipelines); | ||
const onRejected = config.onError || defaultErrorHandler; | ||
await Promise.all(pipelines.map((pipeline) => pipeline.catch(onRejected))); | ||
@@ -76,0 +81,0 @@ return offenses.filter((offense) => !isDisabled(offense)); |
@@ -97,2 +97,3 @@ import { NodeTypes as LiquidHtmlNodeTypes, LiquidHtmlNode } from '@shopify/liquid-html-parser'; | ||
ignore?: string[]; | ||
onError?: (error: Error) => void; | ||
} | ||
@@ -99,0 +100,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1090842
18276