@aivenio/eslint-config-aiven

ESLint configuration, following the styleguide of aiven.io

Usage no npm install needed!

<script type="module">
  import aivenioEslintConfigAiven from 'https://cdn.skypack.dev/@aivenio/eslint-config-aiven';
</script>

README

eslint-config-aiven

Our internal ESLint and prettier configuration. We want to autoformat code like prettier does, but also do more static checks that eslint does. To do both, we use eslint-plugin-prettier and eslint acts as the frontend to check and autofix style and other issues.

The configuration is split into:

  • @aivenio/eslint-config-aiven Recommended base configuration for TypeScript.
  • @aivenio/eslint-config-aiven/react The base + React additions.

Install recommended base

  1. npm install @aivenio/eslint-config-aiven

  2. Install peer dependencies. To get correct versions of these you should use npm 7 which auto-installs peer dependencies.

    If using npm 6:

    npm i --save-dev @typescript-eslint/parser
    npm i --save-dev eslint
    npm i --save-dev eslint-config-prettier
    npm i --save-dev eslint-plugin-import
    npm i --save-dev eslint-plugin-jsx-a11y
    npm i --save-dev eslint-plugin-prettier
    npm i --save-dev eslint-plugin-react
    npm i --save-dev prettier
    npm i --save-dev eslint-plugin-sonarjs
    
  3. Create an .eslintrc file to your repository root, with contents:

    {
      "extends": [
        "@aivenio/eslint-config-aiven"
      ]
    }
    
  4. Setup npm scripts in package.json

      "eslint:fix": "eslint --config .eslintrc --fix \"src/**/*.{ts,tsx}\"",
      "eslint:check": "eslint --config .eslintrc \"src/**/*.{ts,tsx}\"",
    
  5. Remember to setup a CI task to lint source code. See .github/workflows/test.yml for a GH action example.

Install for React

  1. Follow all steps in "Install recommended base" first

  2. Install additional peer dependencies

    npm i --save-dev eslint-plugin-jsx-a11y
    npm i --save-dev eslint-plugin-react
    
  3. Change the .eslintrc in your repository to have the following contents:

    {
      "extends": [
        "@aivenio/eslint-config-aiven/react"
      ]
    }