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 CLI interface provides command-line analysis capabilities with multiple output formats, extensive configuration options, and flexible rule management for analyzing Lit templates in development workflows and CI/CD pipelines.
Entry point function for the command-line interface.
/**
* Main CLI entry point function
* Parses command-line arguments, configures analyzer, and executes analysis
* @returns Promise that resolves when analysis is complete
* @throws Exits process with code 0 on success, 1 on failure
*/
function cli(): Promise<void>;Extended configuration interface for command-line specific options.
type FormatterFormat = "code" | "list" | "markdown";
/**
* CLI-specific configuration interface
* Contains options for command-line interface control
*/
interface LitAnalyzerCliConfig {
/** Enable debug mode for detailed logging */
debug?: boolean;
/** Show help message and exit */
help?: boolean;
/** Disable colored output */
noColor?: boolean;
/** Maximum number of warnings before failing (-1 for unlimited) */
maxWarnings?: number;
/** Output file path (stdout if not specified) */
outFile?: string;
/** Exit immediately after finding the first problem */
failFast?: boolean;
/** Only report errors, suppress warnings */
quiet?: boolean;
/** Enable strict mode (changes default rule severities) */
strict?: boolean;
/** Output format for diagnostic results */
format?: FormatterFormat;
/** Rule configuration mapping rule IDs to severities */
rules?: LitAnalyzerRules;
/** Maximum depth for project import traversal */
maxProjectImportDepth?: number;
/** Maximum depth for node_modules import traversal */
maxNodeModuleImportDepth?: number;
}# Analyze all TypeScript/JavaScript files in src directory (default glob)
lit-analyzer
# Analyze specific directory
lit-analyzer src
# Analyze with glob patterns
lit-analyzer "src/**/*.{js,ts,jsx,tsx}"
# Analyze specific files
lit-analyzer my-element.js another-component.tsControl how diagnostics are displayed:
# Default code format with syntax highlighting
lit-analyzer --format code src
# Compact list format
lit-analyzer --format list src
# Markdown format for documentation
lit-analyzer --format markdown src
# Output to file
lit-analyzer --format markdown --outFile results.md srcConfigure individual rules from the command line:
# Disable specific rule
lit-analyzer --rules.no-unknown-tag-name off src
# Set rule to warning level
lit-analyzer --rules.no-missing-import warn src
# Set rule to error level
lit-analyzer --rules.no-incompatible-type-binding error src
# Multiple rule configurations
lit-analyzer \
--rules.no-unknown-tag-name error \
--rules.no-missing-import warn \
--rules.no-unknown-attribute off \
srcEnable strict mode for more comprehensive validation:
# Enable strict mode (changes default rule severities)
lit-analyzer --strict srcControl CLI behavior and output:
# Suppress warnings, show only errors
lit-analyzer --quiet src
# Exit after first problem found
lit-analyzer --failFast src
# Disable colored output
lit-analyzer --noColor src
# Fail if more than 10 warnings
lit-analyzer --maxWarnings 10 src
# Allow unlimited warnings
lit-analyzer --maxWarnings -1 src# Show help message with all available options
lit-analyzer --helpThe CLI can also read configuration from tsconfig.json files using the TypeScript Language Service plugin configuration format:
{
"compilerOptions": {
"plugins": [
{
"name": "ts-lit-plugin",
"strict": true,
"rules": {
"no-unknown-tag-name": "error",
"no-missing-import": "warn",
"no-incompatible-type-binding": "error"
},
"logging": "debug"
}
]
}
}src/my-element.ts:15:7 - error TS0: Unknown tag name "unknow-element" (no-unknown-tag-name)
15 return html`<unknow-element></unknow-element>`;
~~~~~~~~~~~~~
Did you mean "unknown-element"?
src/my-element.ts:20:25 - warning TS0: Property "invalidProp" does not exist on element "input" (no-unknown-property)
20 return html`<input .invalidProp=${value}>`;
~~~~~~~~~~~~src/my-element.ts:15:7: error: Unknown tag name "unknow-element" (no-unknown-tag-name)
src/my-element.ts:20:25: warning: Property "invalidProp" does not exist on element "input" (no-unknown-property)## Analysis Results
### src/my-element.ts
**Error** at line 15, column 7 - `no-unknown-tag-name`
Unknown tag name "unknow-element"
**Warning** at line 20, column 25 - `no-unknown-property`
Property "invalidProp" does not exist on element "input"The CLI uses standard exit codes:
# Fail build on any errors
lit-analyzer --failFast src && npm run build
# Allow warnings but fail on errors
lit-analyzer --quiet src || exit 1
# Generate markdown report for PR comments
lit-analyzer --format markdown --outFile analysis-report.md srcThe CLI can be integrated with editors and IDEs:
# VS Code task configuration
{
"type": "shell",
"command": "lit-analyzer",
"args": ["src"],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"problemMatcher": {
"owner": "lit-analyzer",
"fileLocation": "relative",
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+)\\s+-\\s+(error|warning)\\s+.*:\\s+(.*)\\s+\\((.*)\\)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
}
}{
"scripts": {
"lint:lit": "lit-analyzer src",
"lint:lit:strict": "lit-analyzer --strict src",
"lint:lit:report": "lit-analyzer --format markdown --outFile lit-analysis.md src"
}
}Create reusable rule configurations:
# Development mode - warnings only
lit-analyzer \
--rules.no-unknown-tag-name warn \
--rules.no-missing-import warn \
--rules.no-incompatible-type-binding warn \
src
# Production mode - strict validation
lit-analyzer \
--strict \
--rules.no-unknown-tag-name error \
--rules.no-missing-import error \
--rules.no-incompatible-type-binding error \
--failFast \
src# Analyze multiple projects
for project in packages/*/; do
echo "Analyzing $project"
lit-analyzer "$project/src"
done
# Parallel analysis with different configurations
lit-analyzer --format list src > analysis-list.txt &
lit-analyzer --format markdown src > analysis-report.md &
waitThe CLI provides detailed error information:
For large codebases:
# Use failFast to exit early
lit-analyzer --failFast src
# Limit warnings to avoid excessive output
lit-analyzer --maxWarnings 50 src
# Use quiet mode for faster processing
lit-analyzer --quiet src