Skip to content

Commit

Permalink
Update coding style, documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrossmann committed Jan 18, 2017
1 parent d4bed97 commit 03225eb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
10 changes: 5 additions & 5 deletions docs/rules/group-exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ This rule warns whenever a single file contains multiple named exports or assign
### Valid

```js
// Default export is adjacent to named export -> ok
// Default export statement is adjacent to named export -> ok
export default function test() {}
// A single named export -> ok
// A single named export statement -> ok
export const valid = true
```

```js
const first = true
const second = true

// A single named export -> ok
// A single named export statement -> ok
export {
first,
second,
Expand All @@ -39,13 +39,13 @@ module.exports = {
### Invalid

```js
// Multiple named exports -> not ok!
// Multiple named export statements -> not ok!
export const first = true
export const second = true
```

```js
// Default export is not adjacent to the named export -> not ok!
// Default export is not adjacent to the named export statement -> not ok!
export default {}
const first = true
export { first }
Expand Down
18 changes: 9 additions & 9 deletions src/rules/group-exports.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
const meta = {}
/* eslint-disable max-len */
const errors = {
ExportNamedDeclaration:
'Multiple named export declarations; consolidate all named exports into a single statement',
ExportDefaultDeclaration:
'Default export declaration should be adjacent to named export',
MemberExpression:
'Multiple CommonJS exports; consolidate all exports into a single assignment to ' +
'`module.exports`',
ExportNamedDeclaration: 'Multiple named export declarations; consolidate all named exports into a single statement',
ExportDefaultDeclaration: 'Default export declaration should be adjacent to named export',
MemberExpression: 'Multiple CommonJS exports; consolidate all exports into a single assignment to `module.exports`',
}
/* eslint-enable max-len */

/**
* Check if two nodes are adjacent (only whitespace between them)
Expand Down Expand Up @@ -85,7 +83,8 @@ function create(context) {
return
}

return void exports.named.add(node)
exports.named.add(node)
return
}

if (node.object.name === 'exports') {
Expand All @@ -94,7 +93,8 @@ function create(context) {
return
}

return void exports.named.add(node)
exports.named.add(node)
return
}
},

Expand Down
12 changes: 5 additions & 7 deletions tests/src/rules/group-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import { test } from '../utils'
import { RuleTester } from 'eslint'
import rule from 'rules/group-exports'

/* eslint-disable max-len */
const errors = {
named:
'Multiple named export declarations; consolidate all named exports into a single statement',
default:
'Default export declaration should be adjacent to named export',
commonjs:
'Multiple CommonJS exports; consolidate all exports into a single assignment to ' +
'`module.exports`',
named: 'Multiple named export declarations; consolidate all named exports into a single statement',
default: 'Default export declaration should be adjacent to named export',
commonjs: 'Multiple CommonJS exports; consolidate all exports into a single assignment to `module.exports`',
}
/* eslint-enable max-len */
const ruleTester = new RuleTester()

ruleTester.run('group-exports', rule, {
Expand Down

0 comments on commit 03225eb

Please sign in to comment.