Home / Function/ validate_identifier_name() — svelte Function Reference

validate_identifier_name() — svelte Function Reference

Architecture documentation for the validate_identifier_name() function in utils.js from the svelte codebase.

Function javascript Compiler Transformer calls 2 called by 4

Entity Profile

Dependency Diagram

graph TD
  962a9e38_f393_8bb8_8642_fd23c4e768e6["validate_identifier_name()"]
  bf0d8f1b_17da_970d_bf44_fbcf099d5371["utils.js"]
  962a9e38_f393_8bb8_8642_fd23c4e768e6 -->|defined in| bf0d8f1b_17da_970d_bf44_fbcf099d5371
  fbf57d5e_ac5f_3e1c_f376_f8f76ce4ec4a["ClassDeclaration()"]
  fbf57d5e_ac5f_3e1c_f376_f8f76ce4ec4a -->|calls| 962a9e38_f393_8bb8_8642_fd23c4e768e6
  56f3948c_7ceb_ca49_e56d_8edd0d6e5ded["FunctionDeclaration()"]
  56f3948c_7ceb_ca49_e56d_8edd0d6e5ded -->|calls| 962a9e38_f393_8bb8_8642_fd23c4e768e6
  533f6c0a_5a99_4a6e_a54c_59fc0c845257["VariableDeclarator()"]
  533f6c0a_5a99_4a6e_a54c_59fc0c845257 -->|calls| 962a9e38_f393_8bb8_8642_fd23c4e768e6
  44642633_e3c9_8ae1_48af_53507481a2cb["declare()"]
  44642633_e3c9_8ae1_48af_53507481a2cb -->|calls| 962a9e38_f393_8bb8_8642_fd23c4e768e6
  bdfe14bf_7b05_3e14_56eb_417219ade2cc["dollar_binding_invalid()"]
  962a9e38_f393_8bb8_8642_fd23c4e768e6 -->|calls| bdfe14bf_7b05_3e14_56eb_417219ade2cc
  d0f2dc13_c362_52e6_cf77_bf4cfe44471d["dollar_prefix_invalid()"]
  962a9e38_f393_8bb8_8642_fd23c4e768e6 -->|calls| d0f2dc13_c362_52e6_cf77_bf4cfe44471d
  style 962a9e38_f393_8bb8_8642_fd23c4e768e6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js lines 254–282

export function validate_identifier_name(binding, function_depth) {
	if (!binding) return;

	const declaration_kind = binding.declaration_kind;

	if (
		declaration_kind !== 'synthetic' &&
		declaration_kind !== 'param' &&
		declaration_kind !== 'rest_param' &&
		(!function_depth || function_depth <= 1)
	) {
		const node = binding.node;

		if (node.name === '$') {
			e.dollar_binding_invalid(node);
		} else if (
			node.name.startsWith('$') &&
			// import type { $Type } from "" - these are normally already filtered out,
			// but for the migration they aren't, and throwing here is preventing the migration to complete
			// TODO -> once migration script is gone we can remove this check
			!(
				binding.initial?.type === 'ImportDeclaration' &&
				/** @type {any} */ (binding.initial).importKind === 'type'
			)
		) {
			e.dollar_prefix_invalid(node);
		}
	}
}

Domain

Subdomains

Frequently Asked Questions

What does validate_identifier_name() do?
validate_identifier_name() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js.
Where is validate_identifier_name() defined?
validate_identifier_name() is defined in packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js at line 254.
What does validate_identifier_name() call?
validate_identifier_name() calls 2 function(s): dollar_binding_invalid, dollar_prefix_invalid.
What calls validate_identifier_name()?
validate_identifier_name() is called by 4 function(s): ClassDeclaration, FunctionDeclaration, VariableDeclarator, declare.

Analyze Your Own Codebase

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

Try Supermodel Free