Skip to content

Commit

Permalink
chore(tsconfig): enable checkJs compiler option
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Sep 17, 2023
1 parent 7fbaf0a commit bb385fa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ const errorMessages = {
* @description Checks each option provided is valid, of the correct type, and can be used by specified
* version of binary.
* @ignore
* @param {object} acceptedOptions - Object containing options that a binary accepts.
* @param {object} options - Object containing options to pass to binary.
* @param {{[key: string]: {arg: string, type: string, minVersion?: string, maxVersion?: string}}} acceptedOptions - Object containing accepted options.
* @param {{[key: string]: any}} options - Object containing options to pass to binary.
* @param {string} [version] - Version of binary.
* @returns {string[]} Array of CLI arguments.
* @throws If invalid arguments provided.
*/
function parseOptions(acceptedOptions, options, version) {
/** @type {string[]} */
const args = [];
/** @type {string[]} */
const invalidArgs = [];
Object.keys(options).forEach((key) => {
if (Object.prototype.hasOwnProperty.call(acceptedOptions, key)) {
Expand Down Expand Up @@ -59,6 +61,7 @@ function parseOptions(acceptedOptions, options, version) {
if (
acceptedOptions[key].minVersion &&
version &&
// @ts-ignore: type checking is done above
lt(version, acceptedOptions[key].minVersion, { loose: true })
) {
invalidArgs.push(
Expand Down Expand Up @@ -216,6 +219,7 @@ class Poppler {
["-v"]
);

// @ts-ignore: parseOptions checks if falsy
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];

const args = parseOptions(acceptedOptions, options, versionInfo);
Expand Down Expand Up @@ -308,6 +312,7 @@ class Poppler {
["-v"]
);

// @ts-ignore: parseOptions checks if falsy
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];

const args = parseOptions(acceptedOptions, options, versionInfo);
Expand Down Expand Up @@ -423,6 +428,7 @@ class Poppler {
["-v"]
);

// @ts-ignore: parseOptions checks if falsy
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];

const args = parseOptions(acceptedOptions, options, versionInfo);
Expand All @@ -431,6 +437,7 @@ class Poppler {
* Poppler does not set the "File size" metadata value if passed
* a Buffer via stdin, so need to retrieve it from the Buffer
*/
/** @type {number} */
let fileSize;

return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -527,6 +534,7 @@ class Poppler {
["-v"]
);

// @ts-ignore: parseOptions checks if falsy
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];

const args = parseOptions(acceptedOptions, options, versionInfo);
Expand Down Expand Up @@ -704,6 +712,7 @@ class Poppler {
["-v"]
);

// @ts-ignore: parseOptions checks if falsy
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];

const args = parseOptions(acceptedOptions, options, versionInfo);
Expand Down Expand Up @@ -844,6 +853,7 @@ class Poppler {
["-v"]
);

// @ts-ignore: parseOptions checks if falsy
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];

const args = parseOptions(acceptedOptions, options, versionInfo);
Expand Down Expand Up @@ -1048,6 +1058,7 @@ class Poppler {
["-v"]
);

// @ts-ignore: parseOptions checks if falsy
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];

const args = parseOptions(acceptedOptions, options, versionInfo);
Expand Down Expand Up @@ -1278,6 +1289,7 @@ class Poppler {
["-v"]
);

// @ts-ignore: parseOptions checks if falsy
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];

const args = parseOptions(acceptedOptions, options, versionInfo);
Expand Down Expand Up @@ -1427,6 +1439,7 @@ class Poppler {
["-v"]
);

// @ts-ignore: parseOptions checks if falsy
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];

const args = parseOptions(acceptedOptions, options, versionInfo);
Expand Down Expand Up @@ -1505,6 +1518,7 @@ class Poppler {
["-v"]
);

// @ts-ignore: parseOptions checks if falsy
const versionInfo = /(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];

const args = parseOptions(acceptedOptions, options, versionInfo);
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"lib": ["ES2023"],
Expand Down

0 comments on commit bb385fa

Please sign in to comment.