> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# no-path-concat

[Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, nodePlugin } from '@rslint/core';

export default defineConfig([
  nodePlugin.configs.recommended,
  {
    rules: {
      'node/no-path-concat': 'error',
    },
  },
]);
```

## Rule details

Disallow string concatenation with `__dirname`, `__filename`, and `import.meta` paths when the appended text starts with a path separator.

Use `path.join()` or `path.resolve()` to build file paths. These functions handle platform-specific separators and normalize the resulting path. Use `new URL()` to resolve relative URLs against `import.meta.url`.

Examples of **incorrect** code for this rule:

```javascript
const config = __dirname + '/config.json';
const child = `${__filename}/child`;
const assets = import.meta.dirname + '/assets';
const sibling = import.meta.filename + '/sibling';
const url = `${import.meta.url}/assets`;
```

Examples of **correct** code for this rule:

```javascript
const config = path.join(__dirname, 'config.json');
const child = path.resolve(__filename, 'child');
const assets = path.join(import.meta.dirname, 'assets');
const sibling = path.resolve(import.meta.filename, 'sibling');
const url = new URL('./assets', import.meta.url);

const sourceMap = __filename + '.map';
const backup = `${import.meta.filename}.bak`;
```

The rule checks `+` expressions and template strings. It recognizes `/`, the separator for the platform running the linter, and tracked `path.sep` reads. Appending an extension or another suffix without a leading separator is allowed.

`__dirname` and `__filename` must be enabled globals. Local declarations and parameters with these names are ignored, as are globals assigned anywhere in the file. `import.meta` paths do not require configured globals.

## Options

This rule has no options and provides no automatic fixes or suggestions.

## Differences from upstream

Some computed separators are not recognized. For example, `__dirname + String.fromCodePoint(47)` is reported by upstream but not by rslint. Using the equivalent literal `/` or `path.sep` makes this concatenation detectable.

## Original documentation

- [eslint-plugin-n: no-path-concat](https://github.com/eslint-community/eslint-plugin-n/blob/v18.3.0/docs/rules/no-path-concat.md)
- [Source code](https://github.com/eslint-community/eslint-plugin-n/blob/v18.3.0/lib/rules/no-path-concat.js)
