Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Resolved conflicts by taking GitHub versions for: - .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml Kept deploy.sh updated to: - Pull from GitHub (primary source) - Push to Gitea (push-mirror) - Build from site/ directory (GitHub structure) Co-Authored-By: Paperclip <noreply@paperclip.ing>
70 lines
1.5 KiB
Markdown
70 lines
1.5 KiB
Markdown
# import/no-relative-packages
|
|
|
|
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
|
|
|
<!-- end auto-generated rule header -->
|
|
|
|
Use this rule to prevent importing packages through relative paths.
|
|
|
|
It's useful in Yarn/Lerna workspaces, where it's possible to import a sibling package using `../package` relative path, while direct `package` is the correct one.
|
|
|
|
## Examples
|
|
|
|
Given the following folder structure:
|
|
|
|
```pt
|
|
my-project
|
|
├── packages
|
|
│ ├── foo
|
|
│ │ ├── index.js
|
|
│ │ └── package.json
|
|
│ └── bar
|
|
│ ├── index.js
|
|
│ └── package.json
|
|
└── entry.js
|
|
```
|
|
|
|
And the .eslintrc file:
|
|
|
|
```json
|
|
{
|
|
...
|
|
"rules": {
|
|
"import/no-relative-packages": "error"
|
|
}
|
|
}
|
|
```
|
|
|
|
The following patterns are considered problems:
|
|
|
|
```js
|
|
/**
|
|
* in my-project/packages/foo.js
|
|
*/
|
|
|
|
import bar from '../bar'; // Import sibling package using relative path
|
|
import entry from '../../entry.js'; // Import from parent package using relative path
|
|
|
|
/**
|
|
* in my-project/entry.js
|
|
*/
|
|
|
|
import bar from './packages/bar'; // Import child package using relative path
|
|
```
|
|
|
|
The following patterns are NOT considered problems:
|
|
|
|
```js
|
|
/**
|
|
* in my-project/packages/foo.js
|
|
*/
|
|
|
|
import bar from 'bar'; // Import sibling package using package name
|
|
|
|
/**
|
|
* in my-project/entry.js
|
|
*/
|
|
|
|
import bar from 'bar'; // Import sibling package using package name
|
|
```
|