Use ESLint to ensure that exports are sorted alphabetically

There's built-in ESLint rule, see `sort-imports`, to ensure that all `import`-statements are sorted alphabetically, since that often helps with readability.
Unfortunately there's no corresponding rule to sort `export`-statements alphabetically, however there's an ESLint plugin which does this; please see https://www.npmjs.com/package/eslint-plugin-sort-exports

The only downside here is that it's not automatically fixable, but the re-ordering is a one-time "cost" and the plugin will help maintain a *consistent* ordering of `export`-statements in the future.
*Note:* To reduce the possibility of introducing any errors here, the re-ordering was done by simply selecting the relevant lines and then using the built-in sort-functionality of my editor.
This commit is contained in:
Jonas Jenwald 2021-01-09 15:37:44 +01:00
parent 7f199e7017
commit 81525fd446
37 changed files with 178 additions and 166 deletions

View File

@ -8,6 +8,7 @@
"import", "import",
"mozilla", "mozilla",
"no-unsanitized", "no-unsanitized",
"sort-exports",
"unicorn", "unicorn",
], ],
@ -36,6 +37,9 @@
"mozilla/use-includes-instead-of-indexOf": "error", "mozilla/use-includes-instead-of-indexOf": "error",
"no-unsanitized/method": "error", "no-unsanitized/method": "error",
"no-unsanitized/property": "error", "no-unsanitized/property": "error",
"sort-exports/sort-exports": ["error", {
"ignoreCase": true,
}],
"unicorn/no-abusive-eslint-disable": "error", "unicorn/no-abusive-eslint-disable": "error",
"unicorn/no-array-instanceof": "error", "unicorn/no-array-instanceof": "error",
"unicorn/prefer-starts-ends-with": "error", "unicorn/prefer-starts-ends-with": "error",

6
package-lock.json generated
View File

@ -5235,6 +5235,12 @@
"prettier-linter-helpers": "^1.0.0" "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": { "eslint-plugin-unicorn": {
"version": "22.0.0", "version": "22.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-22.0.0.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-22.0.0.tgz",

View File

@ -24,6 +24,7 @@
"eslint-plugin-mozilla": "^2.9.1", "eslint-plugin-mozilla": "^2.9.1",
"eslint-plugin-no-unsanitized": "^3.1.4", "eslint-plugin-no-unsanitized": "^3.1.4",
"eslint-plugin-prettier": "^3.3.0", "eslint-plugin-prettier": "^3.3.0",
"eslint-plugin-sort-exports": "^0.3.2",
"eslint-plugin-unicorn": "^22.0.0", "eslint-plugin-unicorn": "^22.0.0",
"globals": "^13.5.0", "globals": "^13.5.0",
"gulp": "^4.0.2", "gulp": "^4.0.2",

View File

@ -2475,6 +2475,6 @@ export {
Annotation, Annotation,
AnnotationBorderStyle, AnnotationBorderStyle,
AnnotationFactory, AnnotationFactory,
MarkupAnnotation,
getQuadPoints, getQuadPoints,
MarkupAnnotation,
}; };

View File

@ -1913,15 +1913,15 @@ class CFFCompiler {
} }
export { export {
CFFStandardStrings,
CFFParser,
CFF, CFF,
CFFHeader,
CFFStrings,
CFFIndex,
CFFCharset, CFFCharset,
CFFTopDict,
CFFPrivateDict,
CFFCompiler, CFFCompiler,
CFFFDSelect, CFFFDSelect,
CFFHeader,
CFFIndex,
CFFParser,
CFFPrivateDict,
CFFStandardStrings,
CFFStrings,
CFFTopDict,
}; };

View File

@ -116,4 +116,4 @@ const ExpertSubsetCharset = [
"periodinferior", "commainferior" "periodinferior", "commainferior"
]; ];
export { ISOAdobeCharset, ExpertCharset, ExpertSubsetCharset }; export { ExpertCharset, ExpertSubsetCharset, ISOAdobeCharset };

