Support formatted Vue Pug template tags - #20475
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughVue template extraction now accepts attributes before or after Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to Vue Pug template preprocessing now supports formatted template attributes while preserving existing body replacement behavior and ignoring data-lang. The covered parsing cases and passing checks indicate no current merge-blocking risk. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| static TEMPLATE_REGEX: sync::LazyLock<Regex> = sync::LazyLock::new(|| { | ||
| Regex::new(r#"<template lang=['"]([^"']*)['"]>([\s\S]*)<\/template>"#).unwrap() | ||
| Regex::new( | ||
| r#"<template\s+(?:[^>]*\s+)?lang\s*=\s*(?:"([^"]*)"|'([^']*)')[^>]*>([\s\S]*)<\/template>"#, |
There was a problem hiding this comment.
The [^>]* attribute scan is not aware of quoted values. For example, <template data-config=" lang='pug'"> has no real lang attribute, but this regex captures pug from inside data-config and passes the HTML body through the Pug preprocessor. That can change extracted class candidates, such as interpreting the literal HTML class foo.bar as separate Pug classes.
Summary
Vue files are passed through the Vue preprocessor, which detects
<template lang="pug">blocks and runs the Pug preprocessor on their contents.The existing regular expression only matched the most compact opening tag form. It missed valid Vue template tags when
langhad surrounding whitespace, when the opening tag spanned multiple lines, or when other attributes were present.This change broadens the opening-tag detection while preserving the existing body replacement behavior. Pug preprocessing now works for formatted template tags and still ignores unrelated attributes such as
data-lang.Test plan
cargo test -p tailwindcss-oxiderustfmt --check crates/oxide/src/extractor/pre_processors/vue.rsAll Oxide and scanner tests pass.