https://github.com/jollytoad/deno-lint-no-cross-package-imports
Deno lint rule to prevent imports descending beyond the package root
https://github.com/jollytoad/deno-lint-no-cross-package-imports
deno deno-lint
Last synced: about 2 months ago
JSON representation
Deno lint rule to prevent imports descending beyond the package root
- Host: GitHub
- URL: https://github.com/jollytoad/deno-lint-no-cross-package-imports
- Owner: jollytoad
- License: mit
- Created: 2025-03-04T13:41:05.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-03-04T14:31:56.000Z (2 months ago)
- Last Synced: 2025-03-04T15:22:36.654Z (2 months ago)
- Topics: deno, deno-lint
- Language: TypeScript
- Homepage: https://jsr.io/@jollytoad/lint-no-cross-package-imports
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Deno Lint Plugin: no-cross-package-imports
This lint plugin prevents relative imports from descending beyond the root of
the package.The root of the package is currently deemed to be the nearest ancestor directory
containing a `deno.json`/`deno.jsonc`/`package.json` file.So if a relative import within the package descends beyond this and outside of
the deemed current package then the problem is reported.So given the file structure:
- `foo/deno.json`
- `foo/stuff.ts`
- `bar/util.ts`and `foo/stuff.ts` has:
```ts
import * as util from "../bar/util.ts";
```then the lint rule will report the problem.
## Usage
Add the following config to your `deno.json`:
```json
"lint": {
"plugins": [
"jsr:@jollytoad/lint-no-cross-package-imports"
]
}
```## Caveat
This lint rule requires filesystem access, but unfortunately it doesn't
currently seem possible to declare this in the plugin or allow it via a flag on
the `deno lint` command. So it will ask for filesystem access when you attempt
to lint with this plugin active.I don't know of any work-around for this atm, please let me know if you do.