View File

@ -1055,4 +1055,4 @@ var CMapFactory = (function CMapFactoryClosure() {
}; };
})(); })();
export { CMap, IdentityCMap, CMapFactory }; export { CMap, CMapFactory, IdentityCMap };

View File

@ -323,17 +323,17 @@ function collectActions(xref, dict, eventType) {
export { export {
collectActions, collectActions,
escapePDFName, escapePDFName,
getLookupTableFactory,
getArrayLookupTableFactory, getArrayLookupTableFactory,
MissingDataException,
XRefEntryException,
XRefParseException,
getInheritableProperty, getInheritableProperty,
toRomanNumerals, getLookupTableFactory,
isWhiteSpace,
log2, log2,
MissingDataException,
parseXFAPath, parseXFAPath,
readInt8, readInt8,
readUint16, readUint16,
readUint32, readUint32,
isWhiteSpace, toRomanNumerals,
XRefEntryException,
XRefParseException,
}; };

View File

@ -1956,11 +1956,11 @@ export {
AES128Cipher, AES128Cipher,
AES256Cipher, AES256Cipher,
ARCFourCipher, ARCFourCipher,
CipherTransformFactory,
PDF17,
PDF20,
calculateMD5, calculateMD5,
calculateSHA256, calculateSHA256,
calculateSHA384, calculateSHA384,
calculateSHA512, calculateSHA512,
CipherTransformFactory,
PDF17,
PDF20,
}; };

View File

@ -291,11 +291,11 @@ function getEncoding(encodingName) {
} }
export { export {
WinAnsiEncoding,
StandardEncoding,
MacRomanEncoding,
SymbolSetEncoding,
ZapfDingbatsEncoding,
ExpertEncoding, ExpertEncoding,
getEncoding, getEncoding,
MacRomanEncoding,
StandardEncoding,
SymbolSetEncoding,
WinAnsiEncoding,
ZapfDingbatsEncoding,
}; };

View File

@ -4013,11 +4013,11 @@ var CFFFont = (function CFFFontClosure() {
})(); })();
export { export {
SEAC_ANALYSIS_ENABLED,
ErrorFont, ErrorFont,
Font, Font,
FontFlags, FontFlags,
ToUnicodeMap,
IdentityToUnicodeMap,
getFontType, getFontType,
IdentityToUnicodeMap,
SEAC_ANALYSIS_ENABLED,
ToUnicodeMap,
}; };

View File

@ -1345,6 +1345,6 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
export { export {
isPDFFunction, isPDFFunction,
PDFFunctionFactory, PDFFunctionFactory,
PostScriptEvaluator,
PostScriptCompiler, PostScriptCompiler,
PostScriptEvaluator,
}; };

View File

@ -4556,4 +4556,4 @@ var getDingbatsGlyphsUnicode = getArrayLookupTableFactory(function () {
]; ];
}); });
export { getGlyphsUnicode, getDingbatsGlyphsUnicode }; export { getDingbatsGlyphsUnicode, getGlyphsUnicode };

View File

@ -250,10 +250,10 @@ class GlobalImageCache {
} }
export { export {
LocalImageCache, GlobalImageCache,
LocalColorSpaceCache, LocalColorSpaceCache,
LocalFunctionCache, LocalFunctionCache,
LocalGStateCache, LocalGStateCache,
LocalImageCache,
LocalTilingPatternCache, LocalTilingPatternCache,
GlobalImageCache,
}; };

View File

@ -2602,4 +2602,4 @@ const ObjectLoader = (function () {
return ObjectLoader; return ObjectLoader;
})(); })();
export { Catalog, ObjectLoader, XRef, FileSpec }; export { Catalog, FileSpec, ObjectLoader, XRef };

View File

@ -994,4 +994,4 @@ function getTilingPatternIR(operatorList, dict, color) {
]; ];
} }
export { Pattern, getTilingPatternIR }; export { getTilingPatternIR, Pattern };

