From 5fa6e347c4575f7050a092f382464e24d1daad98 Mon Sep 17 00:00:00 2001 From: nikolay Date: Wed, 19 Feb 2020 04:53:06 +0100 Subject: [PATCH 1/3] Fix ancient dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index b640fc6..604c52e 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "check-codestyle": "eslint ./", "fix-codestyle": "eslint ./ --fix", "preintegration-tests": "npm run build", - "integration-tests": "mocha test/index.js", + "integration-tests": "mocha --exit test/index.js", "//": "`in-publish` is used so that the CI doesn’t run tests during the installation. If it does and the tests fail, the build gets errored instead of failed.", "prepublish": "in-publish && npm run test || not-in-publish" }, @@ -35,11 +35,11 @@ "chai-as-promised": "^5.3.0", "chromedriver": "^80.0.1", "cross-env": "^3.1.3", - "css-loader": "^0.26.1", - "eslint": "^2.9.0", + "css-loader": "^3.4.2", + "eslint": "^6.6.0", "extract-text-webpack-plugin": "2.0.0-beta.4", "in-publish": "^2.0.0", - "mocha": "^2.5.3", + "mocha": "^7.0.1", "selenium-webdriver": "^3.0.0-beta-2", "static-server": "^2.0.3", "style-loader": "^0.13.1", From 8afed8078572e13815d370e47b7f881ca1eed80f Mon Sep 17 00:00:00 2001 From: nikolay Date: Wed, 19 Feb 2020 04:53:54 +0100 Subject: [PATCH 2/3] Improve readme.md --- readme.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index c239e46..6f55734 100644 --- a/readme.md +++ b/readme.md @@ -186,4 +186,9 @@ We support IE 10+, Safari 9+ and the latest versions of Chrome, Firefox and Edge # Development Please use the [Github commit style](https://gist.github.com/robertpainsi/b632364184e70900af4ab688decf6f53). -Before pushing: `npm test`. +Before pushing make sure the tests are green and the linter does not complain. +```bash +npm test +npm run-script check-codestyle +``` +Also please add your own tests if you are submitting a feature. From 03d3749cb718dd1e9ec84099545144e8dc113586 Mon Sep 17 00:00:00 2001 From: nikolay Date: Wed, 19 Feb 2020 04:54:34 +0100 Subject: [PATCH 3/3] Fix style according to linter --- source/dom.js | 8 ++++---- source/services/twitter.js | 2 +- source/utils.js | 16 ++++++++-------- source/widget.js | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/source/dom.js b/source/dom.js index 562ccf4..9d40db6 100644 --- a/source/dom.js +++ b/source/dom.js @@ -20,10 +20,10 @@ global.__likelyCallbacks = {}; * @returns {String} */ export const wrapSVG = (coords) => - ''; + ''; /** * Create node from HTML diff --git a/source/services/twitter.js b/source/services/twitter.js index f7bf54a..cb045c8 100644 --- a/source/services/twitter.js +++ b/source/services/twitter.js @@ -7,7 +7,7 @@ export default { popupWidth: 600, popupHeight: 450, click() { - if (!/[\.\?:\-–—]\s*$/.test(this.options.title)) { + if (!/[.?:\-–—]\s*$/.test(this.options.title)) { this.options.title += ':'; } diff --git a/source/utils.js b/source/utils.js index 7793943..ae612d8 100644 --- a/source/utils.js +++ b/source/utils.js @@ -8,7 +8,7 @@ const bool = { yes: true, no: false }; */ export const each = (object, callback) => { for (const key in object) { - if (object.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(object, key)) { callback(object[key], key); } } @@ -37,7 +37,7 @@ export const merge = function () { if (arg) { for (const key in arg) { - if (arg.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(arg, key)) { result[key] = arg[key]; } } @@ -56,7 +56,7 @@ export const merge = function () { */ export const extend = (target, subject) => { for (const key in subject) { - if (subject.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(subject, key)) { target[key] = subject[key]; } } @@ -85,7 +85,7 @@ export const getDataset = (node) => { for (i = attributes.length - 1; i >= 0; i--) { attribute = attributes[i]; - if (attribute && attribute.name && (/^data-\w[\w\-]*$/).test(attribute.name)) { + if (attribute && attribute.name && (/^data-\w[\w-]*$/).test(attribute.name)) { attributeName = attribute.name.substr(5).replace(/-./g, toUpperCase); dataset[attributeName] = attribute.value; } @@ -105,7 +105,7 @@ export const bools = (node) => { const data = getDataset(node); for (const key in data) { - if (data.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(data, key)) { const value = data[key]; result[key] = bool[value] || value; @@ -123,7 +123,7 @@ export const bools = (node) => { * @returns {String} */ export const template = (text, data) => { - return text ? text.replace(/\{([^\}]+)\}/g, function (value, key) { + return text ? text.replace(/\{([^}]+)\}/g, function (value, key) { return key in data ? data[key] : value; }) : ''; }; @@ -137,7 +137,7 @@ export const template = (text, data) => { */ export const makeUrl = (text, data) => { for (const key in data) { - if (data.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(data, key)) { data[key] = encodeURIComponent(data[key]); } } @@ -183,7 +183,7 @@ export const set = (object, key, value) => { } if (index !== frags.length - 1) { - object = object[key]; // eslint-disable-line no-param-reassign + object = object[key]; // eslint-disable-line no-param-reassign } last = key; diff --git a/source/widget.js b/source/widget.js index fdb771e..2eb5db2 100644 --- a/source/widget.js +++ b/source/widget.js @@ -26,7 +26,7 @@ class Likely { */ init() { toArray(this.container.children) - .forEach(this.addButton.bind(this)); + .forEach(this.addButton.bind(this)); if (this.options.counters) { this.timer = setTimeout(this.appear.bind(this), this.options.wait);