Skip to content

Latest commit

 

History

History
101 lines (77 loc) · 1.71 KB

README.md

File metadata and controls

101 lines (77 loc) · 1.71 KB

License Lint

A linter for NPM package licenses to avoid dependencies that not compatible with license of your software. It can check licenses automatically on CI or on NPM postinstall.

Install

npm install -D @rambler-tech/licenselint

or

yarn add -D @rambler-tech/licenselint

Usage

licenselint --help

  Lint NPM package licenses

  Usage
    licenselint [dirname]

  Options
    --production    Only lint production dependencies
    --development   Only lint development dependencies
    --summary       Output a summary of the license usage
    --deny          Fail on an occurrence of the licenses of the deny list
    --allow         Fail on an occurrence of the licenses not in the allow list
    --exclude       Exclude modules which licenses are in the list
    --extends       Use custom configuration file

  Examples
    licenselint
    licenselint packages/foo
    licenselint --production
    licenselint --deny LGPL
    licenselint --allow MIT --allow ISC
    licenselint --extends shared/licenserc.json

Then use it for automatically check in CI

...
lint deps:
  stage: test
  script:
    - npm install
    - licenselint
...

Or on NPM postinstall

{
  "name": "app",
  "description": "...",
  "version": "0.1.2",
  "scripts": {
    "...": "...",
    "postinstall": "licenselint"
  },
  "...": "..."
}

Configuration

Create .licenserc.json configuration file:

{
  "production": true,
  "deny": [
    "GPL",
    "LGPL"
  ]
}

Configuration file supports all CLI flags.

Also you can extends your local setup with shared configuration:

{
  "extends": "@shared/licenserc",
  "summary": true
}

License

MIT