# Environment `env.node`

Creates configuration objects with global symbols and linter rules for NodeJS modules. Adds the plugin [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) and its recommended rules.

## Signature

```ts
function node(options: EnvNodeOptions): ConfigArg
```

## Options

| Name | Type | Default | Description |
| - | - | - | - |
| `basePath` | `string` | `'.'` | Path to a sub directory to apply the environment preset to. |
| `files` | `Array<string\|string[]>` | _required_ | Glob patterns for source files to be included. Use embedded arrays for AND patterns. |
| `ignores` | `string[]` | `[]` | Glob patterns for source files matching `files` to be ignored. |
| `sourceType` | `'module'\|'commonjs'` | `'module'` | Specifies how to treat `.js`, `.jsx`, `.ts`, and `.tsx`. |
| `restricted` | `EnvRestrictedOptions` | `{}` | Settings for banned globals, imports, object properties, and syntax constructs (see below). |
| `rules` | `RulesConfig` | `{}` | Additional linter rules to be added to the configuration. |

### Option `restricted`

- Type: `EnvRestrictedOptions`
- Default: `{}`

This option allows to specify banned globals, imports, object properties, and syntax constructs. See [documentation in `env.browser`](./browser.md#option-restricted) for a detailed description.

The environment `env.node` already defines the following built-in restrictions:

| Type | Name | Description |
| - | - | - |
| Globals | [`isFinite`](https://devdocs.io/javascript/global_objects/isfinite) | Use [`Number.isFinite`](https://devdocs.io/javascript/global_objects/number/isfinite) instead. |
| | [`isNaN`](https://devdocs.io/javascript/global_objects/isnan) | Use [`Number.isNaN`](https://devdocs.io/javascript/global_objects/number/isnan) instead. |
| Syntax | TypeScript `public` class field modifier | Can be omitted (except for constructors of classes deriving from a class with protected constructor). |
| | TypeScript `private` class field modifier | Use native `#private` class fields. |
| | [TypeScript parameter properties](https://www.typescriptlang.org/docs/handbook/2/classes.html#parameter-properties) | Use explicit class properties. |

## Example

```ts
// eslint.config.ts
import { defineConfig, env } from '@open-xchange/linter-presets/eslint'

export default defineConfig(

  // project configuration options
  { /* ... */ },

  // NodeJS environment
  env.node({
    files: ['*.config.{js,ts}', 'scripts/**/*.js'],
    rules: { /* ... */ },
  }),
)
```
