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

Package detail

eslint-config-algolia

algolia7kMIT23.2.1

Algolia's ESLint config.

eslint, eslintconfig, es6, algolia

readme

eslint-config-algolia

Version Build Status License Downloads

This is Algolia's linting and formatting of JavaScript projects (Vanilla, React, Vue) repository.

It explains to you how to setup your project to use it and never worry again about indentation, curly spaces, let vs const etc...

This code style is only as useful as you activate travis for your project so that it runs linting in your test phase and warns you.

Just focus on coding.

Table of Contents

Setup your project

Base requirements

yarn add \
eslint @babel/eslint-parser prettier \
eslint-config-algolia eslint-config-prettier \
eslint-plugin-import eslint-plugin-prettier \
@eslint-community/eslint-plugin-eslint-comments eslint-plugin-jsdoc \
--dev

Vanilla

.eslintrc.js

module.exports = {
  extends: 'algolia'
};

eslint.config.js

const algolia = require('eslint-config-algolia/flat/base');
module.exports = [
  ...algolia,
];

package.json

{
  "scripts": {
    "test": "npm run lint",
    "lint": "eslint .",
    "lint:fix": "npm run lint -- --fix"
  }
}

Jest

We recommend using Jest as a test runner.

terminal

yarn add eslint-plugin-jest --dev

.eslintrc.js

module.exports = {
  extends: ['algolia', 'algolia/jest']
};

eslint.config.js

const algolia = require('eslint-config-algolia/flat/base');
const algoliaJest = require('eslint-config-algolia/flat/jest');
module.exports = [
  ...algolia,
  ...algoliaJest,
];

package.json

{
  "scripts": {
    "test": "npm run lint",
    "lint": "eslint .",
    "lint:fix": "npm run lint -- --fix"
  }
}

React

terminal

yarn add eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-jsx-a11y --dev

.eslintrc.js

module.exports = {
  extends: ['algolia', 'algolia/react']
};

eslint.config.js

const algolia = require('eslint-config-algolia/flat/base');
const algoliaReact = require('eslint-config-algolia/flat/react');
module.exports = [
  ...algolia,
  ...algoliaReact,
];

package.json

{
  "scripts": {
    "test": "npm run lint",
    "lint": "eslint .",
    "lint:fix": "npm run lint -- --fix"
  }
}

Flow (deprecated)

terminal

yarn add eslint-plugin-flowtype --dev

.eslintrc.js

module.exports = {
  extends: ['algolia', 'algolia/flowtype']
};

Flow with React (deprecated)

terminal

yarn add eslint-plugin-flowtype eslint-plugin-react eslint-plugin-react-hooks --dev

.eslintrc.js

module.exports = {
  extends: ['algolia', 'algolia/flowtype', 'algolia/react']
};

package.json

{
  "scripts": {
    "test": "npm run lint",
    "lint": "eslint .",
    "lint:fix": "npm run lint -- --fix"
  }
}

TypeScript

terminal

yarn add @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript --dev

.eslintrc.js

module.exports = {
  extends: ['algolia', 'algolia/typescript'],

  parserOptions: {
    project: '<path-to-tsconfig.json>',
  },
};

eslint.config.js

const algolia = require('eslint-config-algolia/flat/base');
const algoliaTypescript = require('eslint-config-algolia/flat/typescript');
module.exports = [
  ...algolia,
  ...algoliaTypescript,
  {
    languageOptions: {
      parserOptions: {
        project: '<path-to-tsconfig.json>',
      },
    },
  },
];

package.json

{
  "scripts": {
    "test": "npm run lint",
    "lint": "eslint --ext .js,.ts,.tsx .",
    "lint:fix": "npm run lint -- --fix"
  }
}

You also need to make sure that all the files you want to lint are also included in tsconfig.json with the include property.

TypeScript with React

terminal

yarn add @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-jsx-a11y --dev

.eslintrc.js

module.exports = {
  extends: ['algolia', 'algolia/react', 'algolia/typescript']
};

Note: Be sure to put the algolia/typescript configuration last so the parser is properly set for TypeScript files.

eslint.config.js

const algolia = require('eslint-config-algolia/flat/base');
const algoliaReact = require('eslint-config-algolia/flat/react');
const algoliaTypescript = require('eslint-config-algolia/flat/typescript');
module.exports = [
  ...algolia,
  ...algoliaReact,
  ...algoliaTypescript,
];

package.json

{
  "scripts": {
    "test": "npm run lint",
    "lint": "eslint --ext .js,.ts,.tsx .",
    "lint:fix": "npm run lint -- --fix"
  }
}

Vue

terminal

yarn add eslint-plugin-vue --dev

.eslintrc.js

module.exports = {
  extends: ['algolia', 'algolia/vue']
};

eslint.config.js

const algolia = require('eslint-config-algolia/flat/base');
const algoliaVue = require('eslint-config-algolia/flat/vue');
module.exports = [
  ...algolia,
  ...algoliaVue,
];

package.json

