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-readonly-type-properties

v1.0.2

Published

Require readonly primitive type properties and mutable array syntax

Readme

@lint-suite/eslint-readonly-type-properties

An ESLint rule for TypeScript type and interface property signatures. It requires readonly on primitive-valued properties and writes readonly array syntax as mutable T[], so a type's property mutability is explicit without redundant array immutability.

Install

Requires Node.js 24+, ESLint ^10.9.1, and TypeScript >=6.0.3.

pnpm add -D @lint-suite/eslint-readonly-type-properties eslint@^10.9.1 typescript@">=6.0.3" typescript-eslint

The plugin does not configure a TypeScript parser. Use typescript-eslint for TypeScript files:

// eslint.config.js
import readonlyTypeProperties from '@lint-suite/eslint-readonly-type-properties';
import tseslint from 'typescript-eslint';

export default [
  {
    files: ['**/*.ts'],
    languageOptions: { parser: tseslint.parser },
    plugins: { readonlyTypeProperties },
    rules: { 'readonlyTypeProperties/readonly-type-properties': 'error' }
  }
];

Options

This rule has no options.

Scope and exemptions

The rule checks TypeScript property signatures only: type aliases, interfaces, and inline object types. It does not check class fields, object-literal properties, methods, mapped types, or index signatures.

Only primitive keyword types (string, number, boolean, bigint, symbol, null, and undefined), literal and template-literal types, and unions or intersections made entirely from those types require readonly. Array, tuple, function, type-reference, unknown, any, object, keyof, typeof, and generic-parameter properties are exempt. readonly T[] and one-argument ReadonlyArray<T> are always reported, with a suggestion to write T[], independently of property signatures.

Fixes

A missing readonly is offered as an editor suggestion, not an autofix: the rule cannot see code that assigns the property, possibly in another file, and adding readonly there would break compilation (TS2540). eslint --fix therefore leaves property signatures unchanged; apply the suggestion where the property is never written, or disable the rule on that line where mutation is required.

The readonly array forms are also suggestions, not autofixes, for the same reason: the rule cannot see what is assigned to the type, possibly in another file, and rewriting readonly T[] or ReadonlyArray<T> to T[] breaks compilation (TS4104) where a readonly value, such as an as const array or an Object.freeze result, flows into it. eslint --fix leaves them unchanged; apply the suggestion where only mutable arrays are assigned, or disable the rule on that line.

Examples

Each snippet below is checked by this rule alone, not by an entire ESLint configuration.

Valid examples

1. Readonly primitive properties

type User = { readonly name: string; readonly active: boolean };

2. Readonly optional property

interface Settings {
  readonly theme?: string;
}

3. Readonly literal union

type Request = { readonly method: 'GET' | 'POST' };

4. Array-valued property exemption

type Group = { members: string[] };

5. Type-reference property exemption

type Session = { owner: User };

Invalid examples

1. Mutable string property

type User = { name: string };

Add readonly before name; the rule suggests this edit.

2. Mutable interface number property

interface Counter {
  count: number;
}

Add readonly before count.

3. Mutable literal-union property

type Request = { method: 'GET' | 'POST' };

Add readonly before method.

4. Mutable nullable primitive property

type Record = { id: string | null };

Add readonly before id.

5. Readonly array type syntax

type Names = readonly string[];

Use string[]; the rule suggests this edit.

6. ReadonlyArray syntax

type Group = { members: ReadonlyArray<string> };

Use string[]; the rule suggests this edit.

The named readonlyTypePropertiesRule export is for composed plugin registries.