lightsoutAlpha

folder-size

When a folder holds too many files.

Deterministic checkAdvises by default

The rule

Agents read this text as written when they write and review code.

A folder holds at most 20 files, not counting tests. This is true of every folder: a subject folder, a module folder and a common/.

  • Over 20: group related files into subject folders named for what they share.
  • 20 or fewer: make no subject folder inside a module folder or a common/.
  • A module folder counts as one file.
  • types/ and constants/ are exempt: they hold files only.

A long flat folder reads like a listing instead of a description of the product.

Examples

The check flags the incorrect code and passes the correct code. Each example is a small repo, because this rule looks across files. It opens on the file that matters; the other files are the repo around it.

Incorrect

srcbillingcommonformattingwide
src/billing/common/formatting/formatRate.ts
export const formatRate = ({ rate }: { rate: number }): string => `${rate}`;

Correct

srcnarrow
package.json
{
"name": "folder-size-pass-fixture",
"private": true
}

Configure

  • Block"blocking"Stops a run when a file the run changed breaks the rule.
  • Advise"advisory"Reports it and hands it to the refactor agent. Never stops a run.
    Default
  • Off"off"Not checked. Use it when your own linter already enforces the rule.

Add this to your lightsout.config.json, then change the value.

lightsout.config.json
{
"standards-rule-settings": {
"folder-size": {
"severity": "advisory",
"options": {
"cap": 20
}
}
}
}

Packs that select it