# public-static-readonly

Rule `sonarjs/public-static-readonly`. Public "static" fields should be read-only

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1354 by reach, #655 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/public-static-readonly` | yes | suggestion | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-1444/) |

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/public-static-readonly": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/pseudo-random](https://lintradar.dev/rules/sonarjs/pseudo-random.md): Pseudorandom number generators (PRNGs) should not be used in security contexts
- [sonarjs/publicly-writable-directories](https://lintradar.dev/rules/sonarjs/publicly-writable-directories.md): Temporary files should not be created in publicly writable directories
- [sonarjs/production-debug](https://lintradar.dev/rules/sonarjs/production-debug.md): Debugging features should not be enabled in production
- [sonarjs/reduce-initial-value](https://lintradar.dev/rules/sonarjs/reduce-initial-value.md): "Array.reduce()" calls should include an initial value
- [sonarjs/prefer-type-guard](https://lintradar.dev/rules/sonarjs/prefer-type-guard.md): Type predicates should be used
- [sonarjs/redundant-type-aliases](https://lintradar.dev/rules/sonarjs/redundant-type-aliases.md): Redundant type aliases should not be used

---

Web page: https://lintradar.dev/rules/sonarjs/public-static-readonly. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