{
  "scripts": {
    "test": "npm run lint",
    "lint": "eslint --ext .js,.vue .",
    "lint:fix": "npm run lint -- --fix"
  }
}

VSCode

{
  "eslint.validate": [
    {
      "language": "vue",
      "autoFix": true
    }
  ]
}

Node.js

package.json

{
  "scripts": {
    "test": "npm run lint",
    "lint": "eslint .",
    "lint:fix": "npm run lint -- --fix"
  }
}

.eslintrc.js

module.exports = {
  extends: 'algolia',
  rules: {
    'import/no-commonjs': 'off'
  },
};

eslint.config.js

const algolia = require('eslint-config-algolia/flat/base');
module.exports = [
  ...algolia,
  {
    rules: {
      'import/no-commonjs': 'off'
    }
  },
];

Existing codebase setup

If you have a lot of files already written and wants to now use our linting tools, you might have a lot of errors. There's hope!

Just reformat all the files automatically and then manually fix remaining errors.

terminal

npm run lint:fix

Setup autofix in IDE

Don't overlook this part, autofixing on save is a huge productivity boost.

Use any ESLint integration and activate "Fix on save" option.

Also activate "Lint HTML files" when dealing with .vue components.

Ignoring files

See "Ignoring Files and Directories" on ESLint website.

Contributing

Test

We have a sample-project.

yarn test

Release

npm run release

changelog

23.2.1 (2024-10-15)

Bug Fixes

23.2.0 (2024-10-10)

Features

23.1.7 (2024-09-02)

23.1.6 (2024-08-26)

23.1.5 (2024-08-26)

23.1.4 (2024-08-23)

23.1.3 (2024-08-19)

Bug Fixes

23.1.2 (2024-08-19)

Bug Fixes

24.0.0-alpha.0 (2024-08-19)

23.1.1 (2024-08-19)

23.1.0 (2024-08-19)

Bug Fixes

Features

23.0.0 (2024-07-26)

Bug Fixes

Features

22.0.0 (2023-07-12)

