Home / File/ format-nodes.test.ts — tailwindcss Source File

format-nodes.test.ts — tailwindcss Source File

Architecture documentation for format-nodes.test.ts, a typescript file in the tailwindcss codebase. 6 imports, 0 dependents.

File typescript UpgradeToolkit Codemods 6 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  fb30d75d_33fe_1bdc_7044_fd6d2cc1b187["format-nodes.test.ts"]
  e7639b6d_2132_7e05_9498_c732c7517772["format-nodes.ts"]
  fb30d75d_33fe_1bdc_7044_fd6d2cc1b187 --> e7639b6d_2132_7e05_9498_c732c7517772
  729a086c_18ec_2750_83e5_bdd730f8fa5e["formatNodes"]
  fb30d75d_33fe_1bdc_7044_fd6d2cc1b187 --> 729a086c_18ec_2750_83e5_bdd730f8fa5e
  ecf9faa2_4ccf_f16c_bb10_222be63faed0["sort-buckets.ts"]
  fb30d75d_33fe_1bdc_7044_fd6d2cc1b187 --> ecf9faa2_4ccf_f16c_bb10_222be63faed0
  92a12a9f_b36d_4c66_d885_e04224081f21["sortBuckets"]
  fb30d75d_33fe_1bdc_7044_fd6d2cc1b187 --> 92a12a9f_b36d_4c66_d885_e04224081f21
  ba54c7c3_7b1e_9984_bfef_a693a3df2d84["postcss"]
  fb30d75d_33fe_1bdc_7044_fd6d2cc1b187 --> ba54c7c3_7b1e_9984_bfef_a693a3df2d84
  696bd648_5f24_1b59_8e8b_7a97a692869e["vitest"]
  fb30d75d_33fe_1bdc_7044_fd6d2cc1b187 --> 696bd648_5f24_1b59_8e8b_7a97a692869e
  style fb30d75d_33fe_1bdc_7044_fd6d2cc1b187 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import postcss, { type Plugin } from 'postcss'
import { expect, it } from 'vitest'
import { formatNodes } from './format-nodes'
import { sortBuckets } from './sort-buckets'

function markPretty(): Plugin {
  return {
    postcssPlugin: '@tailwindcss/upgrade/mark-pretty',
    OnceExit(root) {
      root.walkAtRules('tw-format', (atRule) => {
        atRule.raws.tailwind_pretty = true
      })
    },
  }
}

function migrate(input: string) {
  return postcss()
    .use(markPretty())
    .use(sortBuckets())
    .use(formatNodes())
    .process(input, { from: expect.getState().testPath })
    .then((result) => result.css)
}

it('should format PostCSS nodes', async () => {
  expect(await migrate(`@utility .foo { .foo { color: red; } }`)).toMatchInlineSnapshot(`
    "@utility .foo {
      .foo {
        color: red;
      }
    }"
  `)
})

it('should format PostCSS nodes in the `user` bucket', async () => {
  expect(await migrate(`@tw-bucket user { @tw-format .bar { .foo { color: red; } } }`))
    .toMatchInlineSnapshot(`
      "@tw-format .bar {
        .foo {
          color: red;
        }
      }"
    `)
})

Subdomains

Frequently Asked Questions

What does format-nodes.test.ts do?
format-nodes.test.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the UpgradeToolkit domain, Codemods subdomain.
What functions are defined in format-nodes.test.ts?
format-nodes.test.ts defines 2 function(s): markPretty, migrate.
What does format-nodes.test.ts depend on?
format-nodes.test.ts imports 6 module(s): format-nodes.ts, formatNodes, postcss, sort-buckets.ts, sortBuckets, vitest.
Where is format-nodes.test.ts in the architecture?
format-nodes.test.ts is located at packages/@tailwindcss-upgrade/src/codemods/css/format-nodes.test.ts (domain: UpgradeToolkit, subdomain: Codemods, directory: packages/@tailwindcss-upgrade/src/codemods/css).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free