Skip to content

Commit aae8ff6

Browse files
authored
Migrate to Nx monorepo with create-eslint-config package (#50)
1 parent 6ab9f68 commit aae8ff6

118 files changed

Lines changed: 10818 additions & 6972 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,68 +13,84 @@ jobs:
1313
steps:
1414
- name: Checkout the repository
1515
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
1618
- name: Set up Node.js
1719
uses: actions/setup-node@v4
1820
with:
1921
node-version-file: .node-version
2022
cache: npm
23+
- name: Set base and head for Nx affected commands
24+
uses: nrwl/nx-set-shas@v4
2125
- name: Install dependencies
2226
run: npm ci
23-
- name: Run Vitest tests
24-
run: npm test
27+
- name: Run affected tests
28+
run: npx nx affected -t test
2529

2630
lint:
2731
runs-on: ubuntu-latest
2832
name: Lint
2933
steps:
3034
- name: Checkout the repository
3135
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 0
3238
- name: Set up Node.js
3339
uses: actions/setup-node@v4
3440
with:
3541
node-version-file: .node-version
3642
cache: npm
43+
- name: Set base and head for Nx affected commands
44+
uses: nrwl/nx-set-shas@v4
3745
- name: Install dependencies
3846
run: npm ci
39-
- name: Run ESLint
40-
run: npm run lint
47+
- name: Lint affected projects
48+
run: npx nx affected -t lint
4149

4250
typecheck:
4351
runs-on: ubuntu-latest
4452
name: Type check
4553
steps:
4654
- name: Checkout the repository
4755
uses: actions/checkout@v4
56+
with:
57+
fetch-depth: 0
4858
- name: Set up Node.js
4959
uses: actions/setup-node@v4
5060
with:
5161
node-version-file: .node-version
5262
cache: npm
63+
- name: Set base and head for Nx affected commands
64+
uses: nrwl/nx-set-shas@v4
5365
- name: Install dependencies
5466
run: npm ci
55-
- name: Check types using TypeScript compiler
56-
run: npm run typecheck
67+
- name: Type check affected projects
68+
run: npx nx affected -t typecheck
5769

5870
docs:
5971
runs-on: ubuntu-latest
6072
name: Docs check
6173
steps:
6274
- name: Checkout the repository
6375
uses: actions/checkout@v4
76+
with:
77+
fetch-depth: 0
6478
- name: Set up Node.js
6579
uses: actions/setup-node@v4
6680
with:
6781
node-version-file: .node-version
6882
cache: npm
83+
- name: Set base and head for Nx affected commands
84+
uses: nrwl/nx-set-shas@v4
6985
- name: Install dependencies
7086
run: npm ci
7187
- name: Generate docs
72-
run: npm run docs
88+
run: npx nx affected -t docs
7389
- name: Check docs unchanged
7490
run: |
75-
if [ "$(git diff --ignore-space-at-eol --text docs/*.md README.md | wc -l)" -gt "0" ]; then
91+
if [ "$(git diff --ignore-space-at-eol --text -- packages/eslint-config/docs/ packages/eslint-config/README.md | wc -l)" -gt "0" ]; then
7692
echo "Detected uncommitted changes after running docs script. See status below:"
77-
git diff --ignore-space-at-eol --text docs/*.md README.md
93+
git diff --ignore-space-at-eol --text -- packages/eslint-config/docs/ packages/eslint-config/README.md
7894
exit 1
7995
fi
8096
@@ -84,12 +100,16 @@ jobs:
84100
steps:
85101
- name: Checkout the repository
86102
uses: actions/checkout@v4
103+
with:
104+
fetch-depth: 0
87105
- name: Set up Node.js
88106
uses: actions/setup-node@v4
89107
with:
90108
node-version-file: .node-version
91109
cache: npm
110+
- name: Set base and head for Nx affected commands
111+
uses: nrwl/nx-set-shas@v4
92112
- name: Install dependencies
93113
run: npm ci
94-
- name: Check Prettier formatting
95-
run: npx prettier --check .
114+
- name: Check formatting of affected files
115+
run: npx nx format:check

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ testem.log
3838
# System Files
3939
.DS_Store
4040
Thumbs.db
41+
42+
# Nx
43+
.nx/cache
44+
.nx/workspace-data
45+
vitest.config.*.timestamp*

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx --no -- commitlint --edit "$1"

.husky/pre-commit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
. "$(dirname -- "$0")/_/husky.sh"
33

44
# tests
5-
npm test
5+
npx nx run eslint-config:test
66

77
# docs script
8-
npm run docs
9-
git add docs README.md
8+
npx nx run eslint-config:docs
9+
git add packages/eslint-config/docs packages/eslint-config/README.md
1010

1111
# Prettier (https://prettier.io/docs/en/precommit.html#option-5-shell-script)
1212
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')

.prettierignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
*.md
1+
*.md
2+
dist
3+
coverage
4+
.nx

.release-it.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Contributing
2+
3+
## Setup
4+
5+
Prerequisites:
6+
7+
- Node.js installed (version specified in [`.node-version`](./.node-version))
8+
9+
Make sure to install dependencies:
10+
11+
```sh
12+
npm install
13+
```
14+
15+
## Development
16+
17+
Refer to docs on [how to run tasks in Nx](https://nx.dev/features/run-tasks).
18+
19+
Some examples:
20+
21+
```sh
22+
# visualize project graph
23+
npx nx graph
24+
25+
# run tests for all projects
26+
npx nx run-many -t test
27+
28+
# run tests for a specific project
29+
npx nx run eslint-config:test
30+
31+
# run lint for all projects
32+
npx nx run-many -t lint
33+
34+
# run type check for all projects
35+
npx nx run-many -t typecheck
36+
37+
# check formatting
38+
npx nx format:check
39+
40+
# fix formatting
41+
npx nx format:write
42+
43+
# generate docs for eslint-config
44+
npx nx run eslint-config:docs
45+
```
46+
47+
## Commits
48+
49+
This repository uses [conventional commits](https://www.conventionalcommits.org/). Commit messages are linted with [Commitlint](https://commitlint.js.org/) and must follow the format:
50+
51+
```
52+
type(scope): description
53+
```
54+
55+
Valid scopes correspond to Nx project names (e.g. `eslint-config`, `create-eslint-config`).
56+
57+
You can use [Commitizen](https://commitizen-tools.github.io/commitizen/) to create commits interactively:
58+
59+
```sh
60+
npm run commit
61+
```
62+
63+
## Releases
64+
65+
Releases are managed with [Nx release](https://nx.dev/features/manage-releases). Both packages are published together under the same version (fixed releases).
66+
67+
To create a release manually:
68+
69+
```sh
70+
npx nx release
71+
```
72+
73+
To preview a release without making changes:
74+
75+
```sh
76+
npx nx release --dry-run
77+
```

README.md

Lines changed: 7 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,14 @@
11
# @code-pushup/eslint-config
22

33
[![npm](https://img.shields.io/npm/v/%40code-pushup%2Feslint-config.svg)](https://www.npmjs.com/package/@code-pushup/eslint-config)
4+
[![CI](https://github.com/code-pushup/eslint-config/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/code-pushup/eslint-config/actions/workflows/ci.yml?query=branch%3Amain)
45
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
56

6-
Recommended ESLint presets by [Code PushUp](https://github.com/code-pushup/cli/tree/main/packages/cli).
7+
Monorepo for [Code PushUp](https://github.com/code-pushup/cli) ESLint packages.
78

8-
<!-- begin autogenerated -->
9+
## Packages
910

10-
## ⚙️ Configs
11-
12-
| Stack | Config | Description |
13-
| :--------------------------------------------------------: | :------------------------------------------------------- | :------------------------------------------------------------------ |
14-
| ![javascript](./docs/icons/material/javascript.png) | [javascript](./docs/javascript.md) | Default config, suitable for any **JavaScript/TypeScript** project. |
15-
| ![typescript](./docs/icons/material/typescript.png) | [typescript](./docs/typescript.md) | Config for strict **TypeScript** projects. |
16-
| ![nodejs](./docs/icons/material/nodejs.png) | [node](./docs/node.md) | Config for **Node.js** projects. |
17-
| ![angular](./docs/icons/material/angular.png) | [angular](./docs/angular.md) | Config for **Angular** projects. |
18-
| ![ngrx](./docs/icons/other/ngrx.png) | [ngrx](./docs/ngrx.md) | Config for **Angular** projects using **NgRx** library. |
19-
| ![react](./docs/icons/material/react.png) | [react](./docs/react.md) | Config for **React** projects. |
20-
| ![graphql](./docs/icons/material/graphql.png) | [graphql](./docs/graphql.md) | Config for **GraphQL servers** implemented in Node.js. |
21-
| ![jest](./docs/icons/material/jest.png) | [jest](./docs/jest.md) | Config for projects using **Jest** for testing. |
22-
| ![vitest](./docs/icons/material/vitest.png) | [vitest](./docs/vitest.md) | Config for projects using **Vitest** for testing. |
23-
| ![cypress](./docs/icons/material/cypress.png) | [cypress](./docs/cypress.md) | Config for projects using **Cypress** for testing. |
24-
| ![playwright](./docs/icons/material/playwright.png) | [playwright](./docs/playwright.md) | Config for projects using **Playwright** for testing. |
25-
| ![storybook](./docs/icons/material/storybook.png) | [storybook](./docs/storybook.md) | Config for projects using **Storybook** for UI components. |
26-
| ![testing-library](./docs/icons/other/testing-library.png) | [react-testing-library](./docs/react-testing-library.md) | Config for projects using **React Testing Library** for testing. |
27-
28-
Some configs extend other configs, as illustrated below. So, for example, extending `angular` config implicitly extends `typescript` and `javascript` configs as well.
29-
30-
```mermaid
31-
graph BT;
32-
typescript --extends--> javascript
33-
node --extends--> javascript
34-
angular --extends--> typescript
35-
ngrx --extends--> angular
36-
react --extends--> javascript
37-
graphql --extends--> node
38-
```
39-
40-
### 🏗️ Setup
41-
42-
To use the default config, follow these steps:
43-
44-
1. You must first install all the required peer dependencies (if you haven't already):
45-
46-
```sh
47-
npm install -D eslint @eslint/js eslint-plugin-{functional,import,promise,sonarjs,unicorn} globals typescript-eslint
48-
```
49-
50-
2. Install `@code-pushup/eslint-config` with:
51-
52-
```sh
53-
npm install -D @code-pushup/eslint-config
54-
```
55-
56-
3. Include default config in your [ESLint configuration file](https://eslint.org/docs/latest/use/configure/configuration-files) (usually `eslint.config.js`):
57-
58-
```js
59-
import javascript from '@code-pushup/eslint-config/javascript.js';
60-
import { defineConfig } from 'eslint/config';
61-
62-
export default defineConfig(...javascript);
63-
```
64-
65-
Depending on your tech stack, you may wish to extend other configs as well ([listed above](#⚙️-configs)). This will require installing additional peer dependencies. For more details, refer to setup docs for the configs you're interested in using.
66-
67-
#### 📦 Peer dependencies
68-
69-
All peer dependencies used by `@code-pushup/eslint-config` are listed below, along with their supported versions. Only the default config's dependencies are required, others are optional.
70-
71-
| | NPM package | Version | Required |
72-
| :--------------------------------------------------------: | :--------------------------------------------------------------------------------------------------- | :----------------------------------------------: | :------: |
73-
| ![eslint](./docs/icons/material/eslint.png) | [eslint](https://www.npmjs.com/package/eslint) | `^9.0.0` ||
74-
| ![eslint](./docs/icons/material/eslint.png) | [@eslint/js](https://www.npmjs.com/package/@eslint/js) | `^9.0.0` ||
75-
| ![lambda](./docs/icons/icons8/lambda.png) | [eslint-plugin-functional](https://www.npmjs.com/package/eslint-plugin-functional) | `^7.0.0 \|\| ^8.0.0 \|\| ^9.0.0` ||
76-
| ![import](./docs/icons/icons8/import.png) | [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import) | `^2.31.0` ||
77-
| ![import](./docs/icons/icons8/import.png) | [eslint-import-resolver-typescript](https://www.npmjs.com/package/eslint-import-resolver-typescript) | `^3.0.0 \|\| ^4.0.0` | |
78-
| ![promise](./docs/icons/icons8/promise.png) | [eslint-plugin-promise](https://www.npmjs.com/package/eslint-plugin-promise) | `>=6.4.0` ||
79-
| ![sonar](./docs/icons/other/sonar.png) | [eslint-plugin-sonarjs](https://www.npmjs.com/package/eslint-plugin-sonarjs) | `^1.0.4` ||
80-
| ![unicorn](./docs/icons/icons8/unicorn.png) | [eslint-plugin-unicorn](https://www.npmjs.com/package/eslint-plugin-unicorn) | `>=50.0.0` ||
81-
| ![global](./docs/icons/icons8/global.png) | [globals](https://www.npmjs.com/package/globals) | `>=14.0.0` ||
82-
| ![typescript](./docs/icons/material/typescript.png) | [typescript-eslint](https://www.npmjs.com/package/typescript-eslint) | `^8.0.0` ||
83-
| ![graphql](./docs/icons/material/graphql.png) | [@graphql-eslint/eslint-plugin](https://www.npmjs.com/package/@graphql-eslint/eslint-plugin) | `^3.0.0 \|\| ^4.0.0` | |
84-
| ![ngrx](./docs/icons/other/ngrx.png) | [@ngrx/eslint-plugin](https://www.npmjs.com/package/@ngrx/eslint-plugin) | `^18.0.0 \|\| ^19.0.0 \|\| ^20.0.0 \|\| ^21.0.0` | |
85-
| ![vitest](./docs/icons/material/vitest.png) | [@vitest/eslint-plugin](https://www.npmjs.com/package/@vitest/eslint-plugin) | `^1.1.9` | |
86-
| ![angular](./docs/icons/material/angular.png) | [angular-eslint](https://www.npmjs.com/package/angular-eslint) | `^18.0.0 \|\| ^19.0.0 \|\| ^20.0.0 \|\| ^21.0.0` | |
87-
| ![cypress](./docs/icons/material/cypress.png) | [eslint-plugin-cypress](https://www.npmjs.com/package/eslint-plugin-cypress) | `>=3.3.0` | |
88-
| ![jest](./docs/icons/material/jest.png) | [eslint-plugin-jest](https://www.npmjs.com/package/eslint-plugin-jest) | `^28.8.0 \|\| ^29.0.0` | |
89-
| ![accessibility](./docs/icons/icons8/accessibility.png) | [eslint-plugin-jsx-a11y](https://www.npmjs.com/package/eslint-plugin-jsx-a11y) | `^6.10.0` | |
90-
| ![nodejs](./docs/icons/material/nodejs.png) | [eslint-plugin-n](https://www.npmjs.com/package/eslint-plugin-n) | `>=17.0.0` | |
91-
| ![playwright](./docs/icons/material/playwright.png) | [eslint-plugin-playwright](https://www.npmjs.com/package/eslint-plugin-playwright) | `^2.1.0` | |
92-
| ![react](./docs/icons/material/react.png) | [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) | `^7.36.0` | |
93-
| ![react_ts](./docs/icons/material/react_ts.png) | [eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks) | `>=5.0.0` | |
94-
| ![rxjs](./docs/icons/other/rxjs.png) | [eslint-plugin-rxjs-x](https://www.npmjs.com/package/eslint-plugin-rxjs-x) | `>=0.6.0` | |
95-
| ![storybook](./docs/icons/material/storybook.png) | [eslint-plugin-storybook](https://www.npmjs.com/package/eslint-plugin-storybook) | `>=0.10.0` | |
96-
| ![testing-library](./docs/icons/other/testing-library.png) | [eslint-plugin-testing-library](https://www.npmjs.com/package/eslint-plugin-testing-library) | `^7.1.1` | |
97-
98-
### 🧪 Test overrides
99-
100-
For non-production code, some rules are disabled (or downgraded from errors to warnings).
101-
102-
This applies to file paths matching any of the following globs:
103-
104-
- `**/*.spec.?(c|m)[jt]s?(x)`
105-
- `**/*.test.?(c|m)[jt]s?(x)`
106-
- `**/__tests__/**/*.?(c|m)[jt]s?(x)`
107-
- `**/__mocks__/**/*.?(c|m)[jt]s?(x)`
108-
- `**/*.cy.?(c|m)[jt]s?(x)`
109-
- `**/*.stories.?(c|m)[jt]s?(x)`
110-
- `**/*.e2e.?(c|m)[jt]s?(x)`
111-
- `**/*.mock.?(c|m)[jt]s?(x)`
112-
- `**/*.mocks.?(c|m)[jt]s?(x)`
113-
- `**/test/**/*.?(c|m)[jt]s?(x)`
114-
- `**/tests/**/*.?(c|m)[jt]s?(x)`
115-
- `**/mocks/**/*.?(c|m)[jt]s?(x)`
116-
- `**/testing-utils/**/*.?(c|m)[jt]s?(x)`
117-
- `**/test-utils/**/*.?(c|m)[jt]s?(x)`
118-
- `**/fixtures/**/*.?(c|m)[jt]s?(x)`
119-
- `**/*.config.?(c|m)[jt]s`
120-
- `**/.prettierrc.?(c|m)[jt]s`
121-
- `**/codegen.?(c|m)[jt]s`
122-
- `**/test-setup.?(c|m)[jt]s`
123-
124-
<!-- end autogenerated -->
125-
126-
## 🫴 Contributing
127-
128-
Node.js installation is a prerequisite (LTS version). Install dependencies with NPM:
129-
130-
```sh
131-
npm install
132-
```
133-
134-
To execute tests:
135-
136-
```sh
137-
npm test
138-
```
139-
140-
To generate documentation:
141-
142-
```sh
143-
npm run docs
144-
```
11+
| Package | Description |
12+
| :------------------------------------------------------------------- | :------------------------------------------- |
13+
| [`@code-pushup/eslint-config`](./packages/eslint-config/README.md) | Recommended ESLint presets by Code PushUp |
14+
| `@code-pushup/create-eslint-config` | Interactive setup wizard _(coming soon)_ |

0 commit comments

Comments
 (0)