From 47a60e6fb13c0308d80021f8dc917485f8fdb8ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Sep 2020 17:47:41 +0000 Subject: [PATCH 01/11] chore(deps-dev): bump prettier from 1.17.0 to 2.1.2 Bumps [prettier](https://github.com/prettier/prettier) from 1.17.0 to 2.1.2. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/1.17.0...2.1.2) Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 15199d0b..0d86a9bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14102,9 +14102,9 @@ "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=" }, "prettier": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.17.0.tgz", - "integrity": "sha512-sXe5lSt2WQlCbydGETgfm1YBShgOX4HxQkFPvbxkcwgDvGDeqVau8h+12+lmSVlP3rHPz0oavfddSZg/q+Szjw==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz", + "integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==", "dev": true }, "pretty-format": { diff --git a/package.json b/package.json index 4d6f659f..c219cadb 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "lint-staged": "^8.0.4", "npm-run-all": "^4.0.0", "nyc": "^14.0.0", - "prettier": "^1.17.0", + "prettier": "^2.1.2", "remark-cli": "^8.0.1", "remark-preset-lint-itgalaxy": "^15.0.0", "rimraf": "^3.0.2", From 7f30eef0a1117886b28e3b117d2889e1734755f6 Mon Sep 17 00:00:00 2001 From: Jimmy Andrade Date: Tue, 29 Sep 2020 16:40:19 -0300 Subject: [PATCH 02/11] refactor(eslintrc): move ESLint config to external file --- .eslintrc.json | 44 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 48 ------------------------------------------------ 2 files changed, 44 insertions(+), 48 deletions(-) create mode 100644 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..78c8c1fb --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,44 @@ +{ + "parserOptions": { + "sourceType": "script" + }, + "extends": [ + "plugin:itgalaxy/node", + "plugin:itgalaxy/esnext", + "plugin:itgalaxy/jest", + "plugin:itgalaxy/markdown" + ], + "overrides": [ + { + "files": ["src/**/*"], + "parserOptions": { + "sourceType": "module" + }, + "rules": { + "node/no-unsupported-features/es-syntax": "off" + } + }, + { + "files": ["**/*.md"], + "parserOptions": { + "sourceType": "module", + "ecmaFeatures": { + "impliedStrict": true + } + }, + "rules": { + "strict": "off", + "no-undef": "off", + "no-unused-vars": "off", + "no-process-env": "off", + "no-process-exit": "off", + "no-console": "off", + "import/no-unresolved": "off", + "import/extensions": "off", + "node/no-unpublished-require": "off", + "node/no-unsupported-features/es-syntax": "off" + } + } + ], + "root": true +} diff --git a/package.json b/package.json index c219cadb..2239c0a2 100644 --- a/package.json +++ b/package.json @@ -133,54 +133,6 @@ ] ] }, - "eslintConfig": { - "parserOptions": { - "sourceType": "script" - }, - "extends": [ - "plugin:itgalaxy/node", - "plugin:itgalaxy/esnext", - "plugin:itgalaxy/jest", - "plugin:itgalaxy/markdown" - ], - "overrides": [ - { - "files": [ - "src/**/*" - ], - "parserOptions": { - "sourceType": "module" - }, - "rules": { - "node/no-unsupported-features/es-syntax": "off" - } - }, - { - "files": [ - "**/*.md" - ], - "parserOptions": { - "sourceType": "module", - "ecmaFeatures": { - "impliedStrict": true - } - }, - "rules": { - "strict": "off", - "no-undef": "off", - "no-unused-vars": "off", - "no-process-env": "off", - "no-process-exit": "off", - "no-console": "off", - "import/no-unresolved": "off", - "import/extensions": "off", - "node/no-unpublished-require": "off", - "node/no-unsupported-features/es-syntax": "off" - } - } - ], - "root": true - }, "remarkConfig": { "plugins": [ "remark-preset-lint-itgalaxy" From cd9ac29c2f5b37c90535fff711959e3852be27b4 Mon Sep 17 00:00:00 2001 From: Jimmy Andrade Date: Tue, 29 Sep 2020 16:40:37 -0300 Subject: [PATCH 03/11] style(husky config): update formatting --- husky.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/husky.config.js b/husky.config.js index 1c28eee4..aa7bc770 100644 --- a/husky.config.js +++ b/husky.config.js @@ -2,6 +2,6 @@ module.exports = { hooks: { - "pre-commit": "lint-staged" - } + "pre-commit": "lint-staged", + }, }; From a4515560c225fd99c216dee945bb4cdb25d8b384 Mon Sep 17 00:00:00 2001 From: Jimmy Andrade Date: Tue, 29 Sep 2020 16:41:10 -0300 Subject: [PATCH 04/11] style(lint staged): update code style --- lint-staged.config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lint-staged.config.js b/lint-staged.config.js index 562c8e61..8828db6c 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -4,12 +4,12 @@ module.exports = { "*.{js,jsx}": [ "prettier --list-different", "eslint --report-unused-disable-directives", - "git add" + "git add", ], "*.{md,markdown,mdown,mkdn,mkd,mdwn,mkdown,ron}": [ "prettier --list-different", "remark -f -q", - "git add" + "git add", ], - "*.{yml,yaml}": ["prettier --list-different", "git add"] + "*.{yml,yaml}": ["prettier --list-different", "git add"], }; From b53f69af3872f0c853f531003a17cc507aadf9cd Mon Sep 17 00:00:00 2001 From: Jimmy Andrade Date: Tue, 29 Sep 2020 16:42:10 -0300 Subject: [PATCH 05/11] style(readme): update code style on README.md --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index a2c659c7..3ff9fd21 100755 --- a/README.md +++ b/README.md @@ -51,14 +51,14 @@ const webfont = require("webfont").default; webfont({ files: "src/svg-icons/**/*.svg", - fontName: "my-font-name" + fontName: "my-font-name", }) - .then(result => { + .then((result) => { console.log(result); return result; }) - .catch(error => { + .catch((error) => { throw error; }); ``` @@ -70,14 +70,14 @@ import webfont from "webfont"; webfont({ files: "src/svg-icons/**/*.svg", - fontName: "my-font-name" + fontName: "my-font-name", }) - .then(result => { + .then((result) => { console.log(result); return result; }) - .catch(error => { + .catch((error) => { throw error; }); ``` @@ -122,7 +122,7 @@ webfont({ ```js webfont({ - template: "./path/to/my-template.css" + template: "./path/to/my-template.css", }); ``` @@ -130,7 +130,7 @@ webfont({ ```js webfont({ - template: path.resolve(__dirname, "./my-template.css") + template: path.resolve(__dirname, "./my-template.css"), }); ``` @@ -138,7 +138,7 @@ webfont({ ```js webfont({ - template: path.resolve(__dirname, "./my-template.styl") + template: path.resolve(__dirname, "./my-template.styl"), }); ``` @@ -172,18 +172,18 @@ webfont({ webfont({ files: "src/svg-icons/**/*.svg", - glyphTransformFn: obj => { + glyphTransformFn: (obj) => { obj.name += "_transform"; return obj; - } + }, }) - .then(result => { + .then((result) => { console.log(result); return result; }) - .catch(error => { + .catch((error) => { throw error; }); ``` From 5c6cf1bf2418c976c70f37c62ec15792b1c33d30 Mon Sep 17 00:00:00 2001 From: Jimmy Andrade Date: Tue, 29 Sep 2020 16:43:16 -0300 Subject: [PATCH 06/11] style: format standalone test code style --- src/__tests__/standalone.test.js | 68 +++++++++++++------------------- 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/src/__tests__/standalone.test.js b/src/__tests__/standalone.test.js index 4b23f49c..b4b9c2cb 100644 --- a/src/__tests__/standalone.test.js +++ b/src/__tests__/standalone.test.js @@ -24,7 +24,7 @@ describe("standalone", () => { try { await standalone({ - files: `${fixturesGlob}/not-found-svg-icons/**/*` + files: `${fixturesGlob}/not-found-svg-icons/**/*`, }); } catch (error) { // eslint-disable-next-line jest/no-conditional-expect @@ -36,7 +36,7 @@ describe("standalone", () => { it("should generate all fonts", async () => { const result = await standalone({ - files: `${fixturesGlob}/svg-icons/**/*` + files: `${fixturesGlob}/svg-icons/**/*`, }); expect(isSvg(result.svg)).toBe(true); @@ -49,7 +49,7 @@ describe("standalone", () => { // Need search better way to test `fs` delay it("should generate all fonts and will be deterministic", async () => { const result = await standalone({ - files: `${fixturesGlob}/svg-icons/**/*` + files: `${fixturesGlob}/svg-icons/**/*`, }); expect(isSvg(result.svg)).toBe(true); @@ -58,22 +58,10 @@ describe("standalone", () => { expect(isWoff(result.woff)).toBe(true); expect(isWoff2(result.woff2)).toBe(true); - const svgHash = crypto - .createHash("md5") - .update(result.svg) - .digest("hex"); - const ttfHash = crypto - .createHash("md5") - .update(result.ttf) - .digest("hex"); - const eotHash = crypto - .createHash("md5") - .update(result.eot) - .digest("hex"); - const woffHash = crypto - .createHash("md5") - .update(result.woff) - .digest("hex"); + const svgHash = crypto.createHash("md5").update(result.svg).digest("hex"); + const ttfHash = crypto.createHash("md5").update(result.ttf).digest("hex"); + const eotHash = crypto.createHash("md5").update(result.eot).digest("hex"); + const woffHash = crypto.createHash("md5").update(result.woff).digest("hex"); const woff2Hash = crypto .createHash("md5") .update(result.woff2) @@ -89,7 +77,7 @@ describe("standalone", () => { it("should generate only `svg`, `ttf` and `eot` fonts", async () => { const result = await standalone({ files: `${fixturesGlob}/svg-icons/**/*`, - formats: ["svg", "ttf", "eot"] + formats: ["svg", "ttf", "eot"], }); expect(isSvg(result.svg)).toBe(true); @@ -102,7 +90,7 @@ describe("standalone", () => { it("should generate only `woff2` font", async () => { const result = await standalone({ files: `${fixturesGlob}/svg-icons/**/*`, - formats: ["woff2"] + formats: ["woff2"], }); expect(result.svg).toBeUndefined(); @@ -115,7 +103,7 @@ describe("standalone", () => { it("should generate all fonts with build-in template", async () => { const result = await standalone({ files: `${fixturesGlob}/svg-icons/**/*`, - template: "css" + template: "css", }); expect(isSvg(result.svg)).toBe(true); @@ -130,7 +118,7 @@ describe("standalone", () => { const result = await standalone({ files: `${fixturesGlob}/svg-icons/**/*`, formats: ["woff", "woff2"], - template: "css" + template: "css", }); expect(result.svg).toBeUndefined(); @@ -144,7 +132,7 @@ describe("standalone", () => { it("should generate all fonts with custom `template` with absolute path", async () => { const result = await standalone({ files: `${fixturesGlob}/svg-icons/**/*`, - template: path.join(fixturesGlob, "templates/template.css") + template: path.join(fixturesGlob, "templates/template.css"), }); expect(isSvg(result.svg)).toBe(true); @@ -158,7 +146,7 @@ describe("standalone", () => { it("should generate all fonts with custom `template` with relative path", async () => { const result = await standalone({ files: `${fixturesGlob}/svg-icons/**/*`, - template: "src/__tests__/fixtures/templates/template.css" + template: "src/__tests__/fixtures/templates/template.css", }); expect(isSvg(result.svg)).toBe(true); @@ -173,7 +161,7 @@ describe("standalone", () => { const configFile = path.join(fixturesGlob, "configs/.webfontrc"); const result = await standalone({ configFile, - files: `${fixturesGlob}/svg-icons/**/*` + files: `${fixturesGlob}/svg-icons/**/*`, }); expect(isSvg(result.svg)).toBe(true); @@ -192,7 +180,7 @@ describe("standalone", () => { const result = await standalone({ configFile, - files: `${fixturesGlob}/svg-icons/**/*` + files: `${fixturesGlob}/svg-icons/**/*`, }); expect(isSvg(result.svg)).toBe(true); @@ -211,7 +199,7 @@ describe("standalone", () => { ); const result = await standalone({ configFile, - files: `${fixturesGlob}/svg-icons/**/*` + files: `${fixturesGlob}/svg-icons/**/*`, }); expect(isSvg(result.svg)).toBe(true); @@ -232,7 +220,7 @@ describe("standalone", () => { ); const result = await standalone({ configFile, - files: `${fixturesGlob}/svg-icons/**/*` + files: `${fixturesGlob}/svg-icons/**/*`, }); expect(result.svg).toBeUndefined(); @@ -256,10 +244,10 @@ describe("standalone", () => { const result = await standalone({ files: [ `${fixturesGlob}/svg-icons/envelope.svg`, - `${fixturesGlob}/svg-icons/avatar.svg` + `${fixturesGlob}/svg-icons/avatar.svg`, ], sort: false, - template: path.join(fixturesGlob, "templates/template-ordered.css") + template: path.join(fixturesGlob, "templates/template-ordered.css"), }); expect(templateOutput.replace(/(\s)/g, "")).toBe( @@ -275,7 +263,7 @@ describe("standalone", () => { try { await standalone({ configFile, - files: `${fixturesGlob}/bad-svg-icons/avatar.svg` + files: `${fixturesGlob}/bad-svg-icons/avatar.svg`, }); } catch (error) { // eslint-disable-next-line jest/no-conditional-expect @@ -291,7 +279,7 @@ describe("standalone", () => { try { await standalone({ configFile, - files: `${fixturesGlob}/bad-svg-icons/avatar-1.svg` + files: `${fixturesGlob}/bad-svg-icons/avatar-1.svg`, }); } catch (error) { // eslint-disable-next-line jest/no-conditional-expect @@ -307,7 +295,7 @@ describe("standalone", () => { try { await standalone({ configFile, - files: `${fixturesGlob}/bad-svg-icons/avatar-2.svg` + files: `${fixturesGlob}/bad-svg-icons/avatar-2.svg`, }); } catch (error) { // eslint-disable-next-line jest/no-conditional-expect @@ -323,7 +311,7 @@ describe("standalone", () => { try { await standalone({ configFile, - files: `${fixturesGlob}/bad-svg-icons/avatar-3.svg` + files: `${fixturesGlob}/bad-svg-icons/avatar-3.svg`, }); } catch (error) { // eslint-disable-next-line jest/no-conditional-expect @@ -339,7 +327,7 @@ describe("standalone", () => { try { await standalone({ configFile, - files: `${fixturesGlob}/svg-icons/**/*` + files: `${fixturesGlob}/svg-icons/**/*`, }); } catch (error) { // eslint-disable-next-line jest/no-conditional-expect @@ -351,12 +339,12 @@ describe("standalone", () => { const result = await standalone({ files: `${fixturesGlob}/svg-icons/**/*`, formats: ["eot"], - glyphTransformFn: obj => { + glyphTransformFn: (obj) => { obj.name += "_transform"; return obj; }, - template: "css" + template: "css", }); expect(result.template).toMatchSnapshot(); @@ -368,7 +356,7 @@ describe("standalone", () => { template: "css", templateClassName: "foo", templateFontName: "bar", - templateFontPath: "./foo-bar" + templateFontPath: "./foo-bar", }); expect(isSvg(result.svg)).toBe(true); @@ -384,7 +372,7 @@ describe("standalone", () => { it("should export `glyphsData` in `result`", async () => { const result = await standalone({ files: `${fixturesGlob}/svg-icons/**/*`, - template: "css" + template: "css", }); expect(Array.isArray(result.glyphsData)).toBe(true); From 43fce56a9a9e868b76ac7c6abfc2c807153598ec Mon Sep 17 00:00:00 2001 From: Jimmy Andrade Date: Tue, 29 Sep 2020 16:43:35 -0300 Subject: [PATCH 07/11] style(cli): format code style --- src/cli.js | 66 +++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/cli.js b/src/cli.js index 1bbe7835..ea89776d 100644 --- a/src/cli.js +++ b/src/cli.js @@ -137,93 +137,93 @@ const cli = meow( autoVersion: false, flags: { ascent: { - type: "string" + type: "string", }, "center-horizontally": { - type: "boolean" + type: "boolean", }, config: { - default: null + default: null, }, descent: { - type: "string" + type: "string", }, dest: { alias: "d", default: process.cwd(), - type: "string" + type: "string", }, "dest-template": { alias: "s", - type: "string" + type: "string", }, "fixed-width": { - type: "boolean" + type: "boolean", }, "font-height": { - type: "string" + type: "string", }, "font-id": { - type: "string" + type: "string", }, "font-name": { alias: "u", - type: "string" + type: "string", }, "font-style": { - type: "string" + type: "string", }, "font-weight": { - type: "string" + type: "string", }, formats: { - alias: "f" + alias: "f", }, help: { alias: "h", - type: "boolean" + type: "boolean", }, normalize: { - type: "boolean" + type: "boolean", }, "prepend-unicode": { - type: "boolean" + type: "boolean", }, round: { - type: "string" + type: "string", }, sort: { default: true, - type: "boolean" + type: "boolean", }, "start-unicode": { - type: "string" + type: "string", }, template: { alias: "t", - type: "string" + type: "string", }, "template-class-name": { alias: "c", - type: "string" + type: "string", }, "template-font-name": { alias: "n", - type: "string" + type: "string", }, "template-font-path": { alias: "p", - type: "string" + type: "string", }, verbose: { default: false, - type: "boolean" + type: "boolean", }, version: { alias: "v", - type: "boolean" - } - } + type: "boolean", + }, + }, } ); @@ -344,19 +344,19 @@ if (cli.flags.version || cli.flags.v) { Promise.resolve() .then(() => { const options = Object.assign({}, optionsBase, { - files: cli.input + files: cli.input, }); if (options.files.length === 0) { cli.showHelp(); } - return standalone(options).then(result => { + return standalone(options).then((result) => { result.config = Object.assign( {}, { dest: options.dest, - destTemplate: options.destTemplate + destTemplate: options.destTemplate, }, result.config ); @@ -364,7 +364,7 @@ Promise.resolve() return result; }); }) - .then(result => { + .then((result) => { const { fontName, dest } = result.config; let destTemplate = null; @@ -392,7 +392,7 @@ Promise.resolve() return Promise.resolve() .then(() => Promise.all( - Object.keys(result).map(type => { + Object.keys(result).map((type) => { if ( type === "config" || type === "usedBuildInTemplate" || @@ -419,7 +419,7 @@ Promise.resolve() ) .then(() => Promise.resolve(result)); }) - .catch(error => { + .catch((error) => { // eslint-disable-next-line no-console console.log(error.stack); From 6c052bc7093bd08b0eab81391c759923d01bbf8e Mon Sep 17 00:00:00 2001 From: Jimmy Andrade Date: Tue, 29 Sep 2020 16:44:02 -0300 Subject: [PATCH 08/11] style(standalone): format code style --- src/standalone.js | 52 +++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/standalone.js b/src/standalone.js index 87921315..f081d8da 100644 --- a/src/standalone.js +++ b/src/standalone.js @@ -41,14 +41,14 @@ function getGlyphsData(files, options) { options.metadataProvider || defaultMetadataProvider({ prependUnicode: options.prependUnicode, - startUnicode: options.startUnicode + startUnicode: options.startUnicode, }); const xmlParser = new xml2js.Parser(); const throttle = pLimit(options.maxConcurrency); return Promise.all( - files.map(srcPath => + files.map((srcPath) => throttle( () => new Promise((resolve, reject) => { @@ -57,8 +57,8 @@ function getGlyphsData(files, options) { // eslint-disable-next-line no-promise-executor-return return glyph - .on("error", glyphError => reject(glyphError)) - .on("data", data => { + .on("error", (glyphError) => reject(glyphError)) + .on("data", (data) => { glyphContents += data.toString(); }) .on("end", () => { @@ -67,14 +67,14 @@ function getGlyphsData(files, options) { return reject(new Error(`Empty file ${srcPath}`)); } - return xmlParser.parseString(glyphContents, error => { + return xmlParser.parseString(glyphContents, (error) => { if (error) { return reject(error); } const glyphData = { contents: glyphContents, - srcPath + srcPath, }; return resolve(glyphData); @@ -83,7 +83,7 @@ function getGlyphsData(files, options) { }) ) ) - ).then(glyphsData => { + ).then((glyphsData) => { const sortedGlyphsData = options.sort ? glyphsData.sort((fileA, fileB) => fileSorter(fileA.srcPath, fileB.srcPath) @@ -92,7 +92,7 @@ function getGlyphsData(files, options) { return Promise.all( sortedGlyphsData.map( - glyphData => + (glyphData) => new Promise((resolve, reject) => { metadataProvider(glyphData.srcPath, (error, metadata) => { if (error) { @@ -127,15 +127,15 @@ function toSvg(glyphsData, options) { log: options.verbose ? console.log.bind(console) : () => {}, metadata: options.metadata, normalize: options.normalize, - round: options.round + round: options.round, }) .on("finish", () => resolve(result)) - .on("data", data => { + .on("data", (data) => { result += data; }) - .on("error", error => reject(error)); + .on("error", (error) => reject(error)); - glyphsData.forEach(glyphData => { + glyphsData.forEach((glyphData) => { const glyphStream = new Readable(); glyphStream.push(glyphData.contents); @@ -166,7 +166,7 @@ function toWoff2(buffer) { return wawoff2.compress(buffer); } -export default async function(initialOptions) { +export default async function (initialOptions) { if (!initialOptions || !initialOptions.files) { throw new Error("You must pass webfont a `files` glob"); } @@ -188,8 +188,8 @@ export default async function(initialOptions) { ttf: { copyright: null, ts: null, - version: null - } + version: null, + }, }, glyphTransformFn: null, // Maybe allow setup from CLI @@ -206,19 +206,19 @@ export default async function(initialOptions) { templateClassName: null, templateFontName: null, templateFontPath: "./", - verbose: false + verbose: false, }, initialOptions ); const config = await buildConfig({ - configFile: options.configFile + configFile: options.configFile, }); if (Object.keys(config).length > 0) { // eslint-disable-next-line require-atomic-updates options = deepmerge(options, config.config, { - arrayMerge: (_destinationArray, sourceArray, _opts) => sourceArray + arrayMerge: (_destinationArray, sourceArray, _opts) => sourceArray, }); // eslint-disable-next-line require-atomic-updates options.filePath = config.filepath; @@ -226,7 +226,7 @@ export default async function(initialOptions) { const foundFiles = await globby([].concat(options.files)); const filteredFiles = foundFiles.filter( - foundFile => path.extname(foundFile) === ".svg" + (foundFile) => path.extname(foundFile) === ".svg" ); if (filteredFiles.length === 0) { @@ -262,7 +262,7 @@ export default async function(initialOptions) { css: { path: path.join(templateDirectory, "template.css.njk") }, html: { path: path.join(templateDirectory, "template.html.njk") }, scss: { path: path.join(templateDirectory, "template.scss.njk") }, - styl: { path: path.join(templateDirectory, "template.styl.njk") } + styl: { path: path.join(templateDirectory, "template.styl.njk") }, }; let templateFilePath; @@ -272,9 +272,7 @@ export default async function(initialOptions) { nunjucks.configure(path.resolve(__dirname, "../")); - templateFilePath = `${templateDirectory}/template.${ - options.template - }.njk`; + templateFilePath = `${templateDirectory}/template.${options.template}.njk`; } else { const resolvedTemplateFilePath = path.resolve(options.template); @@ -285,20 +283,20 @@ export default async function(initialOptions) { const nunjucksOptions = deepmerge.all([ { - glyphs: result.glyphsData.map(glyphData => { + glyphs: result.glyphsData.map((glyphData) => { if (typeof options.glyphTransformFn === "function") { glyphData.metadata = options.glyphTransformFn(glyphData.metadata); } return glyphData.metadata; - }) + }), }, options, { className: options.templateClassName || options.fontName, fontName: options.templateFontName || options.fontName, - fontPath: options.templateFontPath.replace(/\/?$/, "/") - } + fontPath: options.templateFontPath.replace(/\/?$/, "/"), + }, ]); result.template = nunjucks.render(templateFilePath, nunjucksOptions); From 0270b5afe96d32bccd67c501f2b6ec0644468a89 Mon Sep 17 00:00:00 2001 From: Jimmy Andrade Date: Tue, 29 Sep 2020 16:55:37 -0300 Subject: [PATCH 09/11] style: format standalone test file code style --- src/__tests__/standalone.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/__tests__/standalone.test.js b/src/__tests__/standalone.test.js index 65df2c0e..afd9d27a 100644 --- a/src/__tests__/standalone.test.js +++ b/src/__tests__/standalone.test.js @@ -383,8 +383,8 @@ describe("standalone", () => { expect.assertions(1); return standalone({ - files: `${fixturesGlob}/svg-icons/**/*` - }).then(result => { + files: `${fixturesGlob}/svg-icons/**/*`, + }).then((result) => { expect(result.hash).toBe("ead2b6f69fc603bf1cbd00bf9f8a8a33"); return result; From 6b97ab43ebcf50a593024b53883a9036060d85a1 Mon Sep 17 00:00:00 2001 From: Jimmy Andrade Date: Tue, 29 Sep 2020 16:56:05 -0300 Subject: [PATCH 10/11] style(cli): format code style --- src/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli.js b/src/cli.js index b8ab31ee..7b23437a 100644 --- a/src/cli.js +++ b/src/cli.js @@ -221,7 +221,7 @@ const cli = meow( }, "add-hash-in-font-url": { default: false, - type: "boolean" + type: "boolean", }, verbose: { default: false, From 5bb55f91f2906092057441204e65c074fc538522 Mon Sep 17 00:00:00 2001 From: Jimmy Andrade Date: Tue, 29 Sep 2020 16:56:23 -0300 Subject: [PATCH 11/11] style(standalone): format code style --- src/standalone.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/standalone.js b/src/standalone.js index 57537185..4770e3e6 100644 --- a/src/standalone.js +++ b/src/standalone.js @@ -245,10 +245,7 @@ export default async function (initialOptions) { : {} ); - result.hash = crypto - .createHash("md5") - .update(result.svg) - .digest("hex"); + result.hash = crypto.createHash("md5").update(result.svg).digest("hex"); if (options.formats.includes("eot")) { result.eot = toEot(result.ttf); @@ -302,9 +299,9 @@ export default async function (initialOptions) { { className: options.templateClassName || options.fontName, fontName: options.templateFontName || options.fontName, - fontPath: options.templateFontPath.replace(/\/?$/, "/") + fontPath: options.templateFontPath.replace(/\/?$/, "/"), }, - hashOption + hashOption, ]); result.template = nunjucks.render(templateFilePath, nunjucksOptions);