npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lint-suite/eslint-plugin-no-unused-angular-instance-fields

v1.1.0

Published

Disallow unread instance fields and methods in Angular components and directives

Downloads

285

Readme

@lint-suite/eslint-plugin-no-unused-angular-instance-fields

@lint-suite/eslint-plugin-no-unused-angular-instance-fields is an ESLint rule for Angular and TypeScript that reports unread component and directive instance fields and methods. Project analysis recognizes reads from TypeScript, Angular templates, and component or directive host metadata.

Requirements

  • Node.js 24
  • ESLint ^10.9.1
  • TypeScript 6.0.3 or newer
  • Angular compiler 22.1.5, installed with this plugin
  • typescript-eslint parser services for the default project analysis

Install

pnpm add -D @lint-suite/eslint-plugin-no-unused-angular-instance-fields eslint typescript typescript-eslint

Configure

// eslint.config.js
import angularInstanceFields from '@lint-suite/eslint-plugin-no-unused-angular-instance-fields';
import tseslint from 'typescript-eslint';

export default [
  {
    files: ['**/*.ts'],
    languageOptions: {
      parser: tseslint.parser,
      parserOptions: { projectService: true }
    },
    plugins: {
      'no-unused-instance-fields': angularInstanceFields
    },
    rules: {
      'no-unused-instance-fields/no-unused-instance-fields': 'error'
    }
  }
];

The default analysis: 'project' examines the TypeScript project, including reads from external templates and host bindings. It requires parser services with type information. Project-mode spec files are skipped. Set analysis: 'local' to inspect only the linted file when project-aware analysis is unavailable.

Options

type Options = {
  analysis?: 'local' | 'project';
  allowEffectFields?: boolean;
  allowRxjsInteropFields?: boolean;
};

allowEffectFields defaults to false. When true, effect fields with Angular's automatic cleanup are not reported.

allowRxjsInteropFields defaults to false. When true, unread fields holding @angular/core/rxjs-interop calls (toSignal, toObservable, outputToObservable, rxResource) are not reported.

Inputs, outputs, and queries (signal viewChild(), contentChildren(), and similar, or @ViewChild()-style decorators) are reported like other fields: only reads by the class, its template, and its host metadata count, not bindings from parent templates. These fields are always exempt:

  • decorated setters such as @Input() set value(v) or @ViewChild('box') set box(el);
  • outputFromObservable() fields and @Output() fields not initialized with new EventEmitter();
  • inputs (input(), model(), @Input()) of classes that declare ngOnChanges, whose changes['name'] reads the rule cannot see.
rules: {
  'no-unused-instance-fields/no-unused-instance-fields': [
    'error',
    { analysis: 'local', allowEffectFields: true }
  ]
}

The preceding configuration is non-default local mode: it does not inspect other project files. The examples below are checked by this rule alone. Examples labeled project mode require the projectService configuration above and all listed files in the TypeScript project; all other examples explicitly use local mode.

Examples

Valid examples

1. Field read by the component class

// card.component.ts — local mode
import { Component } from '@angular/core';
@Component({ template: '{{ label() }}' })
class CardComponent {
  readonly title = 'Card';
  label(): string { return this.title; }
}

2. Field read by an inline template

// card.component.ts — local mode
import { Component } from '@angular/core';
@Component({ template: '{{ title }}' })
class CardComponent {
  readonly title = 'Card';
}

3. Field read by host metadata

// card.component.ts — local mode
import { Component } from '@angular/core';
@Component({ host: { '[attr.aria-label]': 'label' }, template: '' })
class CardComponent {
  readonly label = 'Card';
}

4. Field read by an external template

// card.component.ts — project mode
import { Component } from '@angular/core';
@Component({ templateUrl: './card.component.html' })
class CardComponent { readonly title = 'Card'; }
<!-- card.component.html -->
<h1>{{ title }}</h1>

5. Dynamically indexed component

// card.component.ts — local mode
import { Component } from '@angular/core';
@Component({ template: '' })
class CardComponent {
  readonly title = 'Card';
  read(key: string): unknown { return this[key]; }
}

Invalid examples

1. Unread component field

// card.component.ts — local mode
import { Component } from '@angular/core';
@Component({ template: '' })
class CardComponent { readonly unused = 'remove me'; }

2. Unread component method

// card.component.ts — local mode
import { Component } from '@angular/core';
@Component({ template: '' })
class CardComponent { refresh(): void {} }

3. Unread injected field

// card.component.ts — local mode
import { Component, inject } from '@angular/core';
class CardService {}
@Component({ template: '' })
class CardComponent { private readonly service = inject(CardService); }

4. Unread directive field

// state.directive.ts — local mode
import { Directive } from '@angular/core';
@Directive({ selector: '[appState]' })
class StateDirective { private readonly state = 'idle'; }

5. Unread signal input

// card.component.ts — local mode
import { Component, input } from '@angular/core';
@Component({ template: '' })
class CardComponent { readonly title = input(''); }

6. Field no project file reads

// card.component.ts — project mode
import { Component } from '@angular/core';
@Component({ templateUrl: './card.component.html' })
class CardComponent { readonly hidden = 'remove me'; }
<!-- card.component.html -->
<p>Card</p>