# max-lines

Rule `sonarjs/max-lines`. Files should not have too many lines of code

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #2139 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/max-lines` | no | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-104/) |

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/max-lines": "error",
    },
  },
];
```

## Related rules

- [eslint/max-lines](https://lintradar.dev/rules/eslint/max-lines.md): Enforce a maximum number of lines per file
- [sonarjs/max-lines-per-function](https://lintradar.dev/rules/sonarjs/max-lines-per-function.md): Functions should not have too many lines of code
- [sonarjs/function-name](https://lintradar.dev/rules/sonarjs/function-name.md): Function and method names should comply with a naming convention
- [sonarjs/max-union-size](https://lintradar.dev/rules/sonarjs/max-union-size.md): Union types should not have too many elements
- [sonarjs/nested-control-flow](https://lintradar.dev/rules/sonarjs/nested-control-flow.md): Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
- [sonarjs/for-in](https://lintradar.dev/rules/sonarjs/for-in.md): "for...in" loops should filter properties before acting on them

---

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