Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions packages/eslint-presets/eslint-preset-react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# @tcd-devkit/eslint-preset-react

Comprehensive ESLint Flat Configuration Preset for React projects. This preset bundles a curated set of `@tcd-devkit` ESLint configurations to provide a complete linting solution for modern React applications, including React, TypeScript, accessibility (a11y), and import rules. It is designed for ESLint v9+ and its Flat Config system.

## Features

- **All-in-One React Setup**: Combines configurations for React, React Hooks, TypeScript, Imports (JS & TS), and JSX A11y.
- **Opinionated Defaults**: Provides a strong, opinionated baseline for React projects.
- **Easy Integration**: Simplifies ESLint setup by providing a single package to install and configure.
- **Flat Config**: Utilizes ESLint's modern flat configuration format (ESLint v9+).

This preset includes the following `@tcd-devkit` configurations:

- `@tcd-devkit/eslint-config` (Base JavaScript rules)
- `@tcd-devkit/eslint-config-ts` (TypeScript rules)
- `@tcd-devkit/eslint-config-import` (JavaScript import rules)
- `@tcd-devkit/eslint-config-import-ts` (TypeScript import rules)
- `@tcd-devkit/eslint-config-react` (React rules)
- `@tcd-devkit/eslint-config-react-hooks` (React Hooks rules)
- `@tcd-devkit/eslint-config-a11y` (JSX Accessibility rules)

## Installation

```bash
# Using npm
npm install -D @tcd-devkit/eslint-preset-react eslint@^9.0.0

# Using yarn
yarn add -D @tcd-devkit/eslint-preset-react eslint@^9.0.0

# Using pnpm
pnpm add -D @tcd-devkit/eslint-preset-react eslint@^9.0.0
```

All necessary `@tcd-devkit/eslint-config-*` packages are direct dependencies of this preset and will be installed automatically.

## Usage

Import and use the preset in your `eslint.config.js` (or `.mjs`/`.cjs`) file:

```javascript
import reactPreset from '@tcd-devkit/eslint-preset-react'; // This is an array of config objects

export default [
...reactPreset,
{
// Your project-specific overrides or additional configurations can be added here.
// For example, to adjust parser options for TypeScript if your tsconfig.json is not in the root:
// files: ['**/*.ts', '**/*.tsx'],
// languageOptions: {
// parserOptions: {
// project: './path/to/your/tsconfig.json',
// },
// },
rules: {
// example: '@typescript-eslint/no-explicit-any': 'warn',
},
},
];
```

This preset exports an array of ESLint configuration objects. You should spread it (`...reactPreset`) into your top-level configuration array. The underlying configurations are designed to work together. Ensure your `tsconfig.json` is correctly set up for TypeScript linting to function optimally.

## Rules

This preset combines rules from all the included `@tcd-devkit/eslint-config-*` packages listed in the Features section.
For a detailed view of all active rules in your project, you can run ESLint with the `--print-config` flag.

## License

MIT © [Nace Logar](https://thecodedestroyer.com)
80 changes: 80 additions & 0 deletions packages/eslint-presets/eslint-preset-react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"name": "@tcd-devkit/eslint-preset-react",
"version": "0.1.0",
"description": "Comprehensive ESLint Flat Configuration Preset for React projects. This preset bundles various @tcd-devkit ESLint configurations for a complete React, TypeScript, and a11y linting setup.",
"keywords": [
"tcd-devkit",
"preset",
"eslint",
"eslintconfig",
"eslint-preset",
"lint",
"react",
"typescript",
"a11y",
"flat-config"
],
"homepage": "https://github.com/thecodedestroyer/devkit",
"bugs": {
"url": "https://github.com/thecodedestroyer/devkit/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/thecodedestroyer/devkit.git",
"directory": "packages/eslint-presets/eslint-preset-react"
},
"license": "MIT",
"author": {
"name": "Nace Logar",
"email": "the.code.destroyer@gmail.com",
"url": "https://thecodedestroyer.com"
},
"type": "module",
"exports": {
".": {
"types": "./dist/react-preset.linter.d.ts",
"require": "./dist/react-preset.linter.cjs",
"import": "./dist/react-preset.linter.js"
}
},
"main": "./dist/react-preset.linter.cjs",
"module": "./dist/react-preset.linter.js",
"types": "./dist/react-preset.linter.d.ts",
"typesVersions": {
"*": {
".": [
"./dist/react-preset.linter.d.ts"
]
}
},
"files": [
"dist",
"!dist/**/*.d.ts.map"
],
"scripts": {
"build": "tsup",
"lint:types": "tcd-scripts lint --only=tsc"
},
"dependencies": {
"@tcd-devkit/eslint-config": "workspace:*",
"@tcd-devkit/eslint-config-a11y": "workspace:*",
"@tcd-devkit/eslint-config-import-ts": "workspace:*",
"@tcd-devkit/eslint-config-react": "workspace:*",
"@tcd-devkit/eslint-config-react-hooks": "workspace:*",
"@tcd-devkit/eslint-config-ts": "workspace:*",
"eslint-config-prettier": "10.1.8"
},
"devDependencies": {
"@tcd-devkit/scripts": "workspace:*",
"@tcd-devkit/tsconfig": "workspace:*",
"@tcd-devkit/tsup-config": "workspace:*",
"@types/node": "22.17.2",
"tsup": "8.5.0"
},
"peerDependencies": {
"eslint": "^9.0.0"
},
"engines": {
"node": ">=20.11.0 || >=21.2.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { Linter } from 'eslint';
import prettierConfig from 'eslint-config-prettier/flat';
import { defineConfig, globalIgnores } from 'eslint/config';

import { baseConfig } from '@tcd-devkit/eslint-config';
import { a11yConfig } from '@tcd-devkit/eslint-config-a11y';
import { importTsConfig } from '@tcd-devkit/eslint-config-import-ts';
import { reactConfig } from '@tcd-devkit/eslint-config-react';
import { reactHooksConfig } from '@tcd-devkit/eslint-config-react-hooks';
import { tsConfig } from '@tcd-devkit/eslint-config-ts';

const ignoresConfig = globalIgnores(
['**/dist/**', '**/node_modules/**', '**/build/**'],
'@tcd-devkit/eslint-config/ignores',
);

export const reactPreset: Linter.Config[] = defineConfig(
{
name: '@tcd-devkit/eslint-preset-react',
extends: [
baseConfig,
tsConfig,
reactConfig,
reactHooksConfig,
a11yConfig,
importTsConfig,
],
},
prettierConfig,
ignoresConfig,
);

export default reactPreset;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@tcd-devkit/tsconfig/build"
}
4 changes: 4 additions & 0 deletions packages/eslint-presets/eslint-preset-react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@tcd-devkit/tsconfig/lib"
}
5 changes: 5 additions & 0 deletions packages/eslint-presets/eslint-preset-react/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from 'tsup';

import { tsupLibConfig } from '@tcd-devkit/tsup-config/lib';

export default defineConfig(tsupLibConfig);
50 changes: 50 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.