Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

aberlaas

pixelastic1.2kMIT2.14.0

Scaffold your JavaScript projects with tests, lint and release scripts

readme

aberlaas

Scaffold your JavaScript projects with consistent config for tests, lint, release and CI.

aberlaas is a wrapper around Jest, ESLint, Prettier, etc and their plugins so you only install one package in your devDependencies instead of dozens.

I created this module because I got tired of copy-pasting the same configuration files from project to project. With one meta module to handle all the tooling, I could get started on a new project in minutes instead of hours.

Using aberlaas on every project ensured my linting rules and release process is consistent across my projects. Of course, if you don't like the defaults it's shipped with, you can override them as all configuration files are exposed.

Installation

yarn add --dev aberlaas

yarn run aberlaas init

This will add aberlaas to your devDependencies and bootstrap your project. Config files for all the tools will be created (.eslintrc.js, jest.config.js, etc) and new yarn run scripts will be added for the most common tasks (lint, test, release, etc).

At that point, you should probably commit all the changes.

(Optional) Setup the external services

yarn run aberlaas setup

This will configure third party services like GitHub and CircleCI to work better with aberlaas.


The following table lists all the scripts added:

Script Description
yarn run test Run tests using Jest
yarn run test:watch Run tests using Jest in watch mode
yarn run ci Run testing and linting in CI
yarn run release Release the module on npm

Testing (with Jest)

aberlaas test to run all the Jest tests in ./lib. You can alter the behavior with the following options:

CLI Argument Default value Description
[...] ./lib Files and directories to test.
--config jest.config.js Jest config file to use
--watch false If enabled, will listen for changes on files and rerun tests
--failFast false If enabled, will stop as soon as one test fails

Note that you can also pass any other command-line flag and they will be passed directly to Jest under the hood.

Jest is loaded with jest-extended allowing you to use new matchers like .toBeString(), .toStartWith(), etc.

New global variables

testName is available in all tests and contains the name of the current it/test block.

captureOutput allows to swallow any stdout/stderr output for later inspection. Output is stripped of any trailing newlines and ANSI characters.

const actual = await captureOutput(async () => {
  console.log('foo');
});
// actual.stdout = ['foo']

dedent is included in all tests, so you can write multiline strings without having to break your indentation.

