Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Aug 24, 2020
1 parent 657caf6 commit b730feb
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions packages/endo/src/compartmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,30 @@ const findPackage = async (readDescriptor, directory, name) => {
}
};

const languages = ['cjs', 'mjs', 'json'];
const incontroversialParsers = { cjs: "cjs", "mjs": "mjs", json: "json" };
const languages = ["cjs", "mjs", "json"];
const incontroversialParsers = { cjs: "cjs", mjs: "mjs", json: "json" };
const commonParsers = { js: "cjs", ...incontroversialParsers };
const moduleParsers = { js: "mjs", ...incontroversialParsers };

const inferParsers = (descriptor, location) => {
const { type, parsers } = descriptor;
if (parsers !== undefined) {
if (typeof parsers !== 'object') {
throw new Error(`Cannot interpret parser map ${JSON.stringify(parsers)} of package at ${location}, must be an object mapping file extensions to corresponding languages (mjs for ECMAScript modules, cjs for CommonJS modules, or json for JSON modules`);
if (typeof parsers !== "object") {
throw new Error(
`Cannot interpret parser map ${JSON.stringify(
parsers
)} of package at ${location}, must be an object mapping file extensions to corresponding languages (mjs for ECMAScript modules, cjs for CommonJS modules, or json for JSON modules`
);
}
const invalidLanguages = values(parsers).filter(language => !languages.includes(language));
const invalidLanguages = values(parsers).filter(
language => !languages.includes(language)
);
if (invalidLanguages.length > 0) {
throw new Error(`Cannot interpret parser map language values ${JSON.stringify(invalidLanguages)} of package at ${location}, must be an object mapping file extensions to corresponding languages (mjs for ECMAScript modules, cjs for CommonJS modules, or json for JSON modules`);
throw new Error(
`Cannot interpret parser map language values ${JSON.stringify(
invalidLanguages
)} of package at ${location}, must be an object mapping file extensions to corresponding languages (mjs for ECMAScript modules, cjs for CommonJS modules, or json for JSON modules`
);
}
return { ...incontroversialParsers, ...parsers };
}
Expand Down

0 comments on commit b730feb

Please sign in to comment.