36 lines
No EOL
3.6 KiB
JavaScript
36 lines
No EOL
3.6 KiB
JavaScript
'use strict';
|
|
|
|
function isNonExportStatement(_ref) {
|
|
let type = _ref.type;
|
|
|
|
return type !== 'ExportDefaultDeclaration' && type !== 'ExportNamedDeclaration' && type !== 'ExportAllDeclaration';
|
|
}
|
|
|
|
module.exports = {
|
|
create: function (context) {
|
|
return {
|
|
Program: function (_ref2) {
|
|
let body = _ref2.body;
|
|
|
|
const lastNonExportStatementIndex = body.reduce(function findLastIndex(acc, item, index) {
|
|
if (isNonExportStatement(item)) {
|
|
return index;
|
|
}
|
|
return acc;
|
|
}, -1);
|
|
|
|
if (lastNonExportStatementIndex !== -1) {
|
|
body.slice(0, lastNonExportStatementIndex).forEach(function checkNonExport(node) {
|
|
if (!isNonExportStatement(node)) {
|
|
context.report({
|
|
node,
|
|
message: 'Export statements should appear at the end of the file'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
}
|
|
};
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL2V4cG9ydHMtbGFzdC5qcyJdLCJuYW1lcyI6WyJpc05vbkV4cG9ydFN0YXRlbWVudCIsInR5cGUiLCJtb2R1bGUiLCJleHBvcnRzIiwiY3JlYXRlIiwiY29udGV4dCIsIlByb2dyYW0iLCJib2R5IiwibGFzdE5vbkV4cG9ydFN0YXRlbWVudEluZGV4IiwicmVkdWNlIiwiZmluZExhc3RJbmRleCIsImFjYyIsIml0ZW0iLCJpbmRleCIsInNsaWNlIiwiZm9yRWFjaCIsImNoZWNrTm9uRXhwb3J0Iiwibm9kZSIsInJlcG9ydCIsIm1lc3NhZ2UiXSwibWFwcGluZ3MiOiI7O0FBQUEsU0FBU0Esb0JBQVQsT0FBd0M7QUFBQSxNQUFSQyxJQUFRLFFBQVJBLElBQVE7O0FBQ3RDLFNBQU9BLFNBQVMsMEJBQVQsSUFDTEEsU0FBUyx3Qk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