From 5bb063d378d62f1b4c5118fb53f799246cc48094 Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Wed, 2 Oct 2019 11:16:54 +0100 Subject: [PATCH 1/2] style: prefer-arrow-callback --- .eslintrc.json | 3 ++- lib/extend/tag.js | 2 +- lib/plugins/tag/code.js | 2 +- test/scripts/console/list_categories.js | 2 +- test/scripts/console/list_page.js | 2 +- test/scripts/console/list_post.js | 2 +- test/scripts/console/list_tags.js | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 57bd13b4a0..9fb853fe59 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,6 +12,7 @@ { "after": true } - ] + ], + "prefer-arrow-callback": "error" } } diff --git a/lib/extend/tag.js b/lib/extend/tag.js index df66add124..ba8efef76e 100644 --- a/lib/extend/tag.js +++ b/lib/extend/tag.js @@ -69,7 +69,7 @@ function getContext(lines, errLine, location, type) { Array.prototype.push.apply(message, // get LINES_OF_CONTEXT lines surrounding `errLine` getContextLineNums(1, lines.length, errLine, LINES_OF_CONTEXT) - .map(function(lnNum) { + .map(lnNum => { const line = ' ' + lnNum + ' | ' + lines[lnNum - 1]; if (lnNum === errLine) { return colorize.bold(line); diff --git a/lib/plugins/tag/code.js b/lib/plugins/tag/code.js index e7cfd8a614..69700a1c60 100644 --- a/lib/plugins/tag/code.js +++ b/lib/plugins/tag/code.js @@ -52,7 +52,7 @@ function getHighlightOptions(config, arg) { let mark = []; if (rMark.test(arg)) { arg = arg.replace(rMark, (match, _mark) => { - mark = _mark.split(',').reduce(function getMarkedLines(prev, cur) { + mark = _mark.split(',').reduce((prev, cur) => { if (/-/.test(cur)) { let a = Number(cur.substr(0, cur.indexOf('-'))); let b = Number(cur.substr(cur.indexOf('-') + 1)); diff --git a/test/scripts/console/list_categories.js b/test/scripts/console/list_categories.js index 822bc312a1..1519533356 100644 --- a/test/scripts/console/list_categories.js +++ b/test/scripts/console/list_categories.js @@ -13,7 +13,7 @@ describe('Console list', () => { before(() => { const log = console.log; - sinon.stub(console, 'log').callsFake(function(...args) { + sinon.stub(console, 'log').callsFake((...args) => { return log.apply(log, args); }); }); diff --git a/test/scripts/console/list_page.js b/test/scripts/console/list_page.js index d4f2afd1c5..96cd89a26d 100644 --- a/test/scripts/console/list_page.js +++ b/test/scripts/console/list_page.js @@ -12,7 +12,7 @@ describe('Console list', () => { hexo.config.permalink = ':title/'; before(() => { const log = console.log; - sinon.stub(console, 'log').callsFake(function(...args) { + sinon.stub(console, 'log').callsFake((...args) => { return log.apply(log, args); }); }); diff --git a/test/scripts/console/list_post.js b/test/scripts/console/list_post.js index 96f424fdfb..6509e3751e 100644 --- a/test/scripts/console/list_post.js +++ b/test/scripts/console/list_post.js @@ -12,7 +12,7 @@ describe('Console list', () => { before(() => { const log = console.log; - sinon.stub(console, 'log').callsFake(function(...args) { + sinon.stub(console, 'log').callsFake((...args) => { return log.apply(log, args); }); }); diff --git a/test/scripts/console/list_tags.js b/test/scripts/console/list_tags.js index 50b38419f1..0b9d9247df 100644 --- a/test/scripts/console/list_tags.js +++ b/test/scripts/console/list_tags.js @@ -14,7 +14,7 @@ describe('Console list', () => { hexo.config.permalink = ':title/'; before(() => { const log = console.log; - sinon.stub(console, 'log').callsFake(function(...args) { + sinon.stub(console, 'log').callsFake((...args) => { return log.apply(log, args); }); }); From 33af2400f1452b9573714048c0ad01d5e91f838d Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Wed, 2 Oct 2019 11:18:59 +0100 Subject: [PATCH 2/2] style: revert config --- .eslintrc.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 9fb853fe59..57bd13b4a0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,7 +12,6 @@ { "after": true } - ], - "prefer-arrow-callback": "error" + ] } }