Skip to content

Commit

Permalink
Use ESLint to ensure that exports are sorted alphabetically
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Snuffleupagus committed Jan 9, 2021
1 parent 7f199e7 commit 81525fd
Show file tree
Hide file tree
Showing 37 changed files with 160 additions and 148 deletions.
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"import",
"mozilla",
"no-unsanitized",
"sort-exports",
"unicorn",
],

Expand Down Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2475,6 +2475,6 @@ export {
Annotation,
AnnotationBorderStyle,
AnnotationFactory,
MarkupAnnotation,
getQuadPoints,
MarkupAnnotation,
};
14 changes: 7 additions & 7 deletions src/core/cff_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
2 changes: 1 addition & 1 deletion src/core/charsets.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ const ExpertSubsetCharset = [
"periodinferior", "commainferior"
];

export { ISOAdobeCharset, ExpertCharset, ExpertSubsetCharset };
export { ExpertCharset, ExpertSubsetCharset, ISOAdobeCharset };
2 changes: 1 addition & 1 deletion src/core/cmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1055,4 +1055,4 @@ var CMapFactory = (function CMapFactoryClosure() {
};
})();

export { CMap, IdentityCMap, CMapFactory };
export { CMap, CMapFactory, IdentityCMap };
12 changes: 6 additions & 6 deletions src/core/core_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
6 changes: 3 additions & 3 deletions src/core/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -1956,11 +1956,11 @@ export {
AES128Cipher,
AES256Cipher,
ARCFourCipher,
CipherTransformFactory,
PDF17,
PDF20,
calculateMD5,
calculateSHA256,
calculateSHA384,
calculateSHA512,
CipherTransformFactory,
PDF17,
PDF20,
};
8 changes: 4 additions & 4 deletions src/core/encodings.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ function getEncoding(encodingName) {
}

export {
WinAnsiEncoding,
StandardEncoding,
ExpertEncoding,
getEncoding,
MacRomanEncoding,
StandardEncoding,
SymbolSetEncoding,
WinAnsiEncoding,
ZapfDingbatsEncoding,
ExpertEncoding,
getEncoding,
};
6 changes: 3 additions & 3 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4013,11 +4013,11 @@ var CFFFont = (function CFFFontClosure() {
})();

export {
SEAC_ANALYSIS_ENABLED,
ErrorFont,
Font,
FontFlags,
ToUnicodeMap,
IdentityToUnicodeMap,
getFontType,
IdentityToUnicodeMap,
SEAC_ANALYSIS_ENABLED,
ToUnicodeMap,
};
2 changes: 1 addition & 1 deletion src/core/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,6 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
export {
isPDFFunction,
PDFFunctionFactory,
PostScriptEvaluator,
PostScriptCompiler,
PostScriptEvaluator,
};
2 changes: 1 addition & 1 deletion src/core/glyphlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -4556,4 +4556,4 @@ var getDingbatsGlyphsUnicode = getArrayLookupTableFactory(function () {
];
});

export { getGlyphsUnicode, getDingbatsGlyphsUnicode };
export { getDingbatsGlyphsUnicode, getGlyphsUnicode };
4 changes: 2 additions & 2 deletions src/core/image_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ class GlobalImageCache {
}

export {
LocalImageCache,
GlobalImageCache,
LocalColorSpaceCache,
LocalFunctionCache,
LocalGStateCache,
LocalImageCache,
LocalTilingPatternCache,
GlobalImageCache,
};
2 changes: 1 addition & 1 deletion src/core/obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -2602,4 +2602,4 @@ const ObjectLoader = (function () {
return ObjectLoader;
})();

export { Catalog, ObjectLoader, XRef, FileSpec };
export { Catalog, FileSpec, ObjectLoader, XRef };
2 changes: 1 addition & 1 deletion src/core/pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,4 +994,4 @@ function getTilingPatternIR(operatorList, dict, color) {
];
}

export { Pattern, getTilingPatternIR };
export { getTilingPatternIR, Pattern };
12 changes: 6 additions & 6 deletions src/core/primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
6 changes: 3 additions & 3 deletions src/core/standard_fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,11 +764,11 @@ const getSupplementalGlyphMapForCalibri = getLookupTableFactory(function (t) {
});

export {
getStdFontMap,
getGlyphMapForStandardFonts,
getNonStdFontMap,
getSerifFonts,
getSymbolsFonts,
getGlyphMapForStandardFonts,
getStdFontMap,
getSupplementalGlyphMapForArialBlack,
getSupplementalGlyphMapForCalibri,
getSymbolsFonts,
};
4 changes: 2 additions & 2 deletions src/core/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -1341,14 +1341,14 @@ var NullStream = (function NullStreamClosure() {
export {
Ascii85Stream,
AsciiHexStream,
DecryptStream,
DecodeStream,
DecryptStream,
FlateStream,
LZWStream,
NullStream,
PredictorStream,
RunLengthStream,
Stream,
StreamsSequenceStream,
StringStream,
LZWStream,
};
6 changes: 3 additions & 3 deletions src/core/unicode.js
Original file line number Diff line number Diff line change
Expand Up @@ -1642,9 +1642,9 @@ function reverseIfRtl(chars) {
}

export {
mapSpecialUnicodeValues,
reverseIfRtl,
getUnicodeRangeFor,
getNormalizedUnicodes,
getUnicodeForGlyph,
getUnicodeRangeFor,
mapSpecialUnicodeValues,
reverseIfRtl,
};
2 changes: 1 addition & 1 deletion src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,4 +804,4 @@ if (
WorkerMessageHandler.initializeFromPort(self);
}

export { WorkerTask, WorkerMessageHandler };
export { WorkerMessageHandler, WorkerTask };
2 changes: 1 addition & 1 deletion src/core/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,4 @@ function incrementalUpdate({
return array;
}

export { writeDict, incrementalUpdate };
export { incrementalUpdate, writeDict };
8 changes: 4 additions & 4 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3051,15 +3051,15 @@ const build =
typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : null;

export {
build,
DefaultCanvasFactory,
DefaultCMapReaderFactory,
getDocument,
LoopbackPort,
PDFDataRangeTransport,
PDFWorker,
PDFDocumentProxy,
PDFPageProxy,
PDFWorker,
setPDFNetworkStreamFactory,
version,
build,
DefaultCanvasFactory,
DefaultCMapReaderFactory,
};
16 changes: 8 additions & 8 deletions src/display/display_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
2 changes: 1 addition & 1 deletion src/interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ class IPDFStreamRangeReader {
cancel(reason) {}
}

export { IPDFStream, IPDFStreamReader, IPDFStreamRangeReader };
export { IPDFStream, IPDFStreamRangeReader, IPDFStreamReader };
2 changes: 1 addition & 1 deletion src/pdf.image_decoders.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
1 change: 1 addition & 0 deletions src/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 81525fd

Please sign in to comment.