# ESLint

ESLint config is extended from airbnb and other industry recommended ESLint configurations. It is designed to be composable.

`@box/frontend/eslint/base` is designed as a base config, suitable for most frontend and backend projects. It should always be first in `extends` array.

The following additional configs are available:

- `@box/frontend/eslint/react` - React specific rules
- `@box/frontend/eslint/typescript` - TypeScript specific rules
- `@box/frontend/eslint/flow` - Flow specific rules

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [.eslintrc.js](#eslintrcjs)
  - [Example](#example)
  - [Overriding](#overriding)
  - [Prettier](#prettier)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## .eslintrc.js

For example, to use set ESLint config for a Frontend React with TypeScript project, set the following in `.eslintrc.js`:

### Example

```js
module.exports = {
  extends: [
    require.resolve('@box/frontend/eslint/base'),
    require.resolve('@box/frontend/eslint/react'),
    require.resolve('@box/frontend/eslint/typescript'),
  ],
};
```

### Overriding

Add any overrides as necessary, but it is recommended that you ideally should not be having any overrides at all. To add overrides just extend the imported config with your own rules.

```js
module.exports = {
  extends: [
    require.resolve('@box/frontend/eslint/base'),
    require.resolve('@box/frontend/eslint/react'),
    require.resolve('@box/frontend/eslint/typescript'),
  ],
  rules: {
    'some-rule': 'off',
  },
};
```

### Prettier

This config does not include Prettier rules. It is recommended to use Prettier as a separate tool to format your code. Point `package.json` at `"prettier": "@box/frontend/prettier"` (or import that config from a local `prettier.config.mjs` when you need overrides); see [Prettier setup](../prettier/README.md). This is inline with [Prettier's philosophy of being a code formatter and not a linter](https://prettier.io/docs/en/integrating-with-linters).
