开发者社区> 镜像站> NPM> amper-scripts
amper-scripts
GS&F dev scripts
Last updated 5 months ago by blakek .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install amper-scripts 
SYNC missed versions from official npm registry.

amper-scripts

⏩ some tools to make project setup easier

Why

  • Create one set of basic standards and re-use them everywhere.
  • Easily opt-out: any detected config file automatically overrides defaults.
  • Easily extend: config files are made to be basic and extendable.
  • One command can get a decent baseline for testing on your CI servers.

Install

Using Yarn:

$ yarn add -D amper-scripts

…or using npm:

$ npm i --save-dev amper-scripts

Usage

Setting up in a project

A lot of setup is included, but you'll need to do a little setup. This is because your text editor likely expects config files to be in the project directory.

First, install using one of the commands above.

Quick setup

Add or update your .eslintrc.js:

module.exports = require('amper-scripts/config/eslint');

Add or update your prettier.config.js:

module.exports = require('amper-scripts/config/prettier.config.js');

Change scripts in your package.json or CI/CD setup to run this instead of eslint or prettier:

{
  "scripts": {
    "lint": "amper-scripts lint",
    "format": "amper-scripts format-write",
    "validate": "amper-scripts validate"
  }
}

Using different settings

Most commands allow you to extend or opt-out of the default config. In most cases to opt-out, just write the config file as you normally would and it'll be picked up.

Example: Extending ESLint config:

module.exports = {
  extends: [require.resolve('amper-scripts/config/eslint')],
  rules: {
    /* your custom rules */
  }
  // you can also change any other settings, such as `env`
};

Example: Extending Prettier config

const gsandfDefaults = require('amper-scripts/config/prettier.config.js');

module.exports = {
  ...gsandfDefaults
  // your rules
};

Getting help

If you ever forget what commands are available, just ask for help:

$ amper-scripts --help

If you need help on a specific command, run the help script:

$ amper-scripts help [command]

Enforcing code formatting

Check project code formatting using Prettier and list any differing files:

$ amper-scripts format-check

Enforce code formatting using Prettier, overwriting differing files:

$ amper-scripts format-write

Or, just get vanilla Prettier with the default config and ignore applied:

$ amper-scripts format [arguments]

Override the Prettier config by adding any allowed config file. The configuration is not merged; any detected configuration file is used as the base.

Catching code errors

Lint the project using ESLint:

$ amper-scripts lint

Override linting rules by adding any configuration file allowed by ESLint. The configuration is not merged; any detected configuration file is used as the base.

To extend the config in this repo, see "using different settings" above.

Additional arguments are passed to ESLint. For example, you can specify files to validate:

$ amper-scripts lint ./source

Validating project

This runs commands to generally check the project (i.e. lint, format-check) all at once. This is good for CI servers because it's fast, exits if anything fails, and is oriented toward showing you where errors occur:

$ amper-scripts validate

You can opt-out of individual steps as needed:

$ amper-scripts validate --no-lint

Use amper-scripts help validate for all available options.

Current Tags

  • 1.0.0-1                                ...           latest (5 months ago)
  • 1.0.0-0                                ...           next (10 months ago)

13 Versions

  • 1.0.0-1                                ...           5 months ago
  • 1.0.0-0                                ...           10 months ago
  • 0.0.4-7                                ...           10 months ago
  • 0.0.4-6                                ...           a year ago
  • 0.0.4-5                                ...           a year ago
  • 0.0.4-4                                ...           a year ago
  • 0.0.4-3                                ...           a year ago
  • 0.0.4-2                                ...           a year ago
  • 0.0.4-1                                ...           a year ago
  • 0.0.4-0                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (9)
Dev Dependencies (0)
None
Dependents (0)
None