# @typescript-eslint/triple-slash-reference

> Disallow `/// <reference />` comments where an `import` does the job

`/// <reference path="..." />` and `/// <reference types="..." />` pull another file or a type package into the current file from a comment. A comment is easy to overlook, tools that follow imports don't see it, and it stays behind when the code that needed it is gone. Use an `import` instead.

By default `path` references are always reported, `types` references are reported if the file also imports the same module, and `lib` references are allowed.

This rule is on by default in TypeScript files.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

On by default as a warning. To turn it off:

```toml bunfig.toml
[lint.rules]
"@typescript-eslint/triple-slash-reference" = "off" # or "error"
```

Every option, set to its default:

```toml bunfig.toml
[lint.rules]
"@typescript-eslint/triple-slash-reference" = ["warn", {
  path = "never", # "always" or "never"
  types = "prefer-import", # "always", "never" or "prefer-import"
  lib = "always", # "always" or "never"
}]
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 2} */}
```ts
/// <reference path="./globals.d.ts" />
/// <reference types="lodash" />
import { chunk } from "lodash";

export const pages = chunk([1, 2, 3, 4], 2);
```

Not reported:

{/* good */}
```ts
/// <reference lib="dom" />
/// <reference types="bun" />
import "./globals";
import { chunk } from "lodash";

export const pages = chunk([1, 2, 3, 4], 2);
```

## Options

| Option | Default | What it does |
| --- | --- | --- |
| `path` | `"never"` | `"never"` reports `/// <reference path="..." />`. `"always"` allows it. |
| `types` | `"prefer-import"` | `"never"` reports `/// <reference types="..." />`. `"always"` allows it. `"prefer-import"` reports it only if the file imports a module with the same name. |
| `lib` | `"always"` | `"never"` reports `/// <reference lib="..." />`. `"always"` allows it. |

Both are reported with `types: "never"` and `lib: "never"`:

{/* bad {"count": 2, "options": [{"types": "never", "lib": "never"}]} */}
```ts
/// <reference lib="dom" />
/// <reference types="bun" />
export const title = document.title;
```
