Skip to content

Commit

Permalink
Adds no-useless-path-segments documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
manovotny committed Apr 7, 2018
1 parent 80d1ceb commit 37bd542
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
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 37bd542

Please sign in to comment.