Skip to content

Commit

Permalink
Merge pull request #1068 from manovotny/no-useless-path-segments-docu…
Browse files Browse the repository at this point in the history
…mentation

Adds no-useless-path-segments documentation.
  • Loading branch information
ljharb authored Apr 10, 2018
2 parents 121b9e1 + 5569a8c commit 4d0c799
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).

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

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

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

[#1068]: https://github.com/benmosher/eslint-plugin-import/pull/1068
[#1046]: https://github.com/benmosher/eslint-plugin-import/pull/1046
[#944]: https://github.com/benmosher/eslint-plugin-import/pull/944
[#891]: https://github.com/benmosher/eslint-plugin-import/pull/891
Expand Down Expand Up @@ -694,3 +696,4 @@ for info on changes for earlier releases.
[@graingert]: https://github.com/graingert
[@danny-andrews]: https://github.com/dany-andrews
[@fengkfengk]: https://github.com/fengkfengk
[@manovotny]: https://github.com/manovotny
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
* Forbid webpack loader syntax in imports ([`no-webpack-loader-syntax`])
* Forbid a module from importing itself ([`no-self-import`])
* Forbid a module from importing a module with a dependency path back to itself ([`no-cycle`])
* Prevent unnecessary path segemnts in import and require statements ([`no-useless-path-segments`])

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

### Helpful warnings

Expand Down
48 changes: 48 additions & 0 deletions docs/rules/no-useless-path-segments.md
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";
```

0 comments on commit 4d0c799

Please sign in to comment.