Home / File/ css-warn.js — svelte Source File

css-warn.js — svelte Source File

Architecture documentation for css-warn.js, a javascript file in the svelte codebase. 5 imports, 1 dependents.

File javascript Compiler Analyzer 5 imports 1 dependents 5 functions

Entity Profile

Dependency Diagram

graph LR
  4676a465_3cd7_1d4c_04b8_a56bf8469f18["css-warn.js"]
  56a689f9_11c0_cc76_bd60_41bb6dc96475["warnings.js"]
  4676a465_3cd7_1d4c_04b8_a56bf8469f18 --> 56a689f9_11c0_cc76_bd60_41bb6dc96475
  3246e0bc_b9fc_f638_5e35_41e8c39a2408["w"]
  4676a465_3cd7_1d4c_04b8_a56bf8469f18 --> 3246e0bc_b9fc_f638_5e35_41e8c39a2408
  2a0e126c_5670_329c_f4f4_86feb8413563["css.js"]
  4676a465_3cd7_1d4c_04b8_a56bf8469f18 --> 2a0e126c_5670_329c_f4f4_86feb8413563
  aee1cb4d_8fc3_fbc4_d431_00510040685f["is_keyframes_node"]
  4676a465_3cd7_1d4c_04b8_a56bf8469f18 --> aee1cb4d_8fc3_fbc4_d431_00510040685f
  c49ac9f8_b355_57a2_8d10_b5fd945c6144["zimmerframe"]
  4676a465_3cd7_1d4c_04b8_a56bf8469f18 --> c49ac9f8_b355_57a2_8d10_b5fd945c6144
  4aa8a188_84d4_0274_ed83_cac0ab1d3572["index.js"]
  4aa8a188_84d4_0274_ed83_cac0ab1d3572 --> 4676a465_3cd7_1d4c_04b8_a56bf8469f18
  style 4676a465_3cd7_1d4c_04b8_a56bf8469f18 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { Visitors } from 'zimmerframe' */
/** @import { AST } from '#compiler' */
import { walk } from 'zimmerframe';
import * as w from '../../../warnings.js';
import { is_keyframes_node } from '../../css.js';

/**
 * @param {AST.CSS.StyleSheet} stylesheet
 */
export function warn_unused(stylesheet) {
	walk(stylesheet, { stylesheet }, visitors);
}

/** @type {Visitors<AST.CSS.Node, { stylesheet: AST.CSS.StyleSheet }>} */
const visitors = {
	Atrule(node, context) {
		if (!is_keyframes_node(node)) {
			context.next();
		}
	},
	PseudoClassSelector(node, context) {
		if (node.name === 'is' || node.name === 'where') {
			context.next();
		}
	},
	ComplexSelector(node, context) {
		if (
			!node.metadata.used &&
			// prevent double-marking of `.unused:is(.unused)`
			(context.path.at(-2)?.type !== 'PseudoClassSelector' ||
				/** @type {AST.CSS.ComplexSelector} */ (context.path.at(-4))?.metadata.used)
		) {
			const content = context.state.stylesheet.content;
			const text = content.styles.substring(node.start - content.start, node.end - content.start);
			w.css_unused_selector(node, text);
		}

		context.next();
	},
	Rule(node, context) {
		if (node.metadata.is_global_block) {
			context.visit(node.prelude);
		} else {
			context.next();
		}
	}
};

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does css-warn.js do?
css-warn.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Analyzer subdomain.
What functions are defined in css-warn.js?
css-warn.js defines 5 function(s): visitors.Atrule, visitors.ComplexSelector, visitors.PseudoClassSelector, visitors.Rule, warn_unused.
What does css-warn.js depend on?
css-warn.js imports 5 module(s): css.js, is_keyframes_node, w, warnings.js, zimmerframe.
What files import css-warn.js?
css-warn.js is imported by 1 file(s): index.js.
Where is css-warn.js in the architecture?
css-warn.js is located at packages/svelte/src/compiler/phases/2-analyze/css/css-warn.js (domain: Compiler, subdomain: Analyzer, directory: packages/svelte/src/compiler/phases/2-analyze/css).

Analyze Your Own Codebase

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

Try Supermodel Free