Skip to content

Commit

Permalink
Add documentation for exports-last
Browse files Browse the repository at this point in the history
  • Loading branch information
k15a committed Nov 3, 2016
1 parent 7e00bb2 commit 037d32b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
### Fixed
- [`prefer-default-export`] handles re-exported default exports ([#609])

### Added
- [`exports-last`] lints that export statements are at the end of the file ([#620] + [#632])

## [2.0.1] - 2016-10-06
### Fixed
- Fixed code that relied on removed dependencies. ([#604])
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ I want to apologize: I have been pretty unresponsive the last few weeks. My wife

I am hoping to be back in action on this in the next week or two, but I need to focus on my family and work in the immediate term. Fortunately, @jfmengels is a fantastic co-maintainer and has been doing a great job responding to new issues in my absence.

Thanks for your patience! 😎
Thanks for your patience! 😎

-- @benmosher

Expand Down Expand Up @@ -79,6 +79,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
**Style guide:**

* Ensure all imports appear before other statements ([`first`])
* Ensure all exports appear after other statements ([`exports-last`])
* Report repeated import of the same module in multiple places ([`no-duplicates`])
* Report namespace imports ([`no-namespace`])
* Ensure consistent use of file extension within the import path ([`extensions`])
Expand All @@ -89,6 +90,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
* Forbid unassigned imports. ([`no-unassigned-import`])

[`first`]: ./docs/rules/first.md
[`exports-last`]: ./docs/rules/exports-last.md
[`no-duplicates`]: ./docs/rules/no-duplicates.md
[`no-namespace`]: ./docs/rules/no-namespace.md
[`extensions`]: ./docs/rules/extensions.md
Expand Down
41 changes: 41 additions & 0 deletions docs/rules/exports-last.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# exports-last

This rule reports all export declaration which come before any non-export statements.

## This will be reported

```JS

const bool = true

export default bool

const str = 'foo'

```

```JS

export const bool = true

const str = 'foo'

```

## This will not be reported

```JS
export const bool = true

export default bool

export function func() {
console.log('Hello World 🌍')
}

export const str = 'foo'
```

## When Not To Use It

If you don't mind exports being sprinkled throughout a file, you may not want to enable this rule.

0 comments on commit 037d32b

Please sign in to comment.