All files / src/compiler/phases/2-analyze/visitors ClassDeclaration.js

100% Statements 21/21
100% Branches 4/4
100% Functions 1/1
100% Lines 20/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 212x 2x 2x 2x 2x 2x 2x 2x 2x 91x 91x 91x 91x 91x 91x 1x 1x 91x 91x 91x  
/** @import { ClassDeclaration } from 'estree' */
/** @import { Context } from '../types' */
import * as w from '../../../warnings.js';
 
/**
 * @param {ClassDeclaration} node
 * @param {Context} context
 */
export function ClassDeclaration(node, context) {
	// In modules, we allow top-level module scope only, in components, we allow the component scope,
	// which is function_depth of 1. With the exception of `new class` which is also not allowed at
	// component scope level either.
	const allowed_depth = context.state.ast_type === 'module' ? 0 : 1;
 
	if (context.state.scope.function_depth > allowed_depth) {
		w.perf_avoid_nested_class(node);
	}
 
	context.next();
}