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",
"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",

6
package-lock.json generated
View File

@ -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",

View File

@ -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",

View File

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

View File

@ -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,
};

View File

@ -116,4 +116,4 @@ const ExpertSubsetCharset = [
"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 {
collectActions,
escapePDFName,
getLookupTableFactory,
getArrayLookupTableFactory,
MissingDataException,
XRefEntryException,
XRefParseException,
getInheritableProperty,
toRomanNumerals,
getLookupTableFactory,
isWhiteSpace,
log2,
MissingDataException,
parseXFAPath,
readInt8,
readUint16,
readUint32,
isWhiteSpace,
toRomanNumerals,
XRefEntryException,
XRefParseException,
};

View File

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

View File

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

View File

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

View File

@ -1345,6 +1345,6 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
export {
isPDFFunction,
PDFFunctionFactory,
PostScriptEvaluator,
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 {
LocalImageCache,
GlobalImageCache,
LocalColorSpaceCache,
LocalFunctionCache,
LocalGStateCache,
LocalImageCache,
LocalTilingPatternCache,
GlobalImageCache,
};

View File

@ -2602,4 +2602,4 @@ const ObjectLoader = (function () {
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 {
EOF,
clearPrimitiveCaches,
Cmd,
Dict,
Name,
Ref,
RefSet,
RefSetCache,
isEOF,
EOF,
isCmd,
isDict,
isEOF,
isName,
isRef,
isRefsEqual,
isStream,
Name,
Ref,
RefSet,
RefSetCache,
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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,
};

View File

@ -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,
};

View File

@ -166,4 +166,4 @@ class IPDFStreamRangeReader {
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
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
* limitations under the License.
*/
/* eslint-disable sort-exports/sort-exports */
import {
addLinkAttributes,

View File

@ -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,
};

View File

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

View File

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

View File

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

View File

@ -804,4 +804,4 @@ function isDestArraysEqual(firstDest, secondDest) {
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");
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,
};

View File

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

View File

@ -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,
};