sort-scripts

July 12, 2026 ยท View on GitHub

๐Ÿ“ Enforce alphabetical ordering of scripts.

๐Ÿ”ง This rule is automatically fixable by the --fix CLI option.

Alphabetically sorted scripts are easier to scan and produce cleaner diffs when adding or removing commands. ESLint's package.json conventions require script names to appear in alphabetical order.

The fixer preserves script names and commands while rebuilding their object with the file's indentation and newline style. npm identifies scripts by name, so reordering them does not change when they run.

Examples

// โŒ
{
	"scripts": {
		"test": "node --test",
		"build": "tsc"
	}
}
// โœ…
{
	"scripts": {
		"build": "tsc",
		"test": "node --test"
	}
}