diff --git a/.eslintrc b/.eslintrc index 7ad4fa257..e848393ca 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,6 +8,7 @@ "import", "mozilla", "no-unsanitized", + "sort-exports", "unicorn", ], @@ -36,6 +37,9 @@ "mozilla/use-includes-instead-of-indexOf": "error", "no-unsanitized/method": "error", "no-unsanitized/property": "error", + "sort-exports/sort-exports": ["error", { + "ignoreCase": true, + }], "unicorn/no-abusive-eslint-disable": "error", "unicorn/no-array-instanceof": "error", "unicorn/prefer-starts-ends-with": "error", diff --git a/package-lock.json b/package-lock.json index 0969bfcb6..fd5ded00d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5235,6 +5235,12 @@ "prettier-linter-helpers": "^1.0.0" } }, + "eslint-plugin-sort-exports": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-sort-exports/-/eslint-plugin-sort-exports-0.3.2.tgz", + "integrity": "sha512-9wx4oHU3M/jFbqhRtR6vcmcbKoNj++1bnSMjLmNCNza+nWpCjo3o5gFIUmTFxr4JBOD1QL9ONR8EE9T9Rf1COQ==", + "dev": true + }, "eslint-plugin-unicorn": { "version": "22.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-22.0.0.tgz", diff --git a/package.json b/package.json index 557298605..dde8ab819 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "eslint-plugin-mozilla": "^2.9.1", "eslint-plugin-no-unsanitized": "^3.1.4", "eslint-plugin-prettier": "^3.3.0", + "eslint-plugin-sort-exports": "^0.3.2", "eslint-plugin-unicorn": "^22.0.0", "globals": "^13.5.0", "gulp": "^4.0.2", diff --git a/src/core/annotation.js b/src/core/annotation.js index ccdae6f69..0c2280b49 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -2475,6 +2475,6 @@ export { Annotation, AnnotationBorderStyle, AnnotationFactory, - MarkupAnnotation, getQuadPoints, + MarkupAnnotation, }; diff --git a/src/core/cff_parser.js b/src/core/cff_parser.js index d4b67901b..ffac9acdf 100644 --- a/src/core/cff_parser.js +++ b/src/core/cff_parser.js @@ -1913,15 +1913,15 @@ class CFFCompiler { } export { - CFFStandardStrings, - CFFParser, CFF, - CFFHeader, - CFFStrings, - CFFIndex, CFFCharset, - CFFTopDict, - CFFPrivateDict, CFFCompiler, CFFFDSelect, + CFFHeader, + CFFIndex, + CFFParser, + CFFPrivateDict, + CFFStandardStrings, + CFFStrings, + CFFTopDict, }; diff --git a/src/core/charsets.js b/src/core/charsets.js index 62c135f93..504edfc5c 100644 --- a/src/core/charsets.js +++ b/src/core/charsets.js @@ -116,4 +116,4 @@ const ExpertSubsetCharset = [ "periodinferior", "commainferior" ]; -export { ISOAdobeCharset, ExpertCharset, ExpertSubsetCharset }; +export { ExpertCharset, ExpertSubsetCharset, ISOAdobeCharset }; diff --git a/src/core/cmap.js b/src/core/cmap.js index 54c247777..a6abeaab5 100644 --- a/src/core/cmap.js +++ b/src/core/cmap.js @@ -1055,4 +1055,4 @@ var CMapFactory = (function CMapFactoryClosure() { }; })(); -export { CMap, IdentityCMap, CMapFactory }; +export { CMap, CMapFactory, IdentityCMap }; diff --git a/src/core/core_utils.js b/src/core/core_utils.js index d9f8c050a..2fb2d792e 100644 --- a/src/core/core_utils.js +++ b/src/core/core_utils.js @@ -323,17 +323,17 @@ function collectActions(xref, dict, eventType) { export { collectActions, escapePDFName, - getLookupTableFactory, getArrayLookupTableFactory, - MissingDataException, - XRefEntryException, - XRefParseException, getInheritableProperty, - toRomanNumerals, + getLookupTableFactory, + isWhiteSpace, log2, + MissingDataException, parseXFAPath, readInt8, readUint16, readUint32, - isWhiteSpace, + toRomanNumerals, + XRefEntryException, + XRefParseException, }; diff --git a/src/core/crypto.js b/src/core/crypto.js index 46d7682ca..45d439a2e 100644 --- a/src/core/crypto.js +++ b/src/core/crypto.js @@ -1956,11 +1956,11 @@ export { AES128Cipher, AES256Cipher, ARCFourCipher, - CipherTransformFactory, - PDF17, - PDF20, calculateMD5, calculateSHA256, calculateSHA384, calculateSHA512, + CipherTransformFactory, + PDF17, + PDF20, }; diff --git a/src/core/encodings.js b/src/core/encodings.js index 98dc8e868..8ebbd7be4 100644 --- a/src/core/encodings.js +++ b/src/core/encodings.js @@ -291,11 +291,11 @@ function getEncoding(encodingName) { } export { - WinAnsiEncoding, - StandardEncoding, - MacRomanEncoding, - SymbolSetEncoding, - ZapfDingbatsEncoding, ExpertEncoding, getEncoding, + MacRomanEncoding, + StandardEncoding, + SymbolSetEncoding, + WinAnsiEncoding, + ZapfDingbatsEncoding, }; diff --git a/src/core/fonts.js b/src/core/fonts.js index cc3bfce70..d3cfc11aa 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -4013,11 +4013,11 @@ var CFFFont = (function CFFFontClosure() { })(); export { - SEAC_ANALYSIS_ENABLED, ErrorFont, Font, FontFlags, - ToUnicodeMap, - IdentityToUnicodeMap, getFontType, + IdentityToUnicodeMap, + SEAC_ANALYSIS_ENABLED, + ToUnicodeMap, }; diff --git a/src/core/function.js b/src/core/function.js index 3e00cadb9..7f2b8d1da 100644 --- a/src/core/function.js +++ b/src/core/function.js @@ -1345,6 +1345,6 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() { export { isPDFFunction, PDFFunctionFactory, - PostScriptEvaluator, PostScriptCompiler, + PostScriptEvaluator, }; diff --git a/src/core/glyphlist.js b/src/core/glyphlist.js index e8fa34c6c..63785136f 100644 --- a/src/core/glyphlist.js +++ b/src/core/glyphlist.js @@ -4556,4 +4556,4 @@ var getDingbatsGlyphsUnicode = getArrayLookupTableFactory(function () { ]; }); -export { getGlyphsUnicode, getDingbatsGlyphsUnicode }; +export { getDingbatsGlyphsUnicode, getGlyphsUnicode }; diff --git a/src/core/image_utils.js b/src/core/image_utils.js index 6cb485f45..20878e621 100644 --- a/src/core/image_utils.js +++ b/src/core/image_utils.js @@ -250,10 +250,10 @@ class GlobalImageCache { } export { - LocalImageCache, + GlobalImageCache, LocalColorSpaceCache, LocalFunctionCache, LocalGStateCache, + LocalImageCache, LocalTilingPatternCache, - GlobalImageCache, }; diff --git a/src/core/obj.js b/src/core/obj.js index 9bb792501..4061bb076 100644 --- a/src/core/obj.js +++ b/src/core/obj.js @@ -2602,4 +2602,4 @@ const ObjectLoader = (function () { return ObjectLoader; })(); -export { Catalog, ObjectLoader, XRef, FileSpec }; +export { Catalog, FileSpec, ObjectLoader, XRef }; diff --git a/src/core/pattern.js b/src/core/pattern.js index 0a6e50d41..9e1a6fb75 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -994,4 +994,4 @@ function getTilingPatternIR(operatorList, dict, color) { ]; } -export { Pattern, getTilingPatternIR }; +export { getTilingPatternIR, Pattern }; diff --git a/src/core/primitives.js b/src/core/primitives.js index 96a9c36e0..fece2d707 100644 --- a/src/core/primitives.js +++ b/src/core/primitives.js @@ -394,19 +394,19 @@ function clearPrimitiveCaches() { } export { - EOF, clearPrimitiveCaches, Cmd, Dict, - Name, - Ref, - RefSet, - RefSetCache, - isEOF, + EOF, isCmd, isDict, + isEOF, isName, isRef, isRefsEqual, isStream, + Name, + Ref, + RefSet, + RefSetCache, }; diff --git a/src/core/standard_fonts.js b/src/core/standard_fonts.js index 1bf7b53ef..65892dd14 100644 --- a/src/core/standard_fonts.js +++ b/src/core/standard_fonts.js @@ -764,11 +764,11 @@ const getSupplementalGlyphMapForCalibri = getLookupTableFactory(function (t) { }); export { - getStdFontMap, + getGlyphMapForStandardFonts, getNonStdFontMap, getSerifFonts, - getSymbolsFonts, - getGlyphMapForStandardFonts, + getStdFontMap, getSupplementalGlyphMapForArialBlack, getSupplementalGlyphMapForCalibri, + getSymbolsFonts, }; diff --git a/src/core/stream.js b/src/core/stream.js index 9e84fcc94..c225bfe8b 100644 --- a/src/core/stream.js +++ b/src/core/stream.js @@ -1341,14 +1341,14 @@ var NullStream = (function NullStreamClosure() { export { Ascii85Stream, AsciiHexStream, - DecryptStream, DecodeStream, + DecryptStream, FlateStream, + LZWStream, NullStream, PredictorStream, RunLengthStream, Stream, StreamsSequenceStream, StringStream, - LZWStream, }; diff --git a/src/core/unicode.js b/src/core/unicode.js index d053de900..0e9aa8099 100644 --- a/src/core/unicode.js +++ b/src/core/unicode.js @@ -1642,9 +1642,9 @@ function reverseIfRtl(chars) { } export { - mapSpecialUnicodeValues, - reverseIfRtl, - getUnicodeRangeFor, getNormalizedUnicodes, getUnicodeForGlyph, + getUnicodeRangeFor, + mapSpecialUnicodeValues, + reverseIfRtl, }; diff --git a/src/core/worker.js b/src/core/worker.js index 9c8241f70..454c8539a 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -804,4 +804,4 @@ if ( WorkerMessageHandler.initializeFromPort(self); } -export { WorkerTask, WorkerMessageHandler }; +export { WorkerMessageHandler, WorkerTask }; diff --git a/src/core/writer.js b/src/core/writer.js index 16c58fe97..51816f13e 100644 --- a/src/core/writer.js +++ b/src/core/writer.js @@ -273,4 +273,4 @@ function incrementalUpdate({ return array; } -export { writeDict, incrementalUpdate }; +export { incrementalUpdate, writeDict }; diff --git a/src/display/api.js b/src/display/api.js index 9bb3c6e52..1a291ae8e 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -3051,15 +3051,15 @@ const build = typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : null; export { - getDocument, - LoopbackPort, - PDFDataRangeTransport, - PDFWorker, - PDFDocumentProxy, - PDFPageProxy, - setPDFNetworkStreamFactory, - version, build, DefaultCanvasFactory, DefaultCMapReaderFactory, + getDocument, + LoopbackPort, + PDFDataRangeTransport, + PDFDocumentProxy, + PDFPageProxy, + PDFWorker, + setPDFNetworkStreamFactory, + version, }; diff --git a/src/display/display_utils.js b/src/display/display_utils.js index 0c3fd6158..58ff3de3f 100644 --- a/src/display/display_utils.js +++ b/src/display/display_utils.js @@ -642,21 +642,21 @@ class PDFDateString { } export { - PageViewport, - RenderingCancelledException, addLinkAttributes, - getFilenameFromUrl, - LinkTarget, - DEFAULT_LINK_REL, BaseCanvasFactory, - DOMCanvasFactory, BaseCMapReaderFactory, + DEFAULT_LINK_REL, + deprecated, + DOMCanvasFactory, DOMCMapReaderFactory, DOMSVGFactory, - StatTimer, + getFilenameFromUrl, isFetchSupported, isValidFetchUrl, + LinkTarget, loadScript, - deprecated, + PageViewport, PDFDateString, + RenderingCancelledException, + StatTimer, }; diff --git a/src/interfaces.js b/src/interfaces.js index ddcea10bc..e0ecb5474 100644 --- a/src/interfaces.js +++ b/src/interfaces.js @@ -166,4 +166,4 @@ class IPDFStreamRangeReader { cancel(reason) {} } -export { IPDFStream, IPDFStreamReader, IPDFStreamRangeReader }; +export { IPDFStream, IPDFStreamRangeReader, IPDFStreamReader }; diff --git a/src/pdf.image_decoders.js b/src/pdf.image_decoders.js index 5b38ad936..9cd62c235 100644 --- a/src/pdf.image_decoders.js +++ b/src/pdf.image_decoders.js @@ -37,4 +37,4 @@ const pdfjsVersion = PDFJSDev.eval("BUNDLE_VERSION"); // eslint-disable-next-line no-unused-vars const pdfjsBuild = PDFJSDev.eval("BUNDLE_BUILD"); -export { Jbig2mage, JpegImage, JpxImage, getVerbosityLevel, setVerbosityLevel }; +export { getVerbosityLevel, Jbig2mage, JpegImage, JpxImage, setVerbosityLevel }; diff --git a/src/pdf.js b/src/pdf.js index c6a6d1338..51bf5d87d 100644 --- a/src/pdf.js +++ b/src/pdf.js @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable sort-exports/sort-exports */ import { addLinkAttributes, diff --git a/src/shared/util.js b/src/shared/util.js index fc7ef9544..66f0e502e 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -1015,12 +1015,7 @@ function encodeToXmlString(str) { } export { - BaseException, - FONT_IDENTITY_MATRIX, - IDENTITY_MATRIX, - OPS, - VerbosityLevel, - UNSUPPORTED_FEATURES, + AbortException, AnnotationActionEventType, AnnotationBorderStyleType, AnnotationFieldFlag, @@ -1030,55 +1025,60 @@ export { AnnotationReviewState, AnnotationStateModelType, AnnotationType, - FontType, - ImageKind, + arrayByteLength, + arraysToBytes, + assert, + BaseException, + bytesToString, CMapCompressionType, + createObjectURL, + createPromiseCapability, + createValidAbsoluteUrl, DocumentActionEventType, - AbortException, + encodeToXmlString, + escapeString, + FONT_IDENTITY_MATRIX, + FontType, + FormatError, + getModificationDate, + getVerbosityLevel, + IDENTITY_MATRIX, + ImageKind, + info, InvalidPDFException, + isArrayBuffer, + isArrayEqual, + isAscii, + isBool, + IsEvalSupportedCached, + IsLittleEndianCached, + isNum, + isSameOrigin, + isString, MissingPDFException, + objectFromEntries, + objectSize, + OPS, PageActionEventType, PasswordException, PasswordResponses, PermissionFlag, - StreamType, - TextRenderingMode, - UnexpectedResponseException, - UnknownErrorException, - Util, - FormatError, - arrayByteLength, - arraysToBytes, - assert, - bytesToString, - createPromiseCapability, - createObjectURL, - escapeString, - encodeToXmlString, - getModificationDate, - getVerbosityLevel, - info, - isAscii, - isArrayBuffer, - isArrayEqual, - isBool, - isNum, - isString, - isSameOrigin, - createValidAbsoluteUrl, - objectSize, - objectFromEntries, - IsLittleEndianCached, - IsEvalSupportedCached, removeNullCharacters, setVerbosityLevel, shadow, + StreamType, string32, stringToBytes, stringToPDFString, stringToUTF16BEString, stringToUTF8String, - utf8StringToString, - warn, + TextRenderingMode, + UnexpectedResponseException, + UnknownErrorException, unreachable, + UNSUPPORTED_FEATURES, + utf8StringToString, + Util, + VerbosityLevel, + warn, }; diff --git a/test/unit/test_utils.js b/test/unit/test_utils.js index 50b6c1428..6ee980520 100644 --- a/test/unit/test_utils.js +++ b/test/unit/test_utils.js @@ -141,11 +141,11 @@ function isEmptyObj(obj) { } export { - DefaultFileReaderFactory, - XRefMock, buildGetDocumentParams, - TEST_PDFS_PATH, CMAP_PARAMS, createIdFactory, + DefaultFileReaderFactory, isEmptyObj, + TEST_PDFS_PATH, + XRefMock, }; diff --git a/web/app.js b/web/app.js index bc28beda9..7120fb35f 100644 --- a/web/app.js +++ b/web/app.js @@ -3480,7 +3480,7 @@ const PDFPrintServiceFactory = { }; export { - PDFViewerApplication, DefaultExternalServices, PDFPrintServiceFactory, + PDFViewerApplication, }; diff --git a/web/interfaces.js b/web/interfaces.js index 2ab22a6d2..6e3ce2afb 100644 --- a/web/interfaces.js +++ b/web/interfaces.js @@ -238,10 +238,10 @@ class IL10n { } export { - IPDFLinkService, - IPDFHistory, - IRenderableView, - IPDFTextLayerFactory, - IPDFAnnotationLayerFactory, IL10n, + IPDFAnnotationLayerFactory, + IPDFHistory, + IPDFLinkService, + IPDFTextLayerFactory, + IRenderableView, }; diff --git a/web/pdf_history.js b/web/pdf_history.js index c45693e14..67860bf3f 100644 --- a/web/pdf_history.js +++ b/web/pdf_history.js @@ -804,4 +804,4 @@ function isDestArraysEqual(firstDest, secondDest) { return true; } -export { PDFHistory, isDestHashesEqual, isDestArraysEqual }; +export { isDestArraysEqual, isDestHashesEqual, PDFHistory }; diff --git a/web/pdf_rendering_queue.js b/web/pdf_rendering_queue.js index 64b377dd2..20f91f30e 100644 --- a/web/pdf_rendering_queue.js +++ b/web/pdf_rendering_queue.js @@ -183,4 +183,4 @@ class PDFRenderingQueue { } } -export { RenderingStates, PDFRenderingQueue }; +export { PDFRenderingQueue, RenderingStates }; diff --git a/web/pdf_sidebar.js b/web/pdf_sidebar.js index 37242c6e5..94679aa4d 100644 --- a/web/pdf_sidebar.js +++ b/web/pdf_sidebar.js @@ -517,4 +517,4 @@ class PDFSidebar { } } -export { SidebarView, PDFSidebar }; +export { PDFSidebar }; diff --git a/web/pdf_viewer.component.js b/web/pdf_viewer.component.js index a73d85fdb..38d944f15 100644 --- a/web/pdf_viewer.component.js +++ b/web/pdf_viewer.component.js @@ -37,20 +37,20 @@ const pdfjsVersion = PDFJSDev.eval("BUNDLE_VERSION"); const pdfjsBuild = PDFJSDev.eval("BUNDLE_BUILD"); export { - PDFViewer, - PDFSinglePageViewer, - PDFPageView, - PDFLinkService, - SimpleLinkService, - TextLayerBuilder, - DefaultTextLayerFactory, AnnotationLayerBuilder, DefaultAnnotationLayerFactory, - PDFHistory, - PDFFindController, - EventBus, + DefaultTextLayerFactory, DownloadManager, - ProgressBar, + EventBus, GenericL10n, NullL10n, + PDFFindController, + PDFHistory, + PDFLinkService, + PDFPageView, + PDFSinglePageViewer, + PDFViewer, + ProgressBar, + SimpleLinkService, + TextLayerBuilder, }; diff --git a/web/text_layer_builder.js b/web/text_layer_builder.js index 763de86dd..183241b60 100644 --- a/web/text_layer_builder.js +++ b/web/text_layer_builder.js @@ -463,4 +463,4 @@ class DefaultTextLayerFactory { } } -export { TextLayerBuilder, DefaultTextLayerFactory }; +export { DefaultTextLayerFactory, TextLayerBuilder }; diff --git a/web/ui_utils.js b/web/ui_utils.js index 4749af811..d678b19d2 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -1031,46 +1031,46 @@ function getActiveOrFocusedElement() { } export { + animationStarted, + approximateFraction, AutoPrintRegExp, + backtrackBeforeAllVisibleElements, // only exported for testing + binarySearchFirstItem, CSS_UNITS, - DEFAULT_SCALE_VALUE, DEFAULT_SCALE, - MIN_SCALE, - MAX_SCALE, - UNKNOWN_SCALE, - MAX_AUTO_SCALE, - SCROLLBAR_PADDING, - VERTICAL_PADDING, + DEFAULT_SCALE_VALUE, + EventBus, + getActiveOrFocusedElement, + getOutputScale, + getPageSizeInches, + getPDFFileNameFromURL, + getVisibleElements, + isPortraitOrientation, isValidRotation, isValidScrollMode, isValidSpreadMode, - isPortraitOrientation, - PresentationModeState, - SidebarView, - RendererType, - TextLayerMode, - ScrollMode, - SpreadMode, - NullL10n, - EventBus, - ProgressBar, - getPDFFileNameFromURL, - noContextMenuHandler, - parseQueryString, - backtrackBeforeAllVisibleElements, // only exported for testing - getVisibleElements, - roundToDivide, - getPageSizeInches, - approximateFraction, - getOutputScale, - scrollIntoView, - watchScroll, - binarySearchFirstItem, - normalizeWheelEventDirection, - normalizeWheelEventDelta, - animationStarted, - WaitOnType, - waitOnEventOrTimeout, + MAX_AUTO_SCALE, + MAX_SCALE, + MIN_SCALE, moveToEndOfArray, - getActiveOrFocusedElement, + noContextMenuHandler, + normalizeWheelEventDelta, + normalizeWheelEventDirection, + NullL10n, + parseQueryString, + PresentationModeState, + ProgressBar, + RendererType, + roundToDivide, + SCROLLBAR_PADDING, + scrollIntoView, + ScrollMode, + SidebarView, + SpreadMode, + TextLayerMode, + UNKNOWN_SCALE, + VERTICAL_PADDING, + waitOnEventOrTimeout, + WaitOnType, + watchScroll, };