npm package: @splunk/eslint-config
Description: Standardized Splunk ESLint configuration
Author: Splunk Inc.
Latest version: 5.1.0

# @splunk/eslint-config

This package provides extendable ESLint configuration objects. Currently, the following configs are available:

**Traditional (ESLint 8, requires Babel):**
* `browser` - For code that runs in the browser.
* `browser-prettier` - For browser code that is formatted by [prettier](https://github.com/prettier/prettier).
* `node` - For node scripts.
* `node-prettier` - For node scripts that are automatically formatted with [prettier](https://github.com/prettier/prettier).

**Flat Config (ESLint 9, Babel-free):**
* `flat-browser` - For modern toolchains (Vite + SWC, etc.) using ESLint 9 flat config format.
* `flat-browser-prettier` - For browser code with modern toolchains, formatted with [prettier](https://github.com/prettier/prettier).

## Install

### Traditional Configs (ESLint 8, requires Babel)

For projects using Babel and the traditional `.eslintrc` format.

1. Install the peer dependencies:
    ```
    npm install --save-dev @babel/eslint-parser@7 eslint@^8 eslint-config-airbnb@^19 eslint-plugin-import@^2 eslint-plugin-jsx-a11y@^6 eslint-plugin-react@^7 eslint-plugin-react-hooks@^4
    ```
2. Install the package:
    ```
    npm install --save-dev @splunk/eslint-config
    ```

ESLint requires dependencies to be installed as peer dependencies. See [this issue on github](https://github.com/eslint/eslint/issues/3458) for more background.

### Flat Config (ESLint 9, Babel-free)

For projects using ESLint 9's flat config format (works with any build tool: webpack, Vite, SWC, esbuild, etc.).

1. Install the peer dependencies:
    ```
    npm install --save-dev @eslint/js@^9 eslint@^9 globals@^16 eslint-plugin-import@^2 eslint-plugin-jsx-a11y@^6.10.0 eslint-plugin-react@^7.37.1 eslint-plugin-react-hooks@^7
    ```
    For `flat-browser-prettier`, also install:
    ```
    npm install --save-dev eslint-config-prettier
    ```
2. Install the package:
    ```
    npm install --save-dev @splunk/eslint-config
    ```

**Note:** The flat config does **not** require `@babel/eslint-parser` or `eslint-config-airbnb`.

## Choosing a Config

**Use Traditional configs if:**
- You're on ESLint 8
- Your project uses Babel for parsing (e.g., older webpack setups)
- You're using `.eslintrc` format

**Use Flat configs if:**
- You're on ESLint 9 or planning to upgrade
- Your build tool handles JSX natively (Vite, SWC, esbuild, modern webpack)
- You want to avoid the Babel dependency

The flat configs provide the same linting rules as the traditional configs but use ESLint 9's native flat config format and don't require Babel.

## Usage

Add the appropriate entry to your eslint configuration:
```js
{
    extends: "@splunk/eslint-config/browser"
}
```
Or
```js
{
    extends: "@splunk/eslint-config/browser-prettier"
}
```
Or
```js
{
    extends: "@splunk/eslint-config/node"
}
```
Or
```js
{
    extends: "@splunk/eslint-config/node-prettier"
}
```
Or
```js
import splunkConfig from '@splunk/eslint-config/flat-browser.mjs';

export default [
    ...splunkConfig,
    // Your additional configuration
];
```
Or
```js
import splunkConfig from '@splunk/eslint-config/flat-browser-prettier.mjs';

export default [
    ...splunkConfig,
    // Your additional configuration
];
```