forked from import-js/eslint-plugin-import
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds no-useless-path-segments documentation.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# import/no-useless-path-segments | ||
|
||
Use this rule to prevent unnecessary path segemnts in import and require statements. | ||
|
||
## Rule Details | ||
|
||
Given the following folder structure: | ||
|
||
``` | ||
my-project | ||
├── app.js | ||
├── footer.js | ||
├── header.js | ||
└── pages | ||
├── about.js | ||
├── contact.js | ||
└── index.js | ||
``` | ||
|
||
The following patterns are considered problems: | ||
|
||
```js | ||
/** | ||
* in my-project/app.js | ||
*/ | ||
|
||
import "./../pages/about.js"; // should be "./pages/about.js" | ||
import "./../pages/about"; // should be "./pages/about" | ||
import "../pages/about.js"; // should be "./pages/about.js" | ||
import "../pages/about"; // should be "./pages/about" | ||
import "./pages//about"; // should be "./pages/about" | ||
import "./pages/"; // should be "./pages" | ||
``` | ||
|
||
The following patterns are NOT considered problems: | ||
|
||
```js | ||
/** | ||
* in my-project/app.js | ||
*/ | ||
|
||
import "./header.js"; | ||
import "./pages"; | ||
import "./pages/about"; | ||
import "."; | ||
import ".."; | ||
import fs from "fs"; | ||
``` |