View File

@ -394,19 +394,19 @@ function clearPrimitiveCaches() {
} }
export { export {
EOF,
clearPrimitiveCaches, clearPrimitiveCaches,
Cmd, Cmd,
Dict, Dict,
Name, EOF,
Ref,
RefSet,
RefSetCache,
isEOF,
isCmd, isCmd,
isDict, isDict,
isEOF,
isName, isName,
isRef, isRef,
isRefsEqual, isRefsEqual,
isStream, isStream,
Name,
Ref,
RefSet,
RefSetCache,
}; };

View File

@ -764,11 +764,11 @@ const getSupplementalGlyphMapForCalibri = getLookupTableFactory(function (t) {
}); });
export { export {
getStdFontMap, getGlyphMapForStandardFonts,
getNonStdFontMap, getNonStdFontMap,
getSerifFonts, getSerifFonts,
getSymbolsFonts, getStdFontMap,
getGlyphMapForStandardFonts,
getSupplementalGlyphMapForArialBlack, getSupplementalGlyphMapForArialBlack,
getSupplementalGlyphMapForCalibri, getSupplementalGlyphMapForCalibri,
getSymbolsFonts,
}; };

View File

@ -1341,14 +1341,14 @@ var NullStream = (function NullStreamClosure() {
export { export {
Ascii85Stream, Ascii85Stream,
AsciiHexStream, AsciiHexStream,
DecryptStream,
DecodeStream, DecodeStream,
DecryptStream,
FlateStream, FlateStream,
LZWStream,
NullStream, NullStream,
PredictorStream, PredictorStream,
RunLengthStream, RunLengthStream,
Stream, Stream,
StreamsSequenceStream, StreamsSequenceStream,
StringStream, StringStream,
LZWStream,
}; };

View File

@ -1642,9 +1642,9 @@ function reverseIfRtl(chars) {
} }
export { export {
mapSpecialUnicodeValues,
reverseIfRtl,
getUnicodeRangeFor,
getNormalizedUnicodes, getNormalizedUnicodes,
getUnicodeForGlyph, getUnicodeForGlyph,
getUnicodeRangeFor,
mapSpecialUnicodeValues,
reverseIfRtl,
}; };

View File

@ -804,4 +804,4 @@ if (
WorkerMessageHandler.initializeFromPort(self); WorkerMessageHandler.initializeFromPort(self);
} }
export { WorkerTask, WorkerMessageHandler }; export { WorkerMessageHandler, WorkerTask };

View File

@ -273,4 +273,4 @@ function incrementalUpdate({
return array; return array;
} }
export { writeDict, incrementalUpdate }; export { incrementalUpdate, writeDict };

View File

@ -3051,15 +3051,15 @@ const build =
typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : null; typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : null;
export { export {
getDocument,
LoopbackPort,
PDFDataRangeTransport,
PDFWorker,
PDFDocumentProxy,
PDFPageProxy,
setPDFNetworkStreamFactory,
version,
build, build,
DefaultCanvasFactory, DefaultCanvasFactory,
DefaultCMapReaderFactory, DefaultCMapReaderFactory,
getDocument,
LoopbackPort,
PDFDataRangeTransport,
PDFDocumentProxy,
PDFPageProxy,
PDFWorker,
setPDFNetworkStreamFactory,
version,
}; };

View File

@ -642,21 +642,21 @@ class PDFDateString {
} }
export { export {
PageViewport,
RenderingCancelledException,
addLinkAttributes, addLinkAttributes,
getFilenameFromUrl,
LinkTarget,
DEFAULT_LINK_REL,
BaseCanvasFactory, BaseCanvasFactory,
DOMCanvasFactory,
BaseCMapReaderFactory, BaseCMapReaderFactory,
DEFAULT_LINK_REL,
deprecated,
DOMCanvasFactory,
DOMCMapReaderFactory, DOMCMapReaderFactory,
DOMSVGFactory, DOMSVGFactory,
StatTimer, getFilenameFromUrl,
isFetchSupported, isFetchSupported,
isValidFetchUrl, isValidFetchUrl,
LinkTarget,
loadScript, loadScript,
deprecated, PageViewport,
PDFDateString, PDFDateString,
RenderingCancelledException,
StatTimer,
}; };

