version: 2
jobs:
  build:
    docker:
      - image: node:latest
    steps:
      - restore_cache:
          key: eslint-application
      - run:
          name: Install ESLint
          command: npm install --global eslint
      - save_cache:
          paths:
            - /usr/local/bin/eslint
            - /usr/local/lib/node_modules
          key: eslint-application-{{ checksum "/usr/local/lib/node_modules/eslint/package.json" }}
      - checkout
      - run:
          name: System information
          command: uname -a
      - run:
          name: Node.js version
          command: node --version
      - run:
          name: ESLint version
          command: eslint --version
      - run:
          name: Run ESLint
          command: eslint ./*.js

version: 2
jobs:
  build:
    docker:
      - image: node:latest
    steps:
      - checkout
      - restore_cache:
          key: eslint-application
      - run:
          name: Install ESLint
          command: npm install eslint
      - save_cache:
          paths:
            - ./node_modules
            - ./package-lock.json
          key: eslint-application-{{ checksum "./package-lock.json" }}
      - run:
          name: System information
          command: uname -a
      - run:
          name: Node.js version
          command: node --version
      - run:
          name: ESLint version
          command: ./node_modules/.bin/eslint --version
      - run:
          name: Run ESLint
          command: ./node_modules/.bin/eslint -- ./*.js

Install ESLint into local directory
Install ESLint into local directory

By default, npm is installed in /usr/local/lib/node_modules.
Caching /usr/local/lib/node_modules reverts version of npm to older one.
