Skip to content

Commit 150ac19

Browse files
committed
Document how to configure node version
1 parent 1bf4397 commit 150ac19

File tree

7 files changed

+86
-24
lines changed

7 files changed

+86
-24
lines changed

docs/angular.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ Config for **Angular** projects.
1111
npm install -D angular-eslint eslint-plugin-rxjs-x
1212
```
1313

14-
3. Refer to [step 3 in TypeScript config's setup docs](./typescript.md#🏗️-setup) for how to set up tsconfig properly.
15-
4. Add to your `eslint.config.js` file:
14+
3. Add to your `eslint.config.js` file:
1615

1716
```js
1817
import angular from '@code-pushup/eslint-config/angular.js';
@@ -52,6 +51,8 @@ Config for **Angular** projects.
5251
);
5352
```
5453

54+
4. Refer to [step 3 in TypeScript config's setup docs](./typescript.md#🏗️-setup) for how to set up tsconfig properly.
55+
5556
## 📏 Rules (425)
5657

5758
**345** rules are included from [`typescript` config](./typescript.md#📏-rules-345). For brevity, only the **80** additional rules are listed in this document.

docs/graphql.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@ Config for **GraphQL servers** implemented in Node.js.
1111
npm install -D @graphql-eslint/eslint-plugin eslint-plugin-n
1212
```
1313

