igniteui-cli icon indicating copy to clipboard operation
igniteui-cli copied to clipboard

Configure ESLint for WebComponents templates to allow underscore-prefixed unused variables

Open Copilot opened this issue 4 months ago • 1 comments

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-vars rule with argsIgnorePattern: '^_' and varsIgnorePattern: '^_' (matches Lit framework convention)
  • Enabled eslint-plugin-lit with rules: no-legacy-template-syntax, no-invalid-html, no-useless-template-literals
  • Replaced inline globals with globals package for browser and es2021 environments
  • Updated ecmaVersion from 12 to latest

Dependencies (package.json)

  • Added @eslint/eslintrc@^3.2.0 (required for FlatCompat)
  • 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:

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

  1. Create a WebComponents application through the CLI
  2. Install the modules
  3. Run lint tests

Result

no-unused-vars errors are shown

Expected result

There should be no errors when you run the lint tests.

Attachments

image </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.

Copilot avatar Nov 07 '25 10:11 Copilot

Coverage Status

coverage: 70.369%. remained the same when pulling 936277e548c9987e5c4b5b48a8e0a8bc92ae1ddb on copilot/fix-lint-errors-webcomponents-app into 549f80ad16d6f22b3ddfb8d7b3344163dc5a1d34 on master.

coveralls avatar Nov 19 '25 11:11 coveralls