# `import.unneeded`

A file imports a name it already sees without a `use` line, such as a built-in or something its test subject declares.

Area 1, [Project layout and modules](/docs/project-layout-and-modules.md); not declinable; the next step is usually the agent's.

## Why Jadpo refuses it

A `use` line tells a reader where a name lives. Some names need no such
line, because where they live is already plain: built-in types and the
standard library, what the file declares itself, what a test file's
subject declares, and the file's own domain. An import of one of them
says nothing, and suggests the name lives somewhere it doesn't.

## What it looks like

domains/menu/actions/stock_item.jadpo:



```jadpo
use shared/types { Stock }

/// A loaf's stock before any choices.
function loaf_stock() -> Stock {
    return 250
}

action stock_item() -> Stock {
    return loaf_stock()
}
```

domains/menu/actions/stock_item.test.jadpo, its test file:

```jadpo
use menu/actions { loaf_stock }

test "a loaf has 250 in stock" {
    assert loaf_stock() == 250
}
```

```text
error: `loaf_stock` is declared in this test's subject
 --> domains/menu/actions/stock_item.test.jadpo:1:20
  |
1 | use menu/actions { loaf_stock }
  |                    ^^^^^^^^^^ needs no import
  reason: A test file sees everything its subject declares without importing it, and `loaf_stock` is in `stock_item.jadpo`.
  next: Remove this line (agent)
  rule: import.unneeded
  help: https://jadpo.dev/docs/errors/import.unneeded

check failed: 1 error, 4 files
```

`(agent)` at the end of the `next:` line means your coding agent can make
the fix itself.

## How to fix it

**If the name is one the file already sees**, remove the line.
`domains/menu/actions/stock_item.test.jadpo` becomes:

```jadpo
test "a loaf has 250 in stock" {
    assert loaf_stock() == 250
}
```




The test calls `loaf_stock` directly, as it already could. Anything else
it uses still comes in on a `use` line.

## Related

- [What is imported](/docs/imports.md#what-is-imported)
- [What `jadpo check` reports](/docs/imports.md#what-jadpo-check-reports)
- [A test beside its subject](/docs/where-tests-live.md#a-test-beside-its-subject)
