mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-12-02 04:15:23 +01:00
41 lines
No EOL
4.5 KiB
JavaScript
41 lines
No EOL
4.5 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) {var 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 () {function create(context) {
|
|
return {
|
|
Program: function () {function Program(_ref2) {var body = _ref2.body;
|
|
var lastNonExportStatementIndex = body.reduce(function () {function findLastIndex(acc, item, index) {
|
|
if (isNonExportStatement(item)) {
|
|
return index;
|
|
}
|
|
return acc;
|
|
}return findLastIndex;}(), -1);
|
|
|
|
if (lastNonExportStatementIndex !== -1) {
|
|
body.slice(0, lastNonExportStatementIndex).forEach(function () {function checkNonExport(node) {
|
|
if (!isNonExportStatement(node)) {
|
|
context.report({
|
|
node: node,
|
|
message: 'Export statements should appear at the end of the file' });
|
|
|
|
}
|
|
}return checkNonExport;}());
|
|
}
|
|
}return Program;}() };
|
|
|
|
}return create;}() };
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9leHBvcnRzLWxhc3QuanMiXSwibmFtZXMiOlsiaXNOb25FeHBvcnRTdGF0ZW1lbnQiLCJ0eXBlIiwibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJkb2NzIiwidXJsIiwic2NoZW1hIiwiY3JlYXRlIiwiY29udGV4dCIsIlByb2dyYW0iLCJib2R5IiwibGFzdE5v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