{"id":12469,"library":"vue-eslint-parser-template-tokenizer-pug","title":"Vue ESLint Parser Pug Template Tokenizer","description":"This package, `vue-eslint-parser-template-tokenizer-pug`, serves as an internal tokenizer specifically designed for `vue-eslint-parser` to handle Pug (formerly Jade) templates within Vue Single File Components. Its primary function is to convert Pug syntax within `<template lang=\"pug\">` blocks into a format that `vue-eslint-parser` can then process to generate an Abstract Syntax Tree (AST) for linting. It is currently at version 1.0.0. While actively maintained, it is *not* intended for direct end-user consumption. Users who wish to lint Pug templates in Vue applications should instead use `eslint-plugin-vue-pug`, which leverages this library internally. Its release cadence is tied to the needs of `eslint-plugin-vue-pug` and `vue-eslint-parser`, meaning updates are driven by functional requirements rather than a fixed schedule.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install vue-eslint-parser-template-tokenizer-pug","lang":"bash","label":"npm"},{"cmd":"yarn add vue-eslint-parser-template-tokenizer-pug","lang":"bash","label":"yarn"},{"cmd":"pnpm add vue-eslint-parser-template-tokenizer-pug","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as a peer dependency, as this package provides a tokenizer function to be used by vue-eslint-parser for processing Pug templates.","package":"vue-eslint-parser","optional":false}],"imports":[{"note":"The primary export is a function or an object containing `parseTemplate`, which is then passed to `vue-eslint-parser`'s `parserOptions.templateTokenizer`. While CommonJS `require` might work in some contexts, ESM `import` is the preferred and modern approach for library consumption.","wrong":"const { parseTemplate } = require('vue-eslint-parser-template-tokenizer-pug');","symbol":"parseTemplate","correct":"import { parseTemplate } from 'vue-eslint-parser-template-tokenizer-pug';"},{"note":"Type import for advanced users or plugin developers defining their own tokenizers. The actual factory is usually configured via string reference in `vue-eslint-parser` options.","symbol":"TemplateTokenizerFactory","correct":"import type { TemplateTokenizerFactory } from 'vue-eslint-parser-template-tokenizer-pug';"}],"quickstart":{"code":"import { ESLint } from 'eslint';\nimport vueParser from 'vue-eslint-parser';\nimport pugTokenizer from 'vue-eslint-parser-template-tokenizer-pug';\n\nconst cli = new ESLint({\n  useEslintrc: false,\n  overrideConfig: {\n    parser: vueParser,\n    parserOptions: {\n      ecmaVersion: 2020,\n      sourceType: 'module',\n      templateTokenizer: {\n        pug: pugTokenizer\n      }\n    },\n    rules: {\n      'vue/no-unused-vars': 'error'\n    }\n  }\n});\n\nasync function lintPugVue() {\n  const code = `<template lang=\"pug\">\\n  div.my-component\\n    p Hello, Pug in Vue!\\n    span {{ someVar }}\\n</template>\\n<script>\\nexport default { data: () => ({ someVar: 'test' }) }\\n</script>`;\n  const results = await cli.lintText(code, { filePath: 'test.vue' });\n\n  console.log('Linting Results:');\n  results.forEach(result => {\n    console.log(`File: ${result.filePath}`);\n    result.messages.forEach(message => {\n      console.log(`  Line ${message.line}, Col ${message.column}: ${message.message} (${message.ruleId})`);\n    });\n    if (result.errorCount > 0) {\n      console.error(`  Errors: ${result.errorCount}`);\n    }\n  });\n}\n\nlintPugVue().catch(console.error);","lang":"typescript","description":"Demonstrates how `vue-eslint-parser-template-tokenizer-pug` is configured with `vue-eslint-parser` to lint a Vue SFC with Pug templates, emphasizing its internal role rather than direct end-user API usage."},"warnings":[{"fix":"Install `eslint-plugin-vue-pug` and configure it in your ESLint setup. Do not directly import or use `vue-eslint-parser-template-tokenizer-pug` unless developing an ESLint plugin that requires custom tokenizer integration.","message":"This is an internal library and is not intended for direct use by end-user applications. For linting Pug templates in Vue components, use `eslint-plugin-vue-pug` instead.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Be aware that not all Pug parsing issues might be immediately reported as ESLint errors. Rely on `eslint-plugin-vue-pug`'s integrated rules for comprehensive validation. Report specific un-reported parsing issues to `eslint-plugin-vue-pug` or `vue-eslint-parser`.","message":"The README mentions that adding errors to `templateBody.errors` might not affect linting, suggesting potential limitations in how parsing errors from the tokenizer are surfaced by `eslint-plugin-vue`'s `no-parsing-error` rule.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Refer to the `vue-eslint-parser` and `eslint-plugin-vue-pug` documentation for the latest configuration requirements and updates regarding custom template tokenizers.","message":"`vue-eslint-parser`'s `parserOptions.templateTokenizer` is an experimental feature and may change or be removed in minor versions of `vue-eslint-parser` without notice. This could impact how this tokenizer is configured and used.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `vue-eslint-parser-template-tokenizer-pug` is listed in your project's `devDependencies` and installed (`npm install` or `yarn install`). Verify the import path is correct if used directly, or that `eslint-plugin-vue-pug` is correctly configured.","cause":"The package is not installed or the path in `parserOptions.templateTokenizer` is incorrect.","error":"ESLint: Cannot find module 'vue-eslint-parser-template-tokenizer-pug'"},{"fix":"Ensure `vue-eslint-parser` is correctly set as the `parser` in your ESLint configuration and that `parserOptions.templateTokenizer.pug` points to this package (usually handled by `eslint-plugin-vue-pug`).","cause":"Attempting to lint a `.vue` file without `vue-eslint-parser` configured as the main parser, or providing an invalid `templateTokenizer` object.","error":"Error: Cannot read properties of undefined (reading 'templateBody')"}],"ecosystem":"npm"}