npm package: @rainstormy/presets-eslint-jsx
Description: A predefined, opinionated ESLint configuration intended to be used as a foundation for any web project that uses the JSX syntax for components.
Author: Steffen Diswal
Latest version: 1.0.0-rc.0

# Generic JSX Preset for ESLint

This package provides a predefined, opinionated [ESLint](https://eslint.org) configuration intended to be used as a foundation for any web project that uses the JSX syntax for components such as [Qwik](https://qwik.builder.io).

<dl><dt><strong>🔥 CAUTION</strong></dt><dd>

* For a Next.js app, use [@rainstormy/presets-eslint-next](https://github.com/rainstormy/presets-web/tree/main/packages/presets-eslint-next) instead.
* For Preact components, use [@rainstormy/presets-eslint-preact](https://github.com/rainstormy/presets-web/tree/main/packages/presets-eslint-preact) instead.
* For React components, use [@rainstormy/presets-eslint-react](https://github.com/rainstormy/presets-web/tree/main/packages/presets-eslint-react) instead.
* For Solid components, use [@rainstormy/presets-eslint-solid](https://github.com/rainstormy/presets-web/tree/main/packages/presets-eslint-solid) instead.
</dd></dl>

This preset configures a subset of rules from the following plugins, which are installed along with the preset package:

* [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules) (with rule names prefixed by `jsx-a11y/`)
* [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules) (only for generic JSX rules, with rule names prefixed by `react/`)

## Installation
Install the `@rainstormy/presets-eslint-jsx` package and its peer dependencies:

```shell
npm install --save-dev @rainstormy/presets-eslint-jsx @rainstormy/presets-eslint eslint typescript
```

```shell
pnpm install --save-dev @rainstormy/presets-eslint-jsx @rainstormy/presets-eslint eslint typescript
```

```shell
yarn add --dev @rainstormy/presets-eslint-jsx @rainstormy/presets-eslint eslint typescript
```

## Usage
Create or extend a [flat ESLint configuration file](https://eslint.org/docs/latest/use/configure/configuration-files-new) (`eslint.config.js`) and apply the `eslintPresetJsx` preset.

For example (with the default options in comments):

```javascript
import { eslintPresets } from "@rainstormy/presets-eslint"
import { eslintPresetJsx } from "@rainstormy/presets-eslint-jsx"

export default eslintPresets({
	additionalPresets: [
		// ...other presets...
		eslintPresetJsx({
			// targetFilePatterns: ["**/*.@(jsx|tsx)"],
		}),
	],
})
```

### In Combination with Qwik
Install `eslint-plugin-qwik` and use the spread syntax (`...`) to add a custom configuration object after the preset configuration object.

For example:

```javascript
import {
	eslintPresetAmbientTypeScriptModules,
	eslintPresets,
} from "@rainstormy/presets-eslint"
import { eslintPresetJsx } from "@rainstormy/presets-eslint-jsx"
import qwikPlugin from "eslint-plugin-qwik"

export default [
	...eslintPresets({
		additionalPresets: [
			eslintPresetAmbientTypeScriptModules(),
			eslintPresetJsx(),
		],
	}),
	{
		files: ["**/*.@(jsx|tsx)"],
		plugins: {
			qwik: qwikPlugin,
		},
		rules: {
			"react/function-component-definition": "off",
			"react/jsx-key": "off",
			"react/jsx-no-script-url": "off",
			"qwik/jsx-img": "error",
			"qwik/jsx-key": "error",
			"qwik/jsx-no-script-url": "error",
			"qwik/loader-location": "error",
			"qwik/no-react-props": "error",
			"qwik/prefer-classlist": "error",
			"qwik/unused-server": "error",
			"qwik/use-method-usage": "error",
			"qwik/valid-lexical-scope": "error",
		},
	},
]
```