Friday, 14 September 2018

Distributing NPM Scripts With A Package For Use By Project Installing It

I have moved all my linting configuration and related packages/plugins/presets (for prettier, stylelint, eslint, commitlint) out to an npm package. I then use this package in multiple projects and extend or merge over the config into local configuration files for the projects to ensure consistency and remove the need for installing and keeping my development dependencies up to date.

Alongside the config I have a number of useful npm scripts that run the linters and perform a variety of other development related functionality, for example:

"lint:prettier": "prettier 'src/**/*.{js,json}' --write",
"lint:eslint": "eslint 'src/**/*.js'",
"lint:compatibilityCheck": "eslint --print-config .eslintrc.js | eslint-config-prettier-check",
"lint": "npm run lint:compatibilityCheck && npm run lint:prettier && npm run lint:eslint"

These are currently duplicated across all my projects, but I'd like to distribute these scripts along with my shared package so they are defined in a single location. How should I do this?



from Distributing NPM Scripts With A Package For Use By Project Installing It

No comments:

Post a Comment