|
| 1 | +import { test } from '../utils' |
| 2 | +import { RuleTester } from 'eslint' |
| 3 | +import rule from 'rules/group-exports' |
| 4 | + |
| 5 | +const ruleTester = new RuleTester() |
| 6 | + |
| 7 | +ruleTester.run('group-exports', rule, { |
| 8 | + valid: [ |
| 9 | + test({ code: 'export const test = true' }), |
| 10 | + test({ code: 'export default {}\nexport const test = true' }), |
| 11 | + test({ code: [ |
| 12 | + 'const first = true', |
| 13 | + 'const second = true', |
| 14 | + 'export { first,\nsecond }', |
| 15 | + ].join('\n') }), |
| 16 | + test({ code: 'module.exports = {} '}), |
| 17 | + test({ code: 'module.exports = { test: true,\nanother: false }' }), |
| 18 | + test({ code: 'exports.test = true' }), |
| 19 | + ], |
| 20 | + invalid: [ |
| 21 | + test({ |
| 22 | + code: [ |
| 23 | + 'export const test = true', |
| 24 | + 'export const another = true', |
| 25 | + ].join('\n'), |
| 26 | + errors: [ |
| 27 | + 'Multiple named export declarations', |
| 28 | + 'Multiple named export declarations', |
| 29 | + ], |
| 30 | + }), |
| 31 | + test({ |
| 32 | + code: [ |
| 33 | + 'module.exports = {}', |
| 34 | + 'module.exports.test = true', |
| 35 | + 'module.exports.another = true', |
| 36 | + ].join('\n'), |
| 37 | + errors: [ |
| 38 | + 'Multiple CommonJS exports', |
| 39 | + 'Multiple CommonJS exports', |
| 40 | + 'Multiple CommonJS exports', |
| 41 | + ], |
| 42 | + }), |
| 43 | + test({ |
| 44 | + code: [ |
| 45 | + 'module.exports = {}', |
| 46 | + 'module.exports = {}', |
| 47 | + ].join('\n'), |
| 48 | + errors: [ |
| 49 | + 'Multiple CommonJS exports', |
| 50 | + 'Multiple CommonJS exports', |
| 51 | + ], |
| 52 | + }), |
| 53 | + ], |
| 54 | +}) |
0 commit comments