Configure ESLint for WebComponents templates to allow underscore-prefixed unused variables
CLI-generated WebComponents apps fail lint with @typescript-eslint/no-unused-vars errors. The default @typescript-eslint/recommended config doesn't account for common Lit/WebComponents patterns where underscore-prefixed variables indicate intentional non-use.
Changes
ESLint Configuration (eslint.config.mjs)
- Added
@typescript-eslint/no-unused-varsrule withargsIgnorePattern: '^_'andvarsIgnorePattern: '^_'(matches Lit framework convention) - Enabled
eslint-plugin-litwith rules:no-legacy-template-syntax,no-invalid-html,no-useless-template-literals - Replaced inline globals with
globalspackage forbrowserandes2021environments - Updated
ecmaVersionfrom12tolatest
Dependencies (package.json)
- Added
@eslint/eslintrc@^3.2.0(required forFlatCompat) - Added
globals@^15.14.0
Applied to both _base and _base_with_home project templates.
Example
// ✅ Now allowed - underscore indicates intentional non-use
private _cache: Map<string, any> = new Map();
private handleEvent(_event: Event): void { /* ... */ }
// ❌ Still caught - missing underscore prefix
const unusedVar = 1; // error: 'unusedVar' is assigned but never used
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
www.google-analytics.com
- Triggering command:
Ignite UI CLI(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
Original prompt
This section details on the original issue you should resolve
<issue_title>Lint errors in CLI generated app for WebComponents</issue_title> <issue_description>### Description
When you create a WC app through the CLI and you run lint test, no-unused-vars errors occur.Steps to reproduce
- Create a WebComponents application through the CLI
- Install the modules
- Run lint tests
Result
no-unused-vars errors are shown
Expected result
There should be no errors when you run the lint tests.
Attachments
</issue_description>
<agent_instructions>Let's first investigate which is the most common tool for linting a web components project. Then define which are the recommended lint rules to be set.</agent_instructions>
Comments on the Issue (you are @copilot in this section)
- Fixes IgniteUI/igniteui-cli#1291
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.