# @ornikar/eslint-config

Ornikar eslint config

Based on Airbnb.

This is the config to use when you don't have babel on the project.

Also see:

- [@ornikar/eslint-config-babel](https://github.com/ornikar/eslint-configs/tree/master/%40ornikar/eslint-config-babel)
- [@ornikar/eslint-config-react](https://github.com/ornikar/eslint-configs/tree/master/%40ornikar/eslint-config-react)
- [@ornikar/eslint-config-typescript](https://github.com/ornikar/eslint-configs/tree/master/%40ornikar/eslint-config-typescript)
- [@ornikar/eslint-config-typescript-react](https://github.com/ornikar/eslint-configs/tree/master/%40ornikar/eslint-config-typescript-react)

## How to install

These configs ship as flat-config arrays. Require the subpath you need and spread it into your `eslint.config.js`.

### root

1. `npm install --save-dev eslint @ornikar/eslint-config`
2. In your root `eslint.config.js`:

```js
const ornikarRoot = require('@ornikar/eslint-config/root');

module.exports = [...ornikarRoot];
```

### node without babel or typescript

1. `npm install --save-dev eslint @ornikar/eslint-config`
2. In your source `eslint.config.js`:

```js
const ornikarNode = require('@ornikar/eslint-config/node');

module.exports = [...ornikarNode];
```

### node with babel (deprecated, please use typescript instead)

1. `npm install --save-dev eslint @ornikar/eslint-config @ornikar/eslint-config-babel`
2. In your source `eslint.config.js`:

```js
const babelConfig = require('@ornikar/eslint-config-babel');

module.exports = [...babelConfig];
```

### node with typescript

1. `npm install --save-dev eslint @ornikar/eslint-config @ornikar/eslint-config-typescript`
2. In your source `eslint.config.js`:

```js
const tsNode = require('@ornikar/eslint-config-typescript/node');

module.exports = [...tsNode];
```

### module override

In flat config, file-specific overrides are separate entries with `files:`. Use `defineConfig` from `eslint/config` so the `extends:` keyword works:

```js
const { defineConfig } = require('eslint/config');
const ornikarRoot = require('@ornikar/eslint-config/root');
const nodeModuleOverride = require('@ornikar/eslint-config/node-module-override');

module.exports = defineConfig([
  ...ornikarRoot,
  {
    files: ['test-setup.js'],
    extends: [nodeModuleOverride],
  },
]);
```

## How to configure a project

### Two configuration files

In a project you should have two configuration files:

- /eslint.config.js
- /{src,lib}/eslint.config.js

If the project is compiled, use `src` for source and `dist` for compilation with rollup.
If the project is not compiled, use `lib`.
If the project is CRA, next or built with webpack, use `src` for source and `build` or the build directory your tool uses.

Using two config files is important:

- the root config is for config files and scripts. It should allow dev dependencies
- the source config is for your source and test files

ESLint v9 flat config does not cascade like legacy `.eslintrc` did — only the nearest `eslint.config.js` to the file being linted is used. Compose what you need at each location.

### Use `ignores`

Replace `.eslintignore` with the `ignores` property in your flat config:

```js
module.exports = [{ ignores: ['dist/**', 'coverage/**'] }, ...ornikarRoot];
```

### Use `--report-unused-disable-directives`

Really useful tip — it prevents leaving unused eslint-disable directives.

### Lerna/Workspaces configuration

Assuming your `package.json` has `"workspaces": ["packages/*"]`:

- /eslint.config.js
- /packages/\*/{src,lib}/eslint.config.js
