Skip to content

Commit c3f76b4

Browse files
authored
[jinja] Fix failing lint (#1860)
Weird, CI didn't pick up this lint error in #1859. PR ([success](https://github.com/huggingface/huggingface.js/actions/runs/19744569408/job/56576090622)) <img width="887" height="696" alt="image" src="https://github.com/user-attachments/assets/b889135e-6977-4300-8c4e-dc2f9b16b374" /> Main ([failure](https://github.com/huggingface/huggingface.js/actions/runs/19744642524/job/56576326408)) <img width="946" height="778" alt="image" src="https://github.com/user-attachments/assets/8470e6b4-d3d2-46ec-bb23-48d9812e2ebd" /> cc @coyotte508 probably something to look into
1 parent 881f81d commit c3f76b4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

packages/jinja/src/lexer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,8 @@ export function tokenize(source: string, options: PreprocessOptions = {}): Token
180180
};
181181

182182
const stripTrailingWhitespace = () => {
183-
if (tokens.length === 0) return;
184-
const lastToken = tokens.at(-1)!;
185-
if (lastToken.type === TOKEN_TYPES.Text) {
183+
const lastToken = tokens.at(-1);
184+
if (lastToken && lastToken.type === TOKEN_TYPES.Text) {
186185
lastToken.value = lastToken.value.trimEnd();
187186
if (lastToken.value === "") {
188187
tokens.pop(); // Remove empty text token

0 commit comments

Comments
 (0)