Skip to content

Commit dc65882

Browse files
committed
Add documentation for exports-last
1 parent 5ea8e5a commit dc65882

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
2626
- Properly report [`newline-after-import`] when next line is a decorator
2727
- Fixed documentation for the default values for the [`order`] rule ([#601])
2828

29+
### Added
30+
- [`exports-last`] lints that export statements are at the end of the file ([#620] + [#632])
31+
2932
## [2.0.1] - 2016-10-06
3033
### Fixed
3134
- Fixed code that relied on removed dependencies. ([#604])

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
6767
**Style guide:**
6868

6969
* Ensure all imports appear before other statements ([`first`])
70+
* Ensure all exports appear after other statements ([`exports-last`])
7071
* Report repeated import of the same module in multiple places ([`no-duplicates`])
7172
* Report namespace imports ([`no-namespace`])
7273
* Ensure consistent use of file extension within the import path ([`extensions`])
@@ -78,6 +79,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
7879
* Forbid named default exports ([`no-named-default`])
7980

8081
[`first`]: ./docs/rules/first.md
82+
[`exports-last`]: ./docs/rules/exports-last.md
8183
[`no-duplicates`]: ./docs/rules/no-duplicates.md
8284
[`no-namespace`]: ./docs/rules/no-namespace.md
8385
[`extensions`]: ./docs/rules/extensions.md

Diff for: docs/rules/exports-last.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# exports-last
2+
3+
This rule reports all export declaration which come before any non-export statements.
4+
5+
## This will be reported
6+
7+
```JS
8+
9+
const bool = true
10+
11+
export default bool
12+
13+
const str = 'foo'
14+
15+
```
16+
17+
```JS
18+
19+
export const bool = true
20+
21+
const str = 'foo'
22+
23+
```
24+
25+
## This will not be reported
26+
27+
```JS
28+
export const bool = true
29+
30+
export default bool
31+
32+
export function func() {
33+
console.log('Hello World 🌍')
34+
}
35+
36+
export const str = 'foo'
37+
```
38+
39+
## When Not To Use It
40+
41+
If you don't mind exports being sprinkled throughout a file, you may not want to enable this rule.

0 commit comments

Comments
 (0)