1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Upgradeliquidjs 10.13 (#50845)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Grace Park <gracepark@github.com>
This commit is contained in:
Peter Bengtsson
2024-06-12 15:00:10 -04:00
committed by GitHub
parent b58e73c51c
commit c251f6d64e
5 changed files with 18 additions and 7 deletions

7
package-lock.json generated
View File

@@ -57,7 +57,7 @@
"javascript-stringify": "^2.1.0",
"js-cookie": "^3.0.1",
"js-yaml": "^4.1.0",
"liquidjs": "^10.7.0",
"liquidjs": "^10.13.1",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"lowdb": "7.0.1",
@@ -8753,8 +8753,9 @@
}
},
"node_modules/liquidjs": {
"version": "10.7.0",
"license": "MIT",
"version": "10.13.1",
"resolved": "https://registry.npmjs.org/liquidjs/-/liquidjs-10.13.1.tgz",
"integrity": "sha512-QCQ69sbyMdA1970NEsG7KdQoKi6N+lGg55izisvKvrrRO1nrpS/YBAnzDndR13exYB4xE9A87qdOMuaXPn9v9A==",
"dependencies": {
"commander": "^10.0.0"
},

View File

@@ -272,7 +272,7 @@
"javascript-stringify": "^2.1.0",
"js-cookie": "^3.0.1",
"js-yaml": "^4.1.0",
"liquidjs": "^10.7.0",
"liquidjs": "^10.13.1",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"lowdb": "7.0.1",

View File

@@ -2,9 +2,14 @@ import { Tokenizer } from 'liquidjs'
const liquidTokenCache = new Map()
export function getLiquidTokens(content) {
export function getLiquidTokens(content, { noCache = false } = {}) {
if (!content) return []
if (noCache) {
const tokenizer = new Tokenizer(content)
return tokenizer.readTopLevelTokens()
}
if (liquidTokenCache.has(content)) {
return liquidTokenCache.get(content)
}

View File

@@ -223,7 +223,11 @@ function checkString(
}: { page?: Page; filePath?: string; languageCode?: string; verbose?: boolean } = {},
) {
try {
for (const token of getLiquidTokens(string)) {
// The reason for the `noCache: true` is that we're going to be sending
// a LOT of different strings in and the cache will fill up rapidly
// when testing every possible string in every possible language for
// every page.
for (const token of getLiquidTokens(string, { noCache: true })) {
if (token.name === 'ifversion' || token.name === 'elsif') {
for (const arg of token.args.split(/\s+/)) {
if (IGNORE_ARGS.has(arg)) continue

View File

@@ -77,7 +77,8 @@ function run(languageCode: string, site: Site, englishReusables: Reusables) {
const illegalTags = new Map<string, number>()
function countError(error: TokenizationError, where: string) {
const errorString = (error as any).originalError.message as string
const originalError = (error as any).originalError
const errorString = originalError ? originalError.message : error.message
if (errorString.includes('illegal tag syntax')) {
const illegalTag = (error as any).token.content
illegalTags.set(illegalTag, (illegalTags.get(illegalTag) || 0) + 1)