UNPKG

monk-import-export

Version:

Simple import & export sorting ESLint plugin

33 lines (32 loc) 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.exportsRule = void 0; const isPartOfChunk_1 = require("./utils/isPartOfChunk"); const maybeReportChunkSorting_1 = require("./utils/maybeReportChunkSorting"); const maybeReportExportSpecifierSorting_1 = require("./utils/maybeReportExportSpecifierSorting"); const shared_1 = require("../../utils/shared"); const meta = { docs: { url: 'https://github.com/lydell/eslint-plugin-simple-import-sort#sort-order' }, fixable: 'code', messages: { sort: 'Run autofix to sort these exports!' }, schema: [], type: 'layout' }; const Program = (programNode, context) => { const sourceCode = context.getSourceCode(); for (const chunk of (0, shared_1.extractChunks)(programNode, (node, lastNode) => (0, isPartOfChunk_1.isPartOfChunk)(node, lastNode, sourceCode))) { (0, maybeReportChunkSorting_1.maybeReportChunkSorting)(chunk, context); } }; const ExportNamedDeclaration = (node, context) => { if (node.source == null && node.declaration == null) { (0, maybeReportExportSpecifierSorting_1.maybeReportExportSpecifierSorting)(node, context); } }; exports.exportsRule = { meta, create: (context) => ({ Program: (programNode) => Program(programNode, context), ExportNamedDeclaration: (node) => ExportNamedDeclaration(node, context) }) };