Skip to content

Commit

Permalink
add more docs and return to foo bar instead of x y as variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
gavriguy committed May 7, 2016
1 parent 8467c27 commit 93f4dd8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
18 changes: 18 additions & 0 deletions docs/rules/prefer-default-export.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,28 @@ export const foo = 'foo';
const bar = 'bar';
export default 'bar';
```

```javascript
// good2.js

// There is more thank one named exports in the module.
export const foo = 'foo';
export const bar = 'bar';
```

```javascript
// good3.js

// There is more thank one named exports in the module
const foo = 'foo';
const bar = 'bar';
export { foo, bar }
```

```javascript
// good4.js

// There is a default export.
const foo = 'foo';
export { foo as default }
```
18 changes: 9 additions & 9 deletions tests/src/rules/prefer-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,36 @@ ruleTester.run('prefer-default-export', rule, {
valid: [
test({
code: `
export const x = 'x';
export const y = 'y';`,
export const foo = 'foo';
export const bar = 'bar';`,
}),
test({
code: `
export const x = 'x';
export default y;`,
export const foo = 'foo';
export default bar;`,
}),
test({
code: `
export { x, y }`,
export { foo, bar }`,
}),
test({
code: `
export { z as default }`,
export { foo as default }`,
}),
],
invalid: [
test({
code: `
export const x = 'x';`,
export const foo = 'foo';`,
errors: [{
ruleId: 'ExportNamedDeclaration',
message: 'Prefer default export.',
}],
}),
test({
code: `
const x = 'x';
export { x };`,
const foo = 'foo';
export { foo };`,
errors: [{
ruleId: 'ExportNamedDeclaration',
message: 'Prefer default export.',
Expand Down

0 comments on commit 93f4dd8

Please sign in to comment.