View File

@ -166,4 +166,4 @@ class IPDFStreamRangeReader {
cancel(reason) {} cancel(reason) {}
} }
export { IPDFStream, IPDFStreamReader, IPDFStreamRangeReader }; export { IPDFStream, IPDFStreamRangeReader, IPDFStreamReader };

View File

@ -37,4 +37,4 @@ const pdfjsVersion = PDFJSDev.eval("BUNDLE_VERSION");
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const pdfjsBuild = PDFJSDev.eval("BUNDLE_BUILD"); const pdfjsBuild = PDFJSDev.eval("BUNDLE_BUILD");
export { Jbig2mage, JpegImage, JpxImage, getVerbosityLevel, setVerbosityLevel }; export { getVerbosityLevel, Jbig2mage, JpegImage, JpxImage, setVerbosityLevel };

View File

@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable sort-exports/sort-exports */
import { import {
addLinkAttributes, addLinkAttributes,

View File

@ -1015,12 +1015,7 @@ function encodeToXmlString(str) {
} }
export { export {
BaseException, AbortException,
FONT_IDENTITY_MATRIX,
IDENTITY_MATRIX,
OPS,
VerbosityLevel,
UNSUPPORTED_FEATURES,
AnnotationActionEventType, AnnotationActionEventType,
AnnotationBorderStyleType, AnnotationBorderStyleType,
AnnotationFieldFlag, AnnotationFieldFlag,
@ -1030,55 +1025,60 @@ export {
AnnotationReviewState, AnnotationReviewState,
AnnotationStateModelType, AnnotationStateModelType,
AnnotationType, AnnotationType,
FontType, arrayByteLength,
ImageKind, arraysToBytes,
assert,
BaseException,
bytesToString,
CMapCompressionType, CMapCompressionType,
createObjectURL,
createPromiseCapability,
createValidAbsoluteUrl,
DocumentActionEventType, DocumentActionEventType,
AbortException, encodeToXmlString,
escapeString,
FONT_IDENTITY_MATRIX,
FontType,
FormatError,
getModificationDate,
getVerbosityLevel,
IDENTITY_MATRIX,
ImageKind,
info,
InvalidPDFException, InvalidPDFException,
isArrayBuffer,
isArrayEqual,
isAscii,
isBool,
IsEvalSupportedCached,
IsLittleEndianCached,
isNum,
isSameOrigin,
isString,
MissingPDFException, MissingPDFException,
objectFromEntries,
objectSize,
OPS,
PageActionEventType, PageActionEventType,
PasswordException, PasswordException,
PasswordResponses, PasswordResponses,
PermissionFlag, 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, removeNullCharacters,
setVerbosityLevel, setVerbosityLevel,
shadow, shadow,
StreamType,
string32, string32,
stringToBytes, stringToBytes,
stringToPDFString, stringToPDFString,
stringToUTF16BEString, stringToUTF16BEString,
stringToUTF8String, stringToUTF8String,
utf8StringToString, TextRenderingMode,
warn, UnexpectedResponseException,
UnknownErrorException,
unreachable, unreachable,
UNSUPPORTED_FEATURES,
utf8StringToString,
Util,
VerbosityLevel,
warn,
}; };

View File

@ -141,11 +141,11 @@ function isEmptyObj(obj) {
} }
export { export {
DefaultFileReaderFactory,
XRefMock,
buildGetDocumentParams, buildGetDocumentParams,
TEST_PDFS_PATH,
CMAP_PARAMS, CMAP_PARAMS,
createIdFactory, createIdFactory,
DefaultFileReaderFactory,
isEmptyObj, isEmptyObj,
TEST_PDFS_PATH,
XRefMock,
}; };

View File

@ -3480,7 +3480,7 @@ const PDFPrintServiceFactory = {
}; };
export { export {
PDFViewerApplication,
DefaultExternalServices, DefaultExternalServices,
PDFPrintServiceFactory, PDFPrintServiceFactory,
PDFViewerApplication,
}; };