describe('moduleName', () => {
  describe('methodName', () => {
    it('should test a multiline string', () => {
      const input = dedent`
        Leading and trailing lines will be trimmed, so you can write something like
        this and have it work as you expect:

          * how convenient it is
          * that I can use an indented list
             - and still have it do the right thing`;
      // …
    });
  });

Precommit hooks

aberlaas uses lint-staged to make sure all committed code follows your coding standard.

All css, js, json and yml files will be checked for parsing errors (using aberlaas lint internally), and if errors are found it will attempt to automatically fix them. If errors persist, it will prevent the commit and let you know which file contains errors so you can fix them before committing again.

Whenever you commit a .js file that has a test attached (or a test file directly), aberlaas test will be run on those files. If the tests don't pass, your commit will be rejected.

Those two measures ensure that you'll never "break the build", by committing invalid files or code that does not pass the test. If you want to ignore this behavior, you can always add the -n option to your git commit command to skip the hooks.

Releasing

aberlaas release will release the package to npm. It will update the version in package.json as well as creating the related git tag.

When called without arguments, it will prompt you for the next version to package. If called with an argument, this will be used as the next version number (for example, yarn run release 1.1.3). You can also use SemVer increments (for example, yarn run release minor).

Use --dry-run to start a dry-run. It will simulate a release but won't actually push anything to GitHub or npm.

Continuous Integration

aberlaas ci is triggered by CI Servers (currently only CircleCI is supported), and won't do anything when run locally.

When on a CI server it will first display the current node and yarn version, and then test and lint scripts in that order. It will fail whenever one of them fails, or succeed if they all succeed.

The node and yarn version used both locally and on the CI server will be the same. A .nvmrc file is created when running yarn run aberlaas init that will force local users to use the specified version. The same version is also specified in the Docker image pulled by CircleCI. As for Yarn, a local copy of the whole yarn program is added to the repository when first initializing it, so both locals and CI servers will use it.

By default, tests running on the CI will be parallelized on two CPUs (this is what most free CI tier offer). If you have access to higher end machines, you can update this value by passing the --cpu-count=X flag to your aberlaas ci call.

Auto-Releasing

As an optional feature, you can have aberlaas automatically release a new version of your module from the CI environment when relevant.

The CI will then check all the commits since the last release. If any commit is a feat() it will release a new minor version; it any commit is a fix() it will release a new patch version. For major release, you'll have to do it manually.

This option is not enabled by default. If you need it, you need to follow those steps:

  • Run aberlaas setup --auto-release. It will setup the required ENV variables and ssh keys
  • Update your aberlaas ci script to aberlaas ci --auto-release
  • Uncomment the add_ssh_keys in your .circleci.yml file

File structure

./lib/configs contain the default configuration for all the tools. They are exported by the package and thus can be required in userland.

./templates contains default configurations files copied to userland. Each extends the configuration exported in the previous files. Copying files to userland allows user to change the files if they want to change the behavior.

.eslintrc.js, .stylelintrc.js and jest.config.js are local configuration files for aberlaas itself. They eat their own dog food by referencing the same configs as above.

Where does the name Aberlaas come from?

Aberlaas is the base camp from which all great expedition start in the La Horde du Contrevent book. I felt it's a great name for a bootstrapping kit for modules.

For your convenience, aberlass and aberlas are added as aliases by default.

Documentation

The complete documentation can be found on https://projects.pixelastic.com/aberlaas/

changelog

0.11.4 (2020-01-17)

Bug Fixes

  • init: Actually call setDefaultName (8c9797f)
  • lint: Stop ignoring unused _ variable (54c1b8d)

0.11.3 (2020-01-15)

Bug Fixes

  • deps: update babel monorepo to v7.8.0 (f6f2a9f)
  • deps: update babel monorepo to v7.8.3 (6cadf1e)
  • deps: update dependency @babel/preset-env to v7.8.2 (e1daba3)
  • deps: update dependency eslint-plugin-jest to v23.5.0 (bb01d26)
  • deps: update dependency eslint-plugin-jest to v23.6.0 (fca63b5)
  • deps: update dependency eslint-plugin-jsdoc to v20.2.0 (e96689d)
  • deps: update dependency eslint-plugin-jsdoc to v20.3.0 (6d88d3f)
  • deps: update dependency eslint-plugin-jsdoc to v20.3.1 (48ffe13)

Features

  • eslint: Don't warn for unused _vars (563d277)

0.11.2 (2020-01-11)

Bug Fixes

  • deps: update dependency eslint-plugin-import to v2.20.0 (cc19762)
  • deps: update dependency eslint-plugin-jest to v23.4.0 (1080b33)
  • deps: update dependency eslint-plugin-jsdoc to v20.0.4 (dae2f4b)
  • deps: update dependency eslint-plugin-jsdoc to v20.0.5 (502ef99)
  • deps: update dependency eslint-plugin-jsdoc to v20.1.0 (ac8b3f6)

Features

  • init: Set a default package name on aberlaas init (ae082ee)

0.11.1 (2020-01-08)

Bug Fixes

  • deps: update dependency eslint-plugin-jest to v23.3.0 (f37b4ac)
  • deps: update dependency eslint-plugin-jsdoc to v20.0.1 (64db994)
  • deps: update dependency eslint-plugin-jsdoc to v20.0.2 (e6f0bb1)
  • deps: update dependency eslint-plugin-jsdoc to v20.0.3 (9462429)
  • deps: update dependency firost to v0.21.0 (3e0b6a5)

Features

  • init: Set a default v0.0.1 (702b9d4)

0.11.0 (2020-01-03)

Bug Fixes

  • ci: Set absolute path in spy (e423d9e)
  • deps: update babel monorepo to v7.7.7 (ea2125a)
  • deps: update dependency eslint-config-prettier to v6.9.0 (b33d003)
  • deps: update dependency eslint-plugin-jest to v23.2.0 (3fa68fd)
  • tests: Create ./tmp/release folder before moving to it (a4a3d20)

0.10.9 (2020-01-03)

0.10.8 (2020-01-03)

Features

0.10.7 (2020-01-03)

Features

  • circleci: Use extended yaml syntax by default (662d086)

0.10.6 (2020-01-02)

Features

  • lint: Enforce dot notation in JavaScript (613aaac)

0.10.5 (2019-12-18)

Features

  • ci: Fix node to v12.12.0 (4dee77d)

0.10.4 (2019-12-18)

Bug Fixes

  • ci: Correctly scope the call to yarnRun (b810073)

0.10.3 (2019-12-17)

Bug Fixes

  • lint: Do not fail css linting if file not found (070c873)

0.10.2 (2019-12-02)

Bug Fixes

  • init: Fix spinner never ending (e278efc)

Features

  • lint: Allow importing aberlaas/ from templates (399f733)

0.10.1 (2019-11-29)

Features

  • node: Downgrade to node 12 instead of node 13 (09a0325)

0.10.0 (2019-11-27)

Bug Fixes

  • deps: update dependency firost to v0.19.0 (057c3e5)

Features

  • release: Git pull before release (25f5605)
  • release: Update meta release sript (40e94f0)

0.9.3 (2019-11-27)

Bug Fixes

  • deps: update dependency firost to v0.17.1 (502eb4d)
  • deps: update dependency golgoth to v0.6.1 (334dec4)
  • test: captureOutput correctly flushes after errors (cf72c89)

0.9.2 (2019-11-27)

Bug Fixes

  • deps: update dependency eslint-plugin-jest to v23.0.5 (e900e2d)
  • deps: update dependency lint-staged to v9.5.0 (2b34d39)
  • init: Do not pin engine in package.json (e8afa8c)

Features

  • init: Add progress spinner (70650b5)
  • release: Pull remote before releasing (61fa9d3)

0.9.1 (2019-11-26)

Features

  • ci: Add CircleCI config to init script (5ba7fd7)

0.9.0 (2019-11-26)

Bug Fixes

  • ci: Don't treat Renovate PRs any differently (bdb2a29)
  • ci: Force isRenovatePR to false in tests (4193804)
  • deps: update babel monorepo to v7.7.4 (f4e16ca)
  • deps: update dependency eslint to v6.7.1 (e39b2f8)
  • deps: update dependency eslint-config-prettier to v6.7.0 (315e1bf)
  • deps: update dependency eslint-plugin-jest to v22.21.0 (5a952c1)
  • deps: update dependency eslint-plugin-jest to v23 (27067a2)
  • deps: update dependency eslint-plugin-jsdoc to v15.12.2 (edd3463)
  • deps: update dependency eslint-plugin-jsdoc to v18 (28c3ead)
  • deps: update dependency eslint-plugin-prettier to v3.1.1 (045d45a)
  • deps: update dependency execa to v3 (55ad68d)
  • deps: update dependency firost to v0.17.0 (2793e9a)
  • deps: update dependency release-it to v12.4.3 (5b8ebe3)
  • deps: update dependency stylelint to v11.1.1 (50e8522)
  • deps: update dependency stylelint to v12 (a2d0aac)
  • init: Remove yarnrc (4a1d9de)
  • lint: Change order of checks (6fc0f21)

Features

  • ci: Add ci command (00e28a8)
  • ci: Add circleci integration (8990b2e)
  • ci: Skip redundant build (5cbc4bb)
  • lint: Update eslint plugin for jest (b0fa89d)

0.8.1 (2019-11-24)

Features

  • lint: Always validate circleci on itself (3a3617f)

0.8.0 (2019-11-24)

Bug Fixes

  • deps: update dependency execa to v2.1.0 (538f594)
  • deps: update dependency husky to v3.1.0 (fc295fe)

Features

  • lint: Add linting of circleci config (1357222)

0.7.3 (2019-11-22)

Bug Fixes

  • deps: update dependency golgoth to v0.5.1 (7f59d6d)
  • deps: update dependency lint-staged to v9.4.3 (#30) (8879c11)

0.7.2 (2019-11-20)

Features

  • release: Attempt to build before releasing (f66f054)

0.7.1 (2019-11-20)

Features

  • renovate: Try to update deps as soon as possible (4cacb96)
  • test: Expose testName in each Jest test (0284b61)
  • test: Use lodash instead of lodash-es in tests (18faa4c)

0.7.0 (2019-11-06)

Bug Fixes

  • lint: Correctly exit when lint fixing still has errors (e312973)

0.6.10 (2019-10-30)

Bug Fixes

  • lint: Prevent shadowing variables in JS (76fc92b)

0.6.9 (2019-10-22)

Bug Fixes

  • lint: Revert husky logic. Test all files at once (a77279f)

0.6.8 (2019-10-22)

Bug Fixes

  • lint: Fixing of files displays the file that errored (e9367b4)

Features

  • lint: Use single quotes in CSS (f0f6dd4)

0.6.7 (2019-10-17)

Features

  • renovate: Default to silent merging on renovate (68d51a4)

0.6.6 (2019-10-12)

Bug Fixes

  • husky: Correctly name the template file (97240a8)

0.6.5 (2019-10-12)

Bug Fixes

  • husky: Rename "precommit" to "husky:precommit" script (326db9c)

0.6.4 (2019-10-10)

Features

  • release: Add changelog to release notes (2e97865)

0.6.3 (2019-10-10)

Bug Fixes

  • release: Revert testing before release. Add to script instead (2d21931)

0.6.2 (2019-10-10)

Bug Fixes

  • deps: update dependency golgoth to v0.4.2 (#19) (1ddaea8)
  • release: Automatically test and build before release (3cb9456)
  • release: Set build to true by default in release (27ebbaf)

Features

  • release: Test code before release (36a8aae)

0.6.0 (2019-10-09)

Features

  • lint: Add lint-staged for precommits (e79e99e)
  • precommit: Add better handling of changed files (16980d9)

0.5.1 (2019-10-08)

0.5.0 (2019-10-08)

Bug Fixes

  • helper: Fix spawning of node binaries (d0516df)

Features

0.4.11 (2019-10-05)

Bug Fixes

  • deps: update dependency husky to v1.3.1 (13c88f7)

Features

  • init: Add renovate config by default (24ab155)
  • renovate: Configure renovate (598bd8e)
  • renovate: Enable automerge (041e102)

0.4.10 (2019-10-04)

Bug Fixes

  • init: Stop adding LICENSE to list of released files (by default) (52e0ee7)
  • release: Exits with code 1 on error (bec6a81)

0.4.9 (2019-09-26)

Features

  • lint: Allow importing .pug files, but warn if do not exist (1491abd)

0.4.8 (2019-09-25)

0.4.7 (2019-09-25)

0.4.6 (2019-09-25)

Features

  • test: Set Jest to correct version (f1dc7a9)

0.4.5 (2019-09-25)

Bug Fixes

  • test: Re-disnable Jest cache (7247605)

Performance Improvements

  • jest: Update to Jest head and enable cache to fasten tests (10716ab)

0.4.4 (2019-09-24)

Bug Fixes

  • husky: Only define hooks if matching script exists (a02c613)

0.4.3 (2019-09-20)

0.4.2 (2019-09-20)

Bug Fixes

  • test: Make jest-extended always loaded (46a555b)

0.4.1 (2019-09-19)

0.4.0 (2019-09-17)

Features

  • init: Adds a LICENSE file on init (0c18312)

0.3.1 (2019-09-10)

Bug Fixes

  • lint: Force disabling no-console (6722ace)

0.3.0 (2019-08-27)

Bug Fixes

  • lint: Fix linting of several json files (008a8ee)

0.2.2 (2019-08-22)

Features

  • jest: Add jest-extended (6b15865)

0.2.1 (2019-08-11)

Bug Fixes

  • init: Fix typo in method name (965384a)

0.2.0 (2019-08-11)

Features

  • init: Update init method (33657da)

0.1.10 (2019-08-02)

0.1.9 (2019-08-02)

Bug Fixes

  • config: Fallback to configs in build/ folder in aberlaas (ad8364d)

Features

  • lint: Allow passing specific confifs per linter (b318b52)
  • test: Setting default testEnvironment to node instead of jsdom (87e4112)

0.1.8 (2019-07-24)

0.1.7 (2019-07-24)

Bug Fixes

  • test: Correctly allow passing files to test (58ecb13)

0.1.6 (2019-07-19)

Features

  • release: Better warn if release can't be done properly (8b360c7)

0.1.5 (2019-07-17)

0.1.4 (2019-07-17)

0.1.3 (2019-07-16)

0.1.2 (2019-07-05)

0.1.1 (2019-07-04)

Bug Fixes

  • lint: Add json-fix script (92e809a)

0.1.0 (2019-07-04)

0.0.41 (2019-07-03)

Features

  • folders: Exclude vendors folder by default (13553b1)

0.0.40 (2019-07-03)

Bug Fixes

  • install: Update installer to add lint-js script (62e8ea9)
  • release: Allow releasing a specific patch/minor/major (16dc1df)
  • test: Make sure we return an array of path and not a string (e4a16ec)
  • test: Run test on host dir by default (c41ef64)

Features

  • lint: Add linting of CSS files through Stylelint (8f49aca)
  • lint: Allow linting of JSON files as well (4401ca0)
  • lint: Better finding of js/json files for linting (c093cc4)
  • lint: Fixes CSS files (5940d29)
  • lint: Update stylelint rules (2190bfd)

0.0.39 (2019-06-21)

Bug Fixes

  • lint: Allow double quotes if contains single quote (a9478aa)

0.0.38 (2019-06-21)

Features

  • lint: Disable some ESLint/Jest rules (d587d45)

0.0.37 (2019-06-20)

Bug Fixes

  • lint: Exclude build, node_modules and tmp from watch at any depth (0ce9fa5)

0.0.36 (2019-06-19)

0.0.35 (2019-06-19)

Features

  • eslint: Allow indentation in JSDoc (782ee83)

0.0.34 (2019-06-19)

Bug Fixes

  • eslint: Allow type 'promise' (7680b7a)

0.0.33 (2019-06-19)

Features

  • jsdoc: Adding linting of JSDoc back (c8d915d)

0.0.32 (2019-06-18)

Features

  • lint: Allow passing custom config file to lint script (adb4b57)

0.0.31 (2019-06-18)

Bug Fixes

  • lint: Expand input globs for lint command (73f585f)

0.0.30 (2019-06-14)

Features

  • eslint: Ignore line-length because of strings (96ab7af)

0.0.29 (2019-06-14)

Bug Fixes

  • lint: Actually lint files (f7adfd4)

0.0.28 (2019-06-14)

0.0.27 (2019-06-13)

Bug Fixes

  • build: Fix own build script (fc112ad)

0.0.26 (2019-06-11)

Bug Fixes

  • deps: Load firost directly (142e630)

0.0.25 (2019-06-11)

0.0.24 (2019-06-11)

0.0.23 (2019-05-02)

0.0.22 (2019-04-24)

0.0.21 (2019-04-23)

0.0.20 (2018-12-23)

0.0.19 (2018-12-23)

0.0.18 (2018-12-21)

Bug Fixes

  • tests: Stop watching files in ./tmp, ./node_modules and ./build (3ade66f)

0.0.17 (2018-12-21)

0.0.16 (2018-12-21)

Bug Fixes

  • babel: Use babel.config.js instead of .babelrc.js (e57ac69)

Features

  • release: Allow passing the semver part to update in release (3418b6a)

0.0.15 (2018-11-30)

Bug Fixes

  • templates: Templates correctly reference build files (bb80093)

0.0.14 (2018-11-28)

Bug Fixes

  • lint: Fix hidden js files (4e2db79)

0.0.13 (2018-11-28)

Features

  • husky: Eat our own dog food and use husky (1c912dc)

0.0.12 (2018-11-16)

Bug Fixes

  • lint: Correctly exit with error code if linting fails (5a62573)

0.0.11 (2018-11-15)

Bug Fixes

  • test: Don't fail if no tests defined (aad27dc)

0.0.10 (2018-11-15)

0.0.9 (2018-11-07)

0.0.8 (2018-11-05)

0.0.7 (2018-11-03)

0.0.6 (2018-11-03)

0.0.5 (2018-11-02)

0.0.4 (2018-11-02)

0.0.3 (2018-10-31)

0.0.2 (2018-10-29)