14-
3. The GraphQL ESLint plugin needs to know where your GraphQL schema is located. For more information, refer to [_Extended Linting Rules with GraphQL Schema_ in GraphQL ESLint docs](https://the-guild.dev/graphql/eslint/docs/getting-started#extended-linting-rules-with-graphql-schema).
14+
3. Add to your `eslint.config.js` file:
15+
16+
```js
17+
import graphql from '@code-pushup/eslint-config/graphql.js';
18+
import tseslint from 'typescript-eslint';
19+
20+
export default tseslint.config(...graphql);
21+
```
22+
23+
4. The GraphQL ESLint plugin needs to know where your GraphQL schema is located. For more information, refer to [_Extended Linting Rules with GraphQL Schema_ in GraphQL ESLint docs](https://the-guild.dev/graphql/eslint/docs/getting-started#extended-linting-rules-with-graphql-schema).
1524
- If you're using [graphql-config](https://the-guild.dev/graphql/config/docs), then your GraphQL schema will be loaded automatically from your `.graphqlrc.yml` (or equivalent) file. So no extra setup is required in this case.
1625
- Otherwise, you can use [`parserOptions.schema`](https://the-guild.dev/graphql/eslint/docs/getting-started/parser-options#schema), e.g.:
1726

@@ -30,14 +39,6 @@ Config for **GraphQL servers** implemented in Node.js.
3039
}
3140
);
3241
```
33-
4. Add to your `eslint.config.js` file:
34-
35-
```js
36-
import graphql from '@code-pushup/eslint-config/graphql.js';
37-
import tseslint from 'typescript-eslint';
38-
39-
export default tseslint.config(...graphql);
40-
```
4142

4243
## 📏 Rules (317)
4344

docs/ngrx.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ Config for **Angular** projects using **NgRx** library.
1111
npm install -D @ngrx/eslint-plugin angular-eslint eslint-plugin-rxjs-x
1212
```
1313

14-
3. Refer to [step 3 in TypeScript config's setup docs](./typescript.md#🏗️-setup) for how to set up tsconfig properly.
15-
4. Add to your `eslint.config.js` file:
14+
3. Add to your `eslint.config.js` file:
1615

1716
```js
1817
import ngrx from '@code-pushup/eslint-config/ngrx.js';
@@ -52,6 +51,8 @@ Config for **Angular** projects using **NgRx** library.
5251
);
5352
```
5453

54+
4. Refer to [step 3 in TypeScript config's setup docs](./typescript.md#🏗️-setup) for how to set up tsconfig properly.
55+
5556
## 📏 Rules (455)
5657

5758
**425** rules are included from [`angular` config](./angular.md#📏-rules-425). For brevity, only the **30** additional rules are listed in this document.

docs/node.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,36 @@ Config for **Node.js** projects.
2020
export default tseslint.config(...node);
2121
```
2222

23+
4. Some rules (e.g. `n/no-unsupported-features/node-builtins`) need to know which Node version is being used. Configuration options include:
24+
- `engines` field in `package.json`:
25+
26+
```jsonc
27+
{
28+
// ...
29+
"engines": {
30+
"node": ">=22.12.0"
31+
}
32+
33+
```
34+
35+
- `settings.node.version` in `eslint.config.js`:
36+
37+
```js
38+
export default tseslint.config({
39+
// ...
40+
{
41+
settings: {
42+
node: {
43+
version: '>=22.12.0'
44+
}
45+
}
46+
}
47+
});
48+
49+
```
50+
51+
For more information, refer to [`eslint-plugin-n` docs](https://github.com/eslint-community/eslint-plugin-n?tab=readme-ov-file#configured-nodejs-version-range).
52+
2353
## 📏 Rules (294)
2454
2555
**290** rules are included from [`javascript` config](./javascript.md#📏-rules-290). For brevity, only the **4** additional rules are listed in this document.

docs/typescript.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@ Config for strict **TypeScript** projects.
55
## 🏗️ Setup
66

77
1. If you haven't already, make sure to [install `@code-pushup/eslint-config` and its required peer dependencies](../README.md#🏗️-setup).
8-
2. Because this config includes rules which require type information, make sure to configure `parserOptions.project` in your .eslintrc points to your project's tsconfig.
8+
2. Add to your `eslint.config.js` file:
9+
10+
```js
11+
import typescript from '@code-pushup/eslint-config/typescript.js';
12+
import tseslint from 'typescript-eslint';
13+
14+
export default tseslint.config(...typescript);
15+
```
16+
17+
3. Because this config includes rules which require type information, make sure to configure `parserOptions.project` in your `eslint.config.js` points to your project's tsconfig.
918
For more information, refer to [_Linting with Type Information_ (typescript-eslint)](https://typescript-eslint.io/linting/typed-linting).
1019

1120
- Example for library in Nx monorepo:
@@ -54,14 +63,6 @@ Config for strict **TypeScript** projects.
5463
}
5564
);
5665
```
57-
3. Add to your `eslint.config.js` file:
58-
59-
```js
60-
import typescript from '@code-pushup/eslint-config/typescript.js';
61-
import tseslint from 'typescript-eslint';
62-
63-
export default tseslint.config(...typescript);
64-
```
6566

6667
## 📏 Rules (345)
6768

scripts/helpers/configs.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const tsConfigDocsReference = md`Refer to ${md.link('./typescript.md#🏗️-set
7171
/** @type {Partial<Record<keyof typeof configDescriptions, import('build-md').FormattedText>>} */
7272
export const configsExtraSetupDocs = {
7373
typescript: md`${md.paragraph(
74-
md`Because this config includes rules which require type information, make sure to configure ${md.code('parserOptions.project')} in your .eslintrc points to your project's tsconfig.
74+
md`Because this config includes rules which require type information, make sure to configure ${md.code('parserOptions.project')} in your ${md.code('eslint.config.js')} points to your project's tsconfig.
7575
For more information, refer to ${md.link('https://typescript-eslint.io/linting/typed-linting', md`${md.italic('Linting with Type Information')} (typescript-eslint)`)}.${md.list(
7676
[
7777
md`Example for library in Nx monorepo:${md.codeBlock(
@@ -122,6 +122,34 @@ export default tseslint.config(
122122
angular: tsConfigDocsReference,
123123
ngrx: tsConfigDocsReference,
124124

125+
node: md`Some rules (e.g. ${md.code('n/no-unsupported-features/node-builtins')}) need to know which Node version is being used. Configuration options include:${md.list(
126+
[
127+
md`${md.code('engines')} field in ${md.code('package.json')}: ${md.codeBlock(
128+
'jsonc',
129+
`{
130+
// ...
131+
"engines": {
132+
"node": ">=22.12.0"
133+
}
134+
`,
135+
)}`,
136+
md`${md.code('settings.node.version')} in ${md.code('eslint.config.js')}: ${md.codeBlock(
137+
'js',
138+
`export default tseslint.config({
139+
// ...
140+
{
141+
settings: {
142+
node: {
143+
version: '>=22.12.0'
144+
}
145+
}
146+
}
147+
});
148+
`,
149+
)}`,
150+
],
151+
)}${md.paragraph(md`For more information, refer to ${md.link('https://github.com/eslint-community/eslint-plugin-n?tab=readme-ov-file#configured-nodejs-version-range', md`${md.code('eslint-plugin-n')} docs`)}.`)}`,
152+
125153
graphql: md`The GraphQL ESLint plugin needs to know where your GraphQL schema is located. For more information, refer to ${md.link('https://the-guild.dev/graphql/eslint/docs/getting-started#extended-linting-rules-with-graphql-schema', md`${md.italic('Extended Linting Rules with GraphQL Schema')} in GraphQL ESLint docs`)}.${md.list(
126154
[
127155
md`If you're using ${md.link('https://the-guild.dev/graphql/config/docs', 'graphql-config')}, then your GraphQL schema will be loaded automatically from your ${md.code('.graphqlrc.yml')} (or equivalent) file. So no extra setup is required in this case.`,

scripts/helpers/format-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export function configRulesToMarkdown(
7070
)}`,
7171
]
7272
: []),
73-
...(extraSetupDocs ? [extraSetupDocs] : []),
7473
md`Add to your ${md.code('eslint.config.js')} file:${md.codeBlock(
7574
'js',
7675
[
@@ -86,6 +85,7 @@ export function configRulesToMarkdown(
8685
: [`export default tseslint.config(...${config});`]),
8786
].join('\n'),
8887
)}`,
88+
...(extraSetupDocs ? [extraSetupDocs] : []),
8989
]),
9090
)
9191
.heading(2, `📏 Rules (${totalRulesCount})`)

0 commit comments

Comments
 (0)