Skip to content

Conversation

@Sidnioulz
Copy link
Owner

@Sidnioulz Sidnioulz commented Jun 25, 2025

Closes #16

  • Add PostCSS-based CSS transformation API inspired by JSCodeshift
  • Support CSS, SCSS, and Less syntax parsing
  • Implement comprehensive transformation context with PostCSS AST access
  • Add support for Vue-specific features (scoped styles, deep selectors, CSS modules)
  • Create extensive test suite covering all major CSS transformation scenarios
  • Add three example transformations:
    • CSS class prefix addition with configurable prefix
    • Vue deep selector syntax conversion (:deep() to ::v-deep)
    • CSS color values to CSS custom properties conversion
  • Maintain backward compatibility with existing codebase

🤖 Generated with Claude Code

- Add PostCSS-based CSS transformation API inspired by JSCodeshift
- Support CSS, SCSS, and Less syntax parsing
- Implement comprehensive transformation context with PostCSS AST access
- Add support for Vue-specific features (scoped styles, deep selectors, CSS modules)
- Create extensive test suite covering all major CSS transformation scenarios
- Add three example transformations:
  * CSS class prefix addition with configurable prefix
  * Vue deep selector syntax conversion (:deep() to ::v-deep)
  * CSS color values to CSS custom properties conversion
- Maintain backward compatibility with existing codebase

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Sidnioulz Sidnioulz self-assigned this Jun 25, 2025
@Sidnioulz Sidnioulz added the enhancement New feature or request label Jun 25, 2025
@codecov
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 93.50649% with 5 lines in your changes missing coverage. Please review.

Project coverage is 82.66%. Comparing base (de81ac4) to head (b686cad).

Files with missing lines Patch % Lines
src/transformStyle.ts 93.50% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
+ Coverage   81.23%   82.66%   +1.43%     
==========================================
  Files          22       22              
  Lines        1993     2060      +67     
  Branches      215      232      +17     
==========================================
+ Hits         1619     1703      +84     
+ Misses        369      351      -18     
- Partials        5        6       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Sidnioulz Sidnioulz requested a review from Copilot June 25, 2025 12:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a PostCSS-based CSS transformation API for Vue SFCs, adds parser support for CSS/SCSS/Less, and provides examples and tests for common codemods.

  • Define new types (StyleTransformationFileInfo, StyleTransformationContext) and update StyleTransformation signature
  • Implement transformStyle runner with PostCSS parsing, context creation, and result handling
  • Add comprehensive tests and real-world examples (class prefixing, Vue deep selector conversion, color variable conversion)

Reviewed Changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/types/StyleTransformation.ts Added types for style transformation API
src/transformStyle.ts Implemented the core CSS transformation runner
src/tests/transformStyle.spec.ts Added tests covering CSS, SCSS, Less, return types, and errors
package.json Registered PostCSS and related dependencies
examples/css-vue-deep-transform/transformation.cjs Example for Vue deep/slotted selector conversion
examples/css-vue-deep-transform/Input.vue Vue SFC demonstrating deep/slotted syntax
examples/css-prefix-classes/transformation.cjs Example for CSS class prefix addition
examples/css-prefix-classes/Input.vue Vue SFC demonstrating class prefix example
examples/css-color-variables/transformation.cjs Example for converting color literals to CSS custom properties
examples/css-color-variables/Input.vue Vue SFC with color variable declarations (has formatting issue)
Comments suppressed due to low confidence (3)

src/transformStyle.ts:28

  • [nitpick] Rename the params parameter to options to match the StyleTransformation signature and improve consistency.
  params: Options,

examples/css-color-variables/Input.vue:9

  • The CSS rules are appended directly to the <style> tag instead of inside the block. Split this into <style scoped> on its own line, followed by the :root { ... } block.
<style scoped>:root {

package.json:71

  • These dependencies (postcss-selector-parser, postcss-value-parser) are not used in the codebase. Consider removing them to keep the dependency list lean.
    "postcss-selector-parser": "^7.1.0",

Comment on lines +4 to +9

// Transform class selectors
root.walkRules((rule) => {
rule.selector = rule.selector.replace(/\.([a-zA-Z][\w-]*)/g, (match, className) => {
// Don't prefix if it already has the prefix
if (className.startsWith(prefix.replace('-', ''))) {
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Avoid calling prefix.replace('-', '') inside the loop on every rule. Compute the cleaned prefix once outside of root.walkRules for better clarity and slight performance gain.

Suggested change
// Transform class selectors
root.walkRules((rule) => {
rule.selector = rule.selector.replace(/\.([a-zA-Z][\w-]*)/g, (match, className) => {
// Don't prefix if it already has the prefix
if (className.startsWith(prefix.replace('-', ''))) {
const cleanedPrefix = prefix.replace('-', '')
// Transform class selectors
root.walkRules((rule) => {
rule.selector = rule.selector.replace(/\.([a-zA-Z][\w-]*)/g, (match, className) => {
// Don't prefix if it already has the prefix
if (className.startsWith(cleanedPrefix)) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for style

2 participants