Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centralize tooling configs in monorepo #4138

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
6 changes: 5 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
- '@rtk-query/codegen-openapi'
- '@rtk-query/graphql-request-base-query'
- '@reduxjs/rtk-codemods'
- '@reduxjs/eslint-config'
- '@reduxjs/prettier-config'
- '@reduxjs/tsconfig'
- '@reduxjs/vitest-config'
jobs:
publish:
runs-on: ubuntu-latest
Expand All @@ -28,7 +32,7 @@ jobs:
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn workspace ${{ inputs.package }} test
- run: yarn workspaces foreach --include "${{ inputs.package }}" run test
- run: yarn workspace ${{ inputs.package }} exec npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"website",
"examples/query/react/*",
"examples/action-listener/*",
"packages/configs/*",
"examples/type-portability/*"
],
"devDependencies": {
Expand Down Expand Up @@ -59,6 +60,8 @@
"scripts": {
"build": "yarn build:packages",
"test": "yarn test:packages",
"install": "yarn build-configs",
"build-configs": "yarn workspaces foreach -Atip --include '@reduxjs/*config' run build",
"build:examples": "yarn workspaces foreach -A --include '@reduxjs/*' --include '@examples-query-react/*' --include '@examples-action-listener/*' -vtp run build",
"build:docs": "yarn workspace website run build",
"build:packages": "yarn workspaces foreach -A --include '@reduxjs/*' --include '@rtk-query/*' --topological-dev run build",
Expand Down
12 changes: 12 additions & 0 deletions packages/configs/eslint/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DS_Store
*.log
node_modules
.vscode
dist
build
temp
.yalc
yalc.lock
tsconfig.vitest-temp.json
.eslintcache
*.tgz
133 changes: 133 additions & 0 deletions packages/configs/eslint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# ESLint Config

ESLint configuration tailored for Redux projects.

## Installation

#### NPM

```bash
npm install --save-dev @reduxjs/eslint-config
```

#### Yarn

```bash
yarn add --dev @reduxjs/eslint-config
```

#### PNPM

```bash
pnpm add --save-dev @reduxjs/eslint-config
```

#### Bun

```bash
bun add --dev @reduxjs/eslint-config
```

## Usage

**ECMAScript Modules (ESM) usage inside a file like `eslint.config.mts` or `eslint.config.mjs`**:

```ts
import { reduxESLintConfig } from '@reduxjs/eslint-config'

export default reduxESLintConfig
```

**CommonJS (CJS) usage inside a file like `eslint.config.cts` or `eslint.config.cjs` (using `require`)**:

```ts
const { reduxESLintConfig } = require('@reduxjs/eslint-config')

module.exports = reduxESLintConfig
```

**CommonJS (CJS) usage inside a file like `eslint.config.cjs` or `eslint.config.cts` (using dynamic import)**:

```ts
module.exports = (async () =>
(await import('@reduxjs/eslint-config')).reduxESLintConfig)()
```

**CommonJS (CJS) usage inside a file like `eslint.config.cts` (using import and export assignment)**:

```ts
import ReduxESLintConfig = require('@reduxjs/eslint-config')
import reduxESLintConfig = ReduxESLintConfig.reduxESLintConfig

export = reduxESLintConfig
```

Navigating ESLint's configuration options can occasionally feel overwhelming, especially when trying to take advantage of TypeScript's strong typing for better IntelliSense support. To alleviate this complexity and enhance your development experience, we also provide a function called `createESLintConfig` that you can import and use to create your own ESLint configuration. This function already includes the default `reduxESLintConfig` and you can pass in an array of flat configs as additional overrides.

**ECMAScript Modules (ESM) usage inside a file like `eslint.config.mts` or `eslint.config.mjs`**:

```ts
import { createESLintConfig } from '@reduxjs/eslint-config'

export default createESLintConfig([
{
rules: {
'no-console': [0],
},
},
{
// ...Other additional overrides
},
])
```

**CommonJS (CJS) usage inside a file like `eslint.config.cts` or `eslint.config.cjs` (using `require`)**:

```ts
const { createESLintConfig } = require('@reduxjs/eslint-config')

module.exports = createESLintConfig([
{
rules: {
'no-console': [0],
},
},
{
// ...Other additional overrides
},
])
```

**CommonJS (CJS) usage inside a file like `eslint.config.cts` or `eslint.config.cjs` (using dynamic import)**:

```ts
module.exports = (async () =>
(await import('@reduxjs/eslint-config')).createESLintConfig([
{
rules: {
'no-console': [0],
},
},
{
// ...Other additional overrides
},
]))()
```

**CommonJS (CJS) usage inside a file like `eslint.config.cts` (using import and export assignment)**:

```ts
import ReduxESLintConfig = require('@reduxjs/eslint-config')
import createESLintConfig = ReduxESLintConfig.createESLintConfig

export = createESLintConfig([
{
rules: {
'no-console': [0],
},
},
{
// ...Other additional overrides
},
])
```
75 changes: 75 additions & 0 deletions packages/configs/eslint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "@reduxjs/eslint-config",
"version": "0.0.1",
"description": "ESLint configuration for Redux projects",
"source": "./src/index.mts",
"types": "./dist/index.d.ts",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"default": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"files": [
"dist",
"src"
],
"scripts": {
"build": "yarn clean && tsup",
"clean": "rimraf dist",
"prepack": "yarn build"
},
"keywords": [
"eslint",
"config",
"eslint-config",
"reduxjs",
"redux-toolkit",
"configuration"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/reduxjs/redux-toolkit.git",
"directory": "packages/configs/eslint"
},
"bugs": {
"url": "https://github.com/reduxjs/redux-toolkit/issues"
},
"peerDependencies": {
"eslint": ">= 8.56.0"
},
"peerDependenciesMeta": {
"eslint": {
"optional": true
}
},
"devDependencies": {
"@reduxjs/tsconfig": "workspace:^",
"@types/eslint-config-prettier": "^6.11.3",
"@types/eslint__js": "^8.42.3",
"eslint": "^9.10.0",
"rimraf": "^6.0.1",
"tslib": "^2.7.0",
"tsup": "^8.3.0",
"typescript": "^5.6.2"
},
"dependencies": {
"@eslint/js": "^9.10.0",
"@typescript-eslint/utils": "^8.6.0",
"eslint-config-prettier": "^9.1.0",
"typescript-eslint": "^8.6.0"
},
"sideEffects": false
}
Loading
Loading