Skip to content

Commit 4d0c799

Browse files
authored
Merge pull request #1068 from manovotny/no-useless-path-segments-documentation
Adds no-useless-path-segments documentation.
2 parents 121b9e1 + 5569a8c commit 4d0c799

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).
55

66
## [Unreleased]
7+
- Add documentation for [`no-useless-path-segments`] rule ([#1068], thanks [@manovotny])
78
- Fixer for [`first`] ([#1046], thanks [@fengkfengk])
89

910
## [2.10.0] - 2018-03-29
@@ -452,6 +453,7 @@ for info on changes for earlier releases.
452453

453454
[`memo-parser`]: ./memo-parser/README.md
454455

456+
[#1068]: https://github.com/benmosher/eslint-plugin-import/pull/1068
455457
[#1046]: https://github.com/benmosher/eslint-plugin-import/pull/1046
456458
[#944]: https://github.com/benmosher/eslint-plugin-import/pull/944
457459
[#891]: https://github.com/benmosher/eslint-plugin-import/pull/891
@@ -694,3 +696,4 @@ for info on changes for earlier releases.
694696
[@graingert]: https://github.com/graingert
695697
[@danny-andrews]: https://github.com/dany-andrews
696698
[@fengkfengk]: https://github.com/fengkfengk
699+
[@manovotny]: https://github.com/manovotny

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
2525
* Forbid webpack loader syntax in imports ([`no-webpack-loader-syntax`])
2626
* Forbid a module from importing itself ([`no-self-import`])
2727
* Forbid a module from importing a module with a dependency path back to itself ([`no-cycle`])
28+
* Prevent unnecessary path segemnts in import and require statements ([`no-useless-path-segments`])
2829

2930
[`no-unresolved`]: ./docs/rules/no-unresolved.md
3031
[`named`]: ./docs/rules/named.md
@@ -37,6 +38,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
3738
[`no-webpack-loader-syntax`]: ./docs/rules/no-webpack-loader-syntax.md
3839
[`no-self-import`]: ./docs/rules/no-self-import.md
3940
[`no-cycle`]: ./docs/rules/no-cycle.md
41+
[`no-useless-path-segments`]: ./docs/rules/no-useless-path-segments.md
4042

4143
### Helpful warnings
4244

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# import/no-useless-path-segments
2+
3+
Use this rule to prevent unnecessary path segemnts in import and require statements.
4+
5+
## Rule Details
6+
7+
Given the following folder structure:
8+
9+
```
10+
my-project
11+
├── app.js
12+
├── footer.js
13+
├── header.js
14+
└── pages
15+
├── about.js
16+
├── contact.js
17+
└── index.js
18+
```
19+
20+
The following patterns are considered problems:
21+
22+
```js
23+
/**
24+
* in my-project/app.js
25+
*/
26+
27+
import "./../pages/about.js"; // should be "./pages/about.js"
28+
import "./../pages/about"; // should be "./pages/about"
29+
import "../pages/about.js"; // should be "./pages/about.js"
30+
import "../pages/about"; // should be "./pages/about"
31+
import "./pages//about"; // should be "./pages/about"
32+
import "./pages/"; // should be "./pages"
33+
```
34+
35+
The following patterns are NOT considered problems:
36+
37+
```js
38+
/**
39+
* in my-project/app.js
40+
*/
41+
42+
import "./header.js";
43+
import "./pages";
44+
import "./pages/about";
45+
import ".";
46+
import "..";
47+
import fs from "fs";
48+
```

0 commit comments

Comments
 (0)