mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-08-25 08:08:00 +00:00
41 lines
4.2 KiB
JavaScript
41 lines
4.2 KiB
JavaScript
'use strict';var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
|
|
|
|
function isNonExportStatement(_ref) {let type = _ref.type;
|
|
return type !== 'ExportDefaultDeclaration' &&
|
|
type !== 'ExportNamedDeclaration' &&
|
|
type !== 'ExportAllDeclaration';
|
|
}
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: 'suggestion',
|
|
docs: {
|
|
url: (0, _docsUrl2.default)('exports-last') },
|
|
|
|
schema: [] },
|
|
|
|
|
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9leHBvcnRzLWxhc3QuanMiXSwibmFtZXMiOlsiaXNOb25FeHBvcnRTdGF0ZW1lbnQiLCJ0eXBlIiwibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJkb2NzIiwidXJsIiwic2NoZW1hIiwiY3JlYXRlIiwiY29udGV4dCIsIlByb2dyYW0iLCJib2R5IiwibGFzdE5vbkV4cG9ydFN0YXRlbWVudEluZGV4IiwicmVkdWNlIiwiZmluZExhc3RJbmRleCIsImFj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