From 0a139ef67f28fe993b9039034f449bf291fee010 Mon Sep 17 00:00:00 2001 From: Peter deHaan Date: Wed, 9 Nov 2016 15:51:47 -0800 Subject: [PATCH] chore(addon): Fix invalid template strings in addon/MetadataStore.js --- .eslintignore | 5 +++-- .eslintrc | 1 + addon/MetadataStore.js | 6 +++--- content-test/lib/getRelativeTime.test.js | 10 +++++++++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.eslintignore b/.eslintignore index 94dc117507..ac0ff8ea7b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,9 +1,10 @@ activity-streams-env/ -addon/SimpleStorage.js addon/ColorAnalyzer.js +addon/SimpleStorage.js common/vendor.js data/content/ firefox/ logs/ -test/test-SimpleStorage.js +stats.json test/test-ColorAnalyzer.js +test/test-SimpleStorage.js diff --git a/.eslintrc b/.eslintrc index b3736ef10e..85a116fe27 100644 --- a/.eslintrc +++ b/.eslintrc @@ -211,6 +211,7 @@ "no-sparse-arrays": 2, "no-sync": 2, "no-tabs": 2, + "no-template-curly-in-string": 2, "no-ternary": 0, "no-this-before-super": 2, "no-throw-literal": 2, diff --git a/addon/MetadataStore.js b/addon/MetadataStore.js index 67ef2ac08c..8396aa2bf7 100644 --- a/addon/MetadataStore.js +++ b/addon/MetadataStore.js @@ -452,7 +452,7 @@ MetadataStore.prototype = { ); } catch (e) { - Cu.reportError("Failed to fetch metadata by cacheKey: ${e.message}"); + Cu.reportError(`Failed to fetch metadata by cacheKey: ${e.message}`); throw e; } @@ -475,7 +475,7 @@ MetadataStore.prototype = { } ); } catch (e) { - Cu.reportError("Failed to fetch metadata by cacheKey: ${e.message}"); + Cu.reportError(`Failed to fetch metadata by cacheKey: ${e.message}`); throw e; } for (let image of images) { @@ -496,7 +496,7 @@ MetadataStore.prototype = { }); break; default: - throw new Error("Fetched unknown image types: {image.type}"); + throw new Error(`Fetched unknown image types: ${image.type}`); } } } diff --git a/content-test/lib/getRelativeTime.test.js b/content-test/lib/getRelativeTime.test.js index f5997e5808..0c20ada272 100644 --- a/content-test/lib/getRelativeTime.test.js +++ b/content-test/lib/getRelativeTime.test.js @@ -6,18 +6,26 @@ describe("getRelativeTime", () => { assert.equal(getRelativeTime(moment().valueOf()), "<1m"); assert.equal(getRelativeTime(moment().subtract(30, "seconds").valueOf()), "<1m"); }); + + // eslint-disable-next-line no-template-curly-in-string it("should show ${n}m for ~minutes", () => { assert.equal(getRelativeTime(moment().subtract(1, "minutes").valueOf()), "1m"); assert.equal(getRelativeTime(moment().subtract(5, "minutes").valueOf()), "5m"); }); + + // eslint-disable-next-line no-template-curly-in-string it("should show ${n}h for ~hours", () => { assert.equal(getRelativeTime(moment().subtract(1, "hours").valueOf()), "1h"); assert.equal(getRelativeTime(moment().subtract(5, "hours").valueOf()), "5h"); }); - it("should show ${n}h for ~days", () => { + + // eslint-disable-next-line no-template-curly-in-string + it("should show ${n}d for ~days", () => { assert.equal(getRelativeTime(moment().subtract(1, "days").valueOf()), "1d"); assert.equal(getRelativeTime(moment().subtract(5, "days").valueOf()), "5d"); }); + + // eslint-disable-next-line no-template-curly-in-string it("should show ${n}y for ~years", () => { assert.equal(getRelativeTime(moment().subtract(1, "years").valueOf()), "1y"); assert.equal(getRelativeTime(moment().subtract(5, "years").valueOf()), "5y");