diff --git a/package.json b/package.json index 853df7a..cd8152a 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "lint:fix": "yarn lint -- --fix", "precommit": "lint-staged", "prepublish": "yarn build", - "prettier": "prettier 'src/**/*.js' --write --single-quote=true --print-width=120", + "prettier": "prettier 'src/**/*.js' --write --single-quote=true --print-width=120 --no-config", "test": "jest", "test:coverage": "yarn test -- --coverage", "test:report": "codecov", diff --git a/src/scope/templates/__snapshots__/index.test.js.snap b/src/scope/templates/__snapshots__/index.test.js.snap index 4c5323a..5fd4716 100644 --- a/src/scope/templates/__snapshots__/index.test.js.snap +++ b/src/scope/templates/__snapshots__/index.test.js.snap @@ -3,9 +3,9 @@ exports[`Templates .buildGroupCollapsed calls template with correct string and indentation level: 0 1`] = ` " if (typeof window !== 'undefined') { - console.groupCollapsed(title); + console.groupCollapsed(TITLE); } else { - console.log('▼ ', title); + console.log('▼ ', TITLE); } " `; @@ -13,9 +13,9 @@ exports[`Templates .buildGroupCollapsed calls template with correct string and i exports[`Templates .buildGroupCollapsed calls template with correct string and indentation level: 1 1`] = ` " if (typeof window !== 'undefined') { - console.groupCollapsed(title); + console.groupCollapsed(TITLE); } else { - console.log('| ▼ ', title); + console.log('| ▼ ', TITLE); } " `; @@ -23,9 +23,9 @@ exports[`Templates .buildGroupCollapsed calls template with correct string and i exports[`Templates .buildGroupCollapsed calls template with correct string and indentation level: 2 1`] = ` " if (typeof window !== 'undefined') { - console.groupCollapsed(title); + console.groupCollapsed(TITLE); } else { - console.log('| | ▼ ', title); + console.log('| | ▼ ', TITLE); } " `; @@ -33,9 +33,9 @@ exports[`Templates .buildGroupCollapsed calls template with correct string and i exports[`Templates .buildGroupCollapsed calls template with correct string and indentation level: 3 1`] = ` " if (typeof window !== 'undefined') { - console.groupCollapsed(title); + console.groupCollapsed(TITLE); } else { - console.log('| | | ▼ ', title); + console.log('| | | ▼ ', TITLE); } " `; @@ -43,7 +43,7 @@ exports[`Templates .buildGroupCollapsed calls template with correct string and i exports[`Templates .buildGroupEnd calls template with correct string 1`] = ` " if (typeof window !== 'undefined') { - console.groupEnd(title); + console.groupEnd(TITLE); } " `; @@ -51,9 +51,9 @@ exports[`Templates .buildGroupEnd calls template with correct string 1`] = ` exports[`Templates .buildLog calls template with correct string and indentation level: 1 1`] = ` " if (typeof window !== 'undefined') { - console.log(args); + console.log(ARGS); } else { - console.log('| | ', args); + console.log('| | ', ARGS); } " @@ -62,9 +62,9 @@ exports[`Templates .buildLog calls template with correct string and indentation exports[`Templates .buildLog calls template with correct string and indentation level: 2 1`] = ` " if (typeof window !== 'undefined') { - console.log(args); + console.log(ARGS); } else { - console.log('| | | ', args); + console.log('| | | ', ARGS); } " @@ -73,9 +73,9 @@ exports[`Templates .buildLog calls template with correct string and indentation exports[`Templates .buildLog calls template with correct string and indentation level: 3 1`] = ` " if (typeof window !== 'undefined') { - console.log(args); + console.log(ARGS); } else { - console.log('| | | | ', args); + console.log('| | | | ', ARGS); } " diff --git a/src/scope/templates/index.js b/src/scope/templates/index.js index f8eb8b3..1445196 100644 --- a/src/scope/templates/index.js +++ b/src/scope/templates/index.js @@ -1,36 +1,36 @@ -const buildGroupCollapsed = template => title => level => { +const buildGroupCollapsed = template => TITLE => level => { const indentation = indentWith(level, '| ', '▼ '); return template(` if (typeof window !== 'undefined') { - console.groupCollapsed(title); + console.groupCollapsed(TITLE); } else { - console.log('${indentation}', title); + console.log('${indentation}', TITLE); } - `)({ title }); + `)({ TITLE }); }; -const buildGroupEnd = template => title => +const buildGroupEnd = template => TITLE => template(` if (typeof window !== 'undefined') { - console.groupEnd(title); + console.groupEnd(TITLE); } -`)({ title }); +`)({ TITLE }); -const buildLog = template => (...args) => level => { +const buildLog = template => (...ARGS) => level => { if (level == 0) { - return template('console.log(args);')({ args }); + return template('console.log(ARGS);')({ ARGS }); } const indentation = indentWith(level, '| ', '| '); return template(` if (typeof window !== 'undefined') { - console.log(args); + console.log(ARGS); } else { - console.log('${indentation}', args); + console.log('${indentation}', ARGS); } - `)({ args }); + `)({ ARGS }); }; const indentWith = (level, str, initial) => Array.from({ length: level }).reduce(acc => `${str}${acc}`, initial); diff --git a/src/scope/templates/index.test.js b/src/scope/templates/index.test.js index 42cf759..ff8e3b0 100644 --- a/src/scope/templates/index.test.js +++ b/src/scope/templates/index.test.js @@ -18,7 +18,7 @@ describe('Templates', () => { const templateCurry = jest.fn(); const { buildGroupCollapsed } = templateHelpers(template); buildGroupCollapsed('matt')(0); - expect(templateCurry).toHaveBeenCalledWith({ title: 'matt' }); + expect(templateCurry).toHaveBeenCalledWith({ TITLE: 'matt' }); }); it('returns value from invoking template', () => { @@ -41,7 +41,7 @@ describe('Templates', () => { const templateCurry = jest.fn(); const { buildGroupEnd } = templateHelpers(template); buildGroupEnd('matt'); - expect(templateCurry).toHaveBeenCalledWith({ title: 'matt' }); + expect(templateCurry).toHaveBeenCalledWith({ TITLE: 'matt' }); }); it('returns value from invoking template', () => { @@ -56,7 +56,7 @@ describe('Templates', () => { const template = jest.fn(() => noop); const { buildLog } = templateHelpers(template); buildLog('bob', 'woz', 'ere')(0); - expect(template).toHaveBeenCalledWith('console.log(args);'); + expect(template).toHaveBeenCalledWith('console.log(ARGS);'); }); each([[1], [2], [3]]).it('calls template with correct string and indentation level: %d', level => { @@ -71,7 +71,7 @@ describe('Templates', () => { const templateCurry = jest.fn(); const { buildLog } = templateHelpers(template); buildLog('matt', 'woz', 'ere')(0); - expect(templateCurry).toHaveBeenCalledWith({ args: ['matt', 'woz', 'ere'] }); + expect(templateCurry).toHaveBeenCalledWith({ ARGS: ['matt', 'woz', 'ere'] }); }); it('returns value from invoking template', () => {