-
Notifications
You must be signed in to change notification settings - Fork 0
/
export-default-identifier.test.ts
43 lines (40 loc) · 1.17 KB
/
export-default-identifier.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { RuleTester } from 'eslint-docgen'
import rule from './export-default-identifier'
const tester = new RuleTester({
parserOptions: {
ecmaVersion: 2015,
sourceType: 'module',
}
})
tester.run('export-default-identifier', rule, {
valid: [
{
code: `const myExport = {}
export default myExport`
},
{
code: `const myExport = {}
export default myExport`,
options: [{ types: ["Identifier", "FunctionDeclaration" ]}]
},
{
code: `export default function test() {}`,
options: [{ types: ["Identifier", "FunctionDeclaration" ]}]
},
],
invalid: [
{
code: `export default {}`,
errors: [{ message: 'Cannot export ObjectExpression. Must export identifier as default export for TypeDocs.' }]
},
{
code: `export default function test() {}`,
errors: [{ message: 'Cannot export FunctionDeclaration. Must export identifier as default export for TypeDocs.' }]
},
{
code: `export default {}`,
options: [{ types: ["Identifier", "FunctionDeclaration" ]}],
errors: [{ message: 'Cannot export ObjectExpression. Must export identifier as default export for TypeDocs.' }]
},
],
})