eslint-config-pipedrive

Pipedrive specific linting configurations for JavaScript projects

Usage no npm install needed!

<script type="module">
  import eslintConfigPipedrive from 'https://cdn.skypack.dev/eslint-config-pipedrive';
</script>

README

eslint-config-pipedrive

This is a shared config for ESLint that is based in Pipedrive internal coding standards. It is mainly intended to be used with the internal node-hooks library, but can be used completely separately as well.

Table of Contents

Installing without node-hooks

Install Pipedrive shared config:

npm install --save-dev eslint
npm install --save-dev eslint-config-pipedrive

Configuration

All you really need to configure is the flavour of the configuration package. You use the rules by extending the shared config:

{
    "extends": ["pipedrive"]
}

Rulesets

There are essentially 6 rulesets that you can extend:

  • "pipedrive" (or "pipedrive/es6"): Default ES6 based rules for Pipedrive
  • "pipedrive/es5": ES5 specific rules for Pipedrive
  • "pipedrive/es6": ES6 (ES2015) specific rules for Pipedrive
  • "pipedrive/es8": ES8 (ES2017) specific rules for Pipedrive
  • "pipedrive/es9": ES9 (ES2018) specific rules for Pipedrive
  • "pipedrive/react": React specific rules for Pipedrive
  • "pipedrive/typescript": Typescript specific rules for Pipedrive

Using React

Using React rules also requires additional ESLint plugin for the rules to work. To install dependency:

npm install --save-dev eslint-plugin-react

If you want to enable rules for React Hooks project, you must also install the react-hooks eslint module:

npm install --save-dev eslint-plugin-react-hooks

Using Typescript

Using Typescript rules also requires a few specific Typescript plugins for ESLint. Install dependencies:

npm install --save-dev @typescript-eslint/eslint-plugin @typescript-eslint/parser

Using Prettier

Install dependencies:

npm install --save-dev prettier eslint-config-prettier @pipedrive/prettier-config

Create your .eslintrc.json:

{
    "extends": ["pipedrive", "prettier"]
}

Create your .prettierrc.js file:

module.exports = require('@pipedrive/prettier-config');

Add Prettier to your pre-commit hook

  • For void core projects verify-staged will automatically run Prettier:
{
    "scripts": {
        "verify-staged": "bin/verify-staged.sh"
    },
    "pre-commit": ["verify-staged", "npm-version-check"]
}
  • For other projects add a format script to your package.json, which you can use to format whole project with prettier:
{
    "scripts": {
        "format": "npx prettier . --write"
    },
    "pre-commit": ["format", "lint", "test", "npm-version-check"]
}

When using VS Code, make sure you have the esbenp.prettier-vscode plugin installed and set the settings properly.

{
    // Format using Prettier
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    // Fix eslint errors on save
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    }
}

Contribution and rule proposals

The rules are defined by the Pipedrive developer community. So if there are some new rules that should be added, or would make things better, submit the new issue and fill in the details.

After submitting the issue, post the issue in an appropriate public channel. Voting happens with simple :+1: / :-1: system. And if there is enough interest in the change, it will be adopted.