View File

@ -238,10 +238,10 @@ class IL10n {
} }
export { export {
IPDFLinkService,
IPDFHistory,
IRenderableView,
IPDFTextLayerFactory,
IPDFAnnotationLayerFactory,
IL10n, IL10n,
IPDFAnnotationLayerFactory,
IPDFHistory,
IPDFLinkService,
IPDFTextLayerFactory,
IRenderableView,
}; };

View File

@ -804,4 +804,4 @@ function isDestArraysEqual(firstDest, secondDest) {
return true; return true;
} }
export { PDFHistory, isDestHashesEqual, isDestArraysEqual }; export { isDestArraysEqual, isDestHashesEqual, PDFHistory };

View File

@ -183,4 +183,4 @@ class PDFRenderingQueue {
} }
} }
export { RenderingStates, PDFRenderingQueue }; export { PDFRenderingQueue, RenderingStates };

View File

@ -517,4 +517,4 @@ class PDFSidebar {
} }
} }
export { SidebarView, PDFSidebar }; export { PDFSidebar };

View File

@ -37,20 +37,20 @@ const pdfjsVersion = PDFJSDev.eval("BUNDLE_VERSION");
const pdfjsBuild = PDFJSDev.eval("BUNDLE_BUILD"); const pdfjsBuild = PDFJSDev.eval("BUNDLE_BUILD");
export { export {
PDFViewer,
PDFSinglePageViewer,
PDFPageView,
PDFLinkService,
SimpleLinkService,
TextLayerBuilder,
DefaultTextLayerFactory,
AnnotationLayerBuilder, AnnotationLayerBuilder,
DefaultAnnotationLayerFactory, DefaultAnnotationLayerFactory,
PDFHistory, DefaultTextLayerFactory,
PDFFindController,
EventBus,
DownloadManager, DownloadManager,
ProgressBar, EventBus,
GenericL10n, GenericL10n,
NullL10n, NullL10n,
PDFFindController,
PDFHistory,
PDFLinkService,
PDFPageView,
PDFSinglePageViewer,
PDFViewer,
ProgressBar,
SimpleLinkService,
TextLayerBuilder,
}; };

View File

@ -463,4 +463,4 @@ class DefaultTextLayerFactory {
} }
} }
export { TextLayerBuilder, DefaultTextLayerFactory }; export { DefaultTextLayerFactory, TextLayerBuilder };

View File

@ -1031,46 +1031,46 @@ function getActiveOrFocusedElement() {
} }
export { export {
animationStarted,
approximateFraction,
AutoPrintRegExp, AutoPrintRegExp,
backtrackBeforeAllVisibleElements, // only exported for testing
binarySearchFirstItem,
CSS_UNITS, CSS_UNITS,
DEFAULT_SCALE_VALUE,
DEFAULT_SCALE, DEFAULT_SCALE,
MIN_SCALE, DEFAULT_SCALE_VALUE,
MAX_SCALE, EventBus,
UNKNOWN_SCALE, getActiveOrFocusedElement,
MAX_AUTO_SCALE, getOutputScale,
SCROLLBAR_PADDING, getPageSizeInches,
VERTICAL_PADDING, getPDFFileNameFromURL,
getVisibleElements,
isPortraitOrientation,
isValidRotation, isValidRotation,
isValidScrollMode, isValidScrollMode,
isValidSpreadMode, isValidSpreadMode,
isPortraitOrientation, MAX_AUTO_SCALE,
PresentationModeState, MAX_SCALE,
SidebarView, MIN_SCALE,
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,
moveToEndOfArray, 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,
}; };