CLI that type checks bindings in lit-html templates
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
The configuration system provides comprehensive control over analyzer behavior, rule severities, validation modes, and template recognition patterns.
Create configuration objects from partial options with intelligent defaults.
import { HTMLDataV1 } from "vscode-html-languageservice";
/**
* Create a complete configuration from partial options
* Applies intelligent defaults for unspecified options
* @param userOptions - Partial configuration options
* @returns Complete LitAnalyzerConfig with all defaults applied
*/
function makeConfig(userOptions?: Partial<LitAnalyzerConfig>): LitAnalyzerConfig;
/**
* Create rules configuration from partial analyzer config
* Extracts and processes rule-specific configuration
* @param userOptions - Partial configuration containing rules
* @returns Processed rules configuration
*/
function makeRules(userOptions: Partial<LitAnalyzerConfig>): LitAnalyzerRules;Usage Example:
import { makeConfig } from "lit-analyzer";
// Create strict configuration with custom rules
const config = makeConfig({
strict: true,
rules: {
"no-unknown-tag-name": "error",
"no-missing-import": "warn",
"no-incompatible-type-binding": "off"
},
logging: "debug"
});Utilities for managing rule severities and checking rule states.
/**
* Get the severity level for a specific rule
* @param rules - Rules configuration or full config
* @param ruleId - ID of the rule to check
* @returns The severity level for the rule
*/
function ruleSeverity(rules: LitAnalyzerConfig | LitAnalyzerRules, ruleId: LitAnalyzerRuleId): LitAnalyzerRuleSeverity;
/**
* Check if a rule is disabled
* @param config - Analyzer configuration
* @param ruleId - ID of the rule to check
* @returns True if the rule is disabled
*/
function isRuleDisabled(config: LitAnalyzerConfig, ruleId: LitAnalyzerRuleId): boolean;
/**
* Check if a rule is enabled
* @param config - Analyzer configuration
* @param ruleId - ID of the rule to check
* @returns True if the rule is enabled
*/
function isRuleEnabled(config: LitAnalyzerConfig, ruleId: LitAnalyzerRuleId): boolean;
/**
* Convert rule severity to diagnostic severity
* @param config - Analyzer configuration
* @param ruleId - ID of the rule
* @returns Diagnostic severity level
*/
function litDiagnosticRuleSeverity(config: LitAnalyzerConfig, ruleId: LitAnalyzerRuleId): LitDiagnosticSeverity;Access rule metadata and numeric codes.
/**
* Get numeric code for a rule ID
* @param ruleId - ID of the rule
* @returns Numeric code associated with the rule
*/
function ruleIdCode(ruleId: LitAnalyzerRuleId): number;
/** Array of all available rule IDs in alphabetical order */
const ALL_RULE_IDS: readonly LitAnalyzerRuleId[];
/** Map of rule IDs to their numeric codes */
const RULE_ID_CODE_MAP: Record<LitAnalyzerRuleId, number>;interface LitAnalyzerConfig {
/** Enable strict mode (changes default rule severities) */
strict: boolean;
/** Rule configuration mapping rule IDs to severities */
rules: LitAnalyzerRules;
/** Security system configuration */
securitySystem: LitSecuritySystem;
/** Disable analyzer functionality completely */
disable: boolean;
/** Logging level for analyzer output */
logging: LitAnalyzerLogging;
/** Current working directory */
cwd: string;
/** Format configuration */
format: { disable: boolean };
/** Disable suggestion messages in diagnostics */
dontShowSuggestions: boolean;
/** Disable configuration change suggestions */
dontSuggestConfigChanges: boolean;
/** Maximum depth for node_modules import traversal */
maxNodeModuleImportDepth: number;
/** Maximum depth for project import traversal */
maxProjectImportDepth: number;
/** Template tag names that contain HTML templates */
htmlTemplateTags: string[];
/** Template tag names that contain CSS templates */
cssTemplateTags: string[];
/** Global tag names that are always considered valid */
globalTags: string[];
/** Global attribute names that are always considered valid */
globalAttributes: string[];
/** Global event names that are always considered valid */
globalEvents: string[];
/** Custom HTML data for additional element/attribute definitions */
customHtmlData: (string | HTMLDataV1)[] | string | HTMLDataV1;
}type LitAnalyzerRules = Partial<Record<LitAnalyzerRuleId, LitAnalyzerRuleSeverity>>;
type LitAnalyzerRuleSeverity =
| "on"
| "off"
| "warn"
| "warning"
| "error"
| 0
| 1
| 2
| true
| false;
type LitAnalyzerRuleId =
| "no-unknown-tag-name"
| "no-missing-import"
| "no-unclosed-tag"
| "no-unknown-attribute"
| "no-unknown-property"
| "no-unknown-event"
| "no-unknown-slot"
| "no-unintended-mixed-binding"
| "no-invalid-boolean-binding"
| "no-expressionless-property-binding"
| "no-noncallable-event-binding"
| "no-boolean-in-attribute-binding"
| "no-complex-attribute-binding"
| "no-nullable-attribute-binding"
| "no-incompatible-type-binding"
| "no-invalid-directive-binding"
| "no-incompatible-property-type"
| "no-invalid-attribute-name"
| "no-invalid-tag-name"
| "no-invalid-css"
| "no-property-visibility-mismatch"
| "no-legacy-attribute"
| "no-missing-element-type-definition";type LitAnalyzerLogging = "off" | "error" | "warn" | "debug" | "verbose";type LitSecuritySystem = "off" | "ClosureSafeTypes";Rules for validating custom element usage and definitions:
no-unknown-tag-name - Check for unknown custom element tagsno-missing-import - Ensure custom elements are importedno-unclosed-tag - Check for unclosed tagsno-missing-element-type-definition - Ensure proper TypeScript definitionsRules for validating attribute, property, and event names:
no-unknown-attribute - Check for unknown attributesno-unknown-property - Check for unknown propertiesno-unknown-event - Check for unknown eventsno-unknown-slot - Check for unknown slotsno-legacy-attribute - Disallow legacy Polymer syntaxRules for validating binding type compatibility:
no-incompatible-type-binding - Check type compatibility in bindingsno-boolean-in-attribute-binding - Check boolean attribute usageno-expressionless-property-binding - Ensure property bindings have expressionsno-noncallable-event-binding - Check event handler callabilityno-nullable-attribute-binding - Check nullable attribute bindingsRules for advanced template validation:
no-invalid-attribute-name - Validate attribute name syntaxno-invalid-tag-name - Validate tag name syntaxno-property-visibility-mismatch - Check property visibilityno-invalid-directive-binding - Validate directive usageno-unintended-mixed-binding - Check for mixed binding typesno-invalid-boolean-binding - Validate boolean binding syntaxno-complex-attribute-binding - Check complex attribute expressionsno-attribute-default-value - Check attribute default valuesno-invalid-css - Validate CSS within template literalsno-incompatible-property-type - Check property type compatibilityno-unknown-property-converter - Check property converter usageno-duplicate-slot-names - Check for duplicate slot namesno-template-bind - Check template binding usageimport { makeConfig } from "lit-analyzer";
const config = makeConfig({
rules: {
"no-unknown-tag-name": "warn",
"no-missing-import": "error"
}
});const strictConfig = makeConfig({
strict: true,
logging: "debug",
rules: {
"no-unknown-tag-name": "error",
"no-incompatible-type-binding": "error"
}
});const customConfig = makeConfig({
htmlTemplateTags: ["html", "template", "render"],
cssTemplateTags: ["css", "styles"],
globalTags: ["my-custom-element"],
globalAttributes: ["data-testid"]
});