Skip to content

alphabetic order

tannerbaum edited this page Feb 26, 2020 · 3 revisions

alphabetic-order

This rule is fixable ✓

Why?/How?/Examples

Alphabetically ordered lists make it easier to find a specific script, especially with larger numbers of scripts. Look at this project's scripts (at the time of writing) and it becomes obvious:

{
    "build": "run-s build:clean build:scripts build:chmod",
    "build:chmod": "chmod +x ./dist/cli.js",
    "build:clean": "rimraf ./dist",
    "build:dev": "tsc -p tsconfig.build.json",
    "build:scripts": "tsc -p tsconfig.build.json",
    "dev": "run-s build other:watch",
    "format": "run-p test:self:fix test:lint:fix format:fix",
    "format:fix": "prettier --write tests/*.{ts,tsx} src/*.{ts,tsx}",
    "other:selfupdate": "updtr",
    "other:watch": "nodemon -e js,ts --watch src --exec 'run-p build:dev'",
    "prepublishOnly": "run-p build",
    "pretest": "run-s build",
    "start": "node dist/index.js",
    "test": "run-s test:exports test:lint test:types test:unit:ci test:self",
    "test:exports": "ts-unused-exports tsconfig.json --ignoreFiles src/index.ts",
    "test:lint": "eslint ./src ./tests --ext js,ts,tsx",
    "test:lint:fix": "eslint ./src ./tests --ext js,ts,tsx --fix",
    "test:self": "scriptlint",
    "test:self:fix": "scriptlint --fix",
    "test:types": "tsc -p tsconfig.json --noEmit true",
    "test:unit": "jest --coverage",
    "test:unit:ci": "jest --runInBand --coverage",
    "test:update": "jest -u",
    "test:watch": "jest --watch --coverage"
}

This rule's autofix will order the scripts alphabetically before saving the package.json.


scriptlint status
npm version badge
dependency badge
Issue badge
CI badge

Clone this wiki locally