Skip to content
Moritz Jacobs edited this page Feb 25, 2020 · 15 revisions

Documentation


  1. Motivation
  2. The scriptlint "standard" tl;dr
  3. The scriptlint "standard"
    1. Rules enforceable via the scriptlint CLI
      1. Minimum rules
        1. mandatory-start
        2. mandatory-dev
        3. mandatory-test
        4. no-default-test
      2. Strict rules
        1. uses-allowed-namespace
        2. alphabetic-order
        3. natural-order
        4. correct-casing
        5. no-aliases
        6. prepost-trigger-defined
        7. no-unix-double-ampersand
        8. no-unix-single-ampersand
    2. Best practices
  4. The scriptlint CLI
    1. Installation
    2. Usage
    3. Configuration
    4. Extending
    5. Use as a JavaScript module
  5. Contributing to scriptlint

Motivation

package.json scripts are an integral part of the JavaScript dev experience: we use them to start our projects, run our dev environments and for all kinds of formatting, linting and tooling in general. They are just as important as our code. Yet we don't treat them with the same meticulous attention to detail. Scripts need ❤️ too!

One of the main goals for scriptlint, was to enable people to use memorable and consistent script names across their projects. Tools like nps are great when you have to organize scripts with a certain level of complexity, but they don't help you with the structure and naming of your scripts.

This is where the scriptlint CLI shines: it makes best practices outlined in this documentation enforceable throughout your project(s). Think of it as eslint for your "scripts" section.

"standard" TL;DR

Here's the tl;dr of all the best practices we consider the "scriptlint standard"

Your package.json's "scripts" section should…

  • have a test script that is not the default script from npm init
  • have a dev script and a start script
  • abstract script names from their implementation (test, not jest)
  • use namespaces to categorize scripts ("test:unit": "jest")
  • use : as a namespace separator
  • be in alphabetic or natural order
  • have a trigger script for all hooks (if you have preFoo, there must be a foo)
  • use camelCase for all script names
  • not alias devDependencies ("jest": "jest")
  • not use && or & for sequential or parallel script execution (doesn't work on all operating systems)

(italic = default rule, regular = "strict" rule)


scriptlint status
npm version badge
dependency badge
Issue badge
CI badge

Clone this wiki locally