Bug Fixes

  • release script should update yarn.lock (#314) (4464168)

Features

21.0.0 (2023-04-26)

Features

20.1.0 (2022-12-06)

Bug Fixes

  • remove private-abstract-* options from member-ordering (c0ae1bf)

20.0.0 (2021-12-01)

Bug Fixes

  • breaking: upgrade packages (#199) (8a05411)
  • update deprecated property jsxBracketSameLine (89694fb)

BREAKING CHANGES

  • breaking: different peer dependency "@babel/eslint-parser" is now used instead of "babel-parser"

19.0.2 (2021-08-27)

Bug Fixes

  • jest: correctly test jest rules (617d895)

19.0.1 (2021-08-27)

Bug Fixes

19.0.0 (2021-08-27)

Bug Fixes

  • jest: stricter configuration (09ff1c2)
  • renovate: use our own package (8c3a50b)

18.0.0 (2021-03-02)

Features

  • stricter configuration, add more rules (#137) (a9932b7)

17.0.1 (2021-03-01)

Bug Fixes

  • node: update version (c084828)
  • specify node version (80c2504)
  • deps: update dependency react to v16.14.0 (64ccb01)
  • deps: update dependency react-addons-shallow-compare to v15.6.3 (2975e42)

17.0.0 (2021-03-01)

BREAKING CHANGES

  • sub-configs no longer extend base config ("algolia/jest" => "algolia", "algolia/jest")
  • update dependencies
  • add some missing rules

16.0.0 (2020-06-02)

BREAKING CHANGES

  • typescript: add support for @typescript-eslint/eslint-plugin 3.x (#125) (60d2ad1)

15.0.0 (2019-10-09)

Features

  • typescript: allow generic names starting with "K" (#116) (2148fe4)

BREAKING CHANGES

14.0.1 (2019-09-10)

Bug Fixes

  • typescript: correct rule name (1752458)

14.0.0 (2019-09-10)

Features

BREAKING CHANGES

  • ts: /typescript requires typescript-eslint v2 now

13.4.0 (2019-07-01)

Features

  • rules: disable @typescript-eslint/explicit-function-return-type (#110) (eb77e5f)

13.3.0 (2019-04-16)

Bug Fixes

  • vue: config compatible with eslint v5 (5cbcec1)

Features

13.2.3 (2018-08-28)

Bug Fixes

  • extensions: ignorePackages by default + JS override (b8a5ff0)

13.2.2 (2018-08-27)

Remove the sample-project/node_modules folder from the published package.

13.2.1 (2018-08-27)

Bug Fixes

  • extensions: disable for packages in Vue (37c0ba4)
  • Vue: add Vue plugin to the list (f42bc1d)

13.2.0 (2018-08-27)

Bug Fixes

  • remove nested renovate project configuration (a6d9765)
  • vue: avoid extends from base (5cdeb22)

Features

  • enable curly rules (dca43ad)
  • base: allow unused var with rest (b9c579a)
  • replace experimentalObjectRestSpread for ecmaVersion (76e5d1d)
  • import: enforce no extensions for js files (#92) (b24e9b2)
  • vue: add rules override (ac98c1a)
  • vue: use Vue plugin instead of the HTML one (a0d733a)

13.1.0 (2018-02-12)

Bug Fixes

  • deps: update dependency react to v16.2.0 (144e42f)

Features

  • rules: disable no-return-await (a46f401), closes #78

13.0.1 (2017-11-27)

Bug Fixes

  • react: allow arrow functions in JSX (3d5daff)

13.0.0 (2017-11-25)

Bug Fixes

  • deps: update dependency react to v^16.0.0 (52f6213)

Features

  • jest: move into its own file (2259ed6)
  • react: disallow binding in render (a1d725a)

12.0.0 (2017-07-04)

Features

  • jest: move into its own file (2259ed6)

11.0.0 (2017-06-16)

Features

  • confs: Base, React, Flowtype & Vue confs (9d0a17c)

10.1.0 (2017-06-13)

Bug Fixes

  • eslint: disable no-duplicate-imports (8029357)
  • prettier: use same printWidth as max-len (fe7e304)

Features

  • max-len: explictly set max-len && printWidth to 80 (be940ad)

10.0.0 (2017-05-30)

Features

  • rules: no reassign of fn param props (b087877)

9.0.0 (2017-05-30)

Features

  • style: re add stylistic rules (ed8dd5a)

8.0.0 (2017-05-11)

Features

  • formatting: use eslint-plugin-prettier (ddf37d4)

7.0.3 (2017-04-26)

Bug Fixes

  • rules: wrap our own rules in rules:{} (8b50dce), closes #33

7.0.2 (2017-03-24)

Bug Fixes

  • prettier: enforce prettier rules to pass after ours (5476a88)

7.0.1 (2017-03-17)

Bug Fixes

  • style: remove stylistic error (17c90ca)

7.0.0 (2017-03-17)

Features

  • prettier: prepare prettier migration (83ca621)

6.0.1 (2016-10-15)

6.0.0 (2016-10-01)

Features

  • rules: new default rules (ce194dd)

5.5.1 (2016-09-16)

Bug Fixes

  • dep: upgrade eslint, fix bad err message (1b44598)

5.5.0 (2016-09-06)

Features

  • import: allow using webpack resolver, to lint resolve{alias} (e2054f4)

5.4.0 (2016-09-01)

Features

  • eslint: add new rules since July (6f07294)

5.3.1 (2016-07-19)

Bug Fixes

5.3.0 (2016-07-19)

Features

  • Jasmine: provide set of rules for Jasmine tests (333288c)

5.2.2 (2016-07-18)

5.2.1 (2016-07-18)

5.2.0 (2016-07-13)

Features

  • parser: use babel-eslint, allows for more es features (25f1936)

5.1.0 (2016-07-12)

Features

  • import: disallow commonjs, only check .js imports (949e567)

5.0.0 (2016-07-11)

Features

  • major: eslint 3, stop relying on airbnb and too much invisible defaults (2de318a)

4.7.0 (2016-02-12)

Features

  • no-unused-vars: Allow unused arguments prefixed with _ (b528744)

4.6.0 (2016-01-27)

Features

  • max-len: adds ignore comments and URL's for max-len (6492450)
  • quote-props: Add the keywords: true option (da5deec)

4.5.0 (2015-12-07)

Features

  • no-module-exports: Use v1.5.0 of the eslint-plugin-algolia (c98003f)

4.4.0 (2015-12-07)

Features

  • eslint-plugin-algolia: Use v1.4.2 (8789350)

4.3.2 (2015-12-02)

Bug Fixes

  • relative-require: Use v1.0.3 of eslint-plugin-algolia (e2bee8f)

4.3.1 (2015-12-02)

Bug Fixes

  • relative-require: Prefix with plugin name (3ed7299)

4.3.0 (2015-12-02)

Features

  • plugin-algolia: Add eslint-plugin-algolia (395ce7a)

4.2.0 (2015-10-26)

Features

  • airbnb: use airbnb react rules (abf15a3)

4.1.0 (2015-10-09)

Features

  • react: Add rules on React props (be0e978)

4.0.0 (2015-10-06)

Features

  • usage: simplify usage, remove es5 specific linter (93c2771)

3.0.0 (2015-09-11)

2.2.0 (2015-09-08)

Features

2.1.2 (2015-07-31)

Bug Fixes

  • specify comma dangle parameter (f31cbca)

2.1.1 (2015-07-09)

Bug Fixes

  • disable enforcing function express names (ad97e6c)

2.1.0 (2015-07-08)

Features

  • enforce some more spacing (af9595b)

2.0.4 (2015-07-06)

Bug Fixes

  • semi colon forced (default airbnb (84bc291)

2.0.3 (2015-07-05)

Bug Fixes

  • bad comment (b0cc948)
  • eslint extends features works strangely (a278ac4)

2.0.1 (2015-07-05)

Bug Fixes

2.0.0 (2015-07-05)