<repo_name>Casecommons/lint-config-javascript<file_sep>/docker-compose.yml
version: '3'

services:
  app:
    build:
      context: .
      dockerfile: ./Dockerfile
      args:
        ARTIFACTORY_API_KEY:
        ARTIFACTORY_USER:
    command: 'tail -f /dev/null'
    environment:
      NODE_ENV: development
    volumes:
      - .:/app
      - node_modules:/app/node_modules

volumes:
  node_modules:
<file_sep>/Dockerfile
FROM node:6.13-alpine

# Setup environment
ARG ARTIFACTORY_API_KEY
ARG ARTIFACTORY_USER
ENV APP_ROOT /app

# Create app dir
RUN mkdir $APP_ROOT
WORKDIR $APP_ROOT

# Configure NPM for Artifactory
RUN true \
  && apk add --no-cache --virtual .deps-npm-config curl \
  && touch ~/.npmrc \
  && echo "package-lock=false" >> ~/.npmrc \
  && echo "registry=https://casecommons.jfrog.io/casecommons/api/npm/npm/" >> ~/.npmrc \
  && echo "save-exact=true" >> ~/.npmrc \
  && (test -n "$ARTIFACTORY_API_KEY" || (echo "FATAL: missing ARTIFACTORY_API_KEY" >&2; exit 1)) \
  && (test -n "$ARTIFACTORY_USER" || (echo "FATAL: missing ARTIFACTORY_USER" >&2; exit 1)) \
  && curl --user "${ARTIFACTORY_USER}":"${ARTIFACTORY_API_KEY}" https://casecommons.jfrog.io/casecommons/api/npm/auth >> ~/.npmrc \
  && apk del .deps-npm-config

# Install application dependencies
COPY package.json $APP_ROOT
RUN true \
  && apk add --no-cache --virtual .deps-yarn-install git \
  && rm -rf node_modules \
  && yarn install --no-progress \
  && apk del .deps-yarn-install

# Copy app
COPY . $APP_ROOT
<file_sep>/bin/release
#!/bin/bash

set -e

fatal() {
  echo "FATAL: $1" >&2
  exit 1
}

version() {
  docker-compose run --rm app node -e 'console.log(require("./package.json").version)' | tr -d ' \r\n'
}

# Check state
git fetch || fatal 'Could not fetch remote Git'
git fetch --tags || fatal 'Could not fetch remote Git'
[[ -z "$(git status --porcelain)" ]] || fatal 'Working tree not clean'
[[ "$(git rev-parse --abbrev-ref HEAD)" = "master" ]] || fatal 'Not on master branch'
git diff --quiet HEAD '@{u}' || fatal 'Branch is not up-to-date with remote'

# Publish package
docker-compose run --rm app yarn publish --no-git-tag-version

# Create commit and tag, and push
version="$(version)"
git add package.json
git commit -m "v$version"
git tag -a -m "v$version" "v$version"
git push origin HEAD
git push origin "v$version"
<file_sep>/eslintrc-test.js
module.exports = {
  "extends": [
    "@casecommons/eslint-config/eslintrc-base",
  ],
  "rules": {
    "no-magic-numbers": [0],
    "react/prop-types": [0],
  },
}
<file_sep>/eslintrc-modern.js
module.exports = {
  "env": {
    "commonjs": true,
    "es6": true,
  },
  "extends": [
    "@casecommons/eslint-config/eslintrc-base",
  ],
  "parserOptions": {
    "ecmaFeatures": {
      "experimentalObjectRestSpread": true,
      "jsx": true,
      "modules": true,
    },
    "ecmaVersion": '2017',
    "sourceType": "module",
  },
  "plugins": [
    "react",
  ],
  "rules": {
    "arrow-body-style": [2, "as-needed"],
    "arrow-parens": [2, "always"],
    "arrow-spacing": [2],
    "constructor-super": [2],
    "generator-star-spacing": [2, "after"],
    "jsx-quotes": [2, "prefer-single"],
    "no-class-assign": [2],
    "no-confusing-arrow": [2, {"allowParens": true}],
    "no-const-assign": [2],
    "no-dupe-class-members": [2],
    "no-this-before-super": [2],
    "no-var": [2],
    "prefer-arrow-callback": [2],
    "prefer-const": [2],
    "prefer-spread": [2],
    "prefer-template": [2],
    "react/display-name": [2],
    "react/jsx-closing-bracket-location": [2, "tag-aligned"],
    "react/jsx-curly-spacing": [2, "never"],
    "react/jsx-indent-props": [2, 2],
    "react/jsx-no-duplicate-props": [2],
    "react/jsx-no-undef": [2],
    "react/jsx-uses-react": 1,
    "react/jsx-uses-vars": 1,
    "react/no-danger": [2],
    "react/no-did-mount-set-state": [2],
    "react/no-did-update-set-state": [2],
    "react/no-direct-mutation-state": [2],
    "react/no-unknown-property": [2],
    "react/prop-types": [2],
    "react/react-in-jsx-scope": [2],
    "react/self-closing-comp": [2],
    "react/sort-comp": [2],
    "react/sort-prop-types": [2],
    "require-yield": [2],
  },
}
<file_sep>/eslintrc-base.js
module.exports = {
  "env": {
    "browser": true,
  },
  "extends": "eslint:recommended",
  "rules": {
    "array-bracket-spacing": [2, "never"],
    "block-spacing": [2, "always"],
    "brace-style": [2, "1tbs", {"allowSingleLine": true}],
    "comma-dangle": [2, "always-multiline"],
    "comma-spacing": [2, {"before": false, "after": true}],
    "comma-style": [2, "last"],
    "computed-property-spacing": [2, "never"],
    "consistent-return": [2],
    "consistent-this": [2, "self"],
    "curly": [2, "multi-line"],
    "dot-notation": [2],
    "eqeqeq": [2],
    "func-names": [2],
    "func-style": [2, "declaration", {"allowArrowFunctions": true}],
    "indent": [2, 2, {"SwitchCase": 1}],
    "key-spacing": [2, {"beforeColon": false, "afterColon": true}],
    "keyword-spacing": [2],
    "linebreak-style": [2, "unix"],
    "new-cap": [2, { "capIsNew": false }],
    "new-parens": [2],
    "no-alert": [2],
    "no-array-constructor": [2],
    "no-caller": [2],
    "no-console": [1],
    "no-constant-condition": [2],
    "no-empty-pattern": [2],
    "no-eval": [2],
    "no-extend-native": [2],
    "no-extra-bind": [2],
    "no-extra-semi": [2],
    "no-fallthrough": [2],
    "no-floating-decimal": [2],
    "no-implicit-coercion": [2],
    "no-implied-eval": [2],
    "no-invalid-this": [2],
    "no-labels": [2],
    "no-lone-blocks": [2],
    "no-lonely-if": [2],
    "no-loop-func": [2],
    "no-magic-numbers": [2, {"enforceConst": true, "ignore": [0, 1]}],
    "no-multi-spaces": [2],
    "no-multiple-empty-lines": [2, {"max": 1, "maxBOF": 0, "maxEOF": 0}],
    "no-native-reassign": [2],
    "no-negated-condition": [2],
    "no-nested-ternary": [2],
    "no-new": [2],
    "no-new-func": [2],
    "no-new-object": [2],
    "no-new-wrappers": [2],
    "no-octal": [2],
    "no-octal-escape": [2],
    "no-proto": [2],
    "no-return-assign": [2],
    "no-self-compare": [2],
    "no-sequences": [2],
    "no-shadow-restricted-names": [2],
    "no-spaced-func": [2],
    "no-throw-literal": [2],
    "no-trailing-spaces": [2],
    "no-unexpected-multiline": [2],
    "no-unneeded-ternary": [2],
    "no-unused-expressions": [2],
    "no-unused-vars": [2, {"argsIgnorePattern": '^_'}],
    "no-use-before-define": [2],
    "no-useless-call": [2],
    "no-useless-concat": [2],
    "no-useless-constructor": [2],
    "no-void": [2],
    "no-with": [2],
    "object-curly-spacing": [2, "never"],
    "one-var": [2, "never"],
    "operator-assignment": [2, "always"],
    "operator-linebreak": [2, "after"],
    "padded-blocks": [2, "never"],
    "quote-props": [2, "as-needed", {"keywords": true}],
    "quotes": [2, "single", {"avoidEscape": true}],
    "radix": [2, "as-needed"],
    "semi": [2, "never"],
    "space-before-blocks": [2, "always"],
    "space-before-function-paren": [2, {"anonymous": "never", "asyncArrow": "always", "named": "never"}],
    "space-in-parens": [2, "never"],
    "space-infix-ops": [2],
    "space-unary-ops": [2, {"words": true, "nonwords": false}],
    "wrap-iife": [2],
    "yoda": [2, "never"],
  },
}
<file_sep>/eslintrc-test-modern.js
module.exports = {
  "extends": [
    "@casecommons/eslint-config/eslintrc-modern",
    "@casecommons/eslint-config/eslintrc-test",
  ],
  "rules": {
    "one-var": [0],
    "react/prop-types": [0],
  },
}
<file_sep>/README.md
# Case Commons JavaScript lint config

Configuration for [ESLint](http://eslint.org/) per Case Commons style guide. For TypeScript linting, see [lint-config-typescript](https://github.com/Casecommons/lint-config-typescript).

## Usage

Add to dev dependencies in your project:

```
yarn add --dev @casecommons/eslint-config
```

Be sure to add ESLint as a dependency in your project and set it up to run as part of the project’s test suite.

Use [`extends`](http://eslint.org/docs/user-guide/configuring#using-a-shareable-configuration-package) to include the appropriate lints into `.eslintrc` in your own project. For example:

```javascript
// .eslintrc

{
  extends: [
    "@casecommons/eslint-config/eslintrc-modern",
  ],
}
```

There are various configurations available:

- `@casecommons/eslint-config/eslintrc-base`: Base configuration applicable to any ECMAScript.
- `@casecommons/eslint-config/eslintrc-test`: Extension of base configuration for test code.
- `@casecommons/eslint-config/eslintrc-modern`: Extension of base configuration for modern (2015+) ECMAScript.
- `@casecommons/eslint-config/eslintrc-test-modern`: Extension of modern configuration for test code.

## Development

Docker should be used for simpler dev setup. To do so:

1. `cp .env.sample .env` and set values in `.env` accordingly.
2. `docker-compose build`
3. Prefix the usual `yarn`, etc., commands with `docker-compose exec app`/`docker-compose run --rm app` or similar.

### Packaging

Run `yarn pack` which will emit a tarball in the package root directory. This is useful for testing the client in another project without having to perform a release (see [package.json local paths](https://docs.npmjs.com/files/package.json#local-paths)).

### Releasing

Run `bin/release`.
