mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-13 01:54:52 +08:00
R=jacktfranklin@chromium.org No-Presubmit: True Bug: none Change-Id: I52dc24b12e350787085c5e3d131cface7ea87142 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3060705 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Paul Lewis <aerotwist@chromium.org>
1.3 KiB
1.3 KiB
import/no-relative-packages
Use this rule to prevent importing packages through relative paths.
It's useful in Yarn/Lerna workspaces, were 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:
my-project
├── packages
│ ├── foo
│ │ ├── index.js
│ │ └── package.json
│ └── bar
│ ├── index.js
│ └── package.json
└── entry.js
And the .eslintrc file:
{
...
"rules": {
"import/no-relative-packages": "error"
}
}
The following patterns are considered problems:
/**
* 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:
/**
* 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