DEV: apply coding standards (#37)

DEV: apply coding standards (#37)

diff --git a/.eslintrc b/.eslintrc
index 66c4b8d..7898fbf 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,105 +1,3 @@
 {
-  "env": {
-    "jasmine": true,
-    "node": true,
-    "mocha": true,
-    "browser": true,
-    "builtin": true
-  },
-  "parserOptions": {
-    "ecmaVersion": 7,
-    "sourceType": "module"
-  },
-  "globals": {
-    "Ember":true,
-    "jQuery":true,
-    "$":true,
-    "RSVP":true,
-    "Discourse":true,
-    "PreloadStore":true,
-    "Handlebars":true,
-    "I18n":true,
-    "bootbox":true,
-    "module":true,
-    "moduleFor":true,
-    "moduleForComponent":true,
-    "Pretender":true,
-    "sandbox":true,
-    "controllerFor":true,
-    "test":true,
-    "ok":true,
-    "not":true,
-    "expect":true,
-    "equal":true,
-    "visit":true,
-    "andThen":true,
-    "click":true,
-    "currentPath":true,
-    "currentRouteName":true,
-    "currentURL":true,
-    "fillIn":true,
-    "keyEvent":true,
-    "triggerEvent":true,
-    "count":true,
-    "exists":true,
-    "visible":true,
-    "invisible":true,
-    "asyncRender":true,
-    "selectKit":true,
-    "asyncTestDiscourse":true,
-    "fixture":true,
-    "find":true,
-    "sinon":true,
-    "moment":true,
-    "start":true,
-    "_":true,
-    "alert":true,
-    "containsInstance":true,
-    "deepEqual":true,
-    "notEqual":true,
-    "define":true,
-    "require":true,
-    "requirejs":true,
-    "hasModule":true,
-    "Blob":true,
-    "File":true},
-  "rules": {
-    "block-scoped-var": 2,
-    "dot-notation": 0,
-    "eqeqeq": [
-      2,
-      "allow-null"
-    ],
-    "guard-for-in": 2,
-    "no-bitwise": 2,
-    "no-caller": 2,
-    "no-cond-assign": 0,
-    "no-debugger": 2,
-    "no-empty": 0,
-    "no-eval": 2,
-    "no-extend-native": 2,
-    "no-extra-parens": 0,
-    "no-irregular-whitespace": 2,
-    "no-iterator": 2,
-    "no-loop-func": 2,
-    "no-multi-str": 2,
-    "no-new": 2,
-    "no-plusplus": 0,
-    "no-proto": 2,
-    "no-script-url": 2,
-    "no-sequences": 2,
-    "no-shadow": 2,
-    "no-undef": 2,
-    "no-unused-vars": 2,
-    "no-with": 2,
-    "no-this-before-super": 2,
-    "semi": 2,
-    "strict": 0,
-    "valid-typeof": 2,
-    "wrap-iife": [
-      2,
-      "inside"
-    ]
-  },
-  "parser": "babel-eslint"
+  "extends": "eslint-config-discourse"
 }
diff --git a/.gitignore b/.gitignore
index cd173a2..a0fc57d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,6 @@ auto_generated/
 gems/
 .DS_Store
 node_modules/
+node_modules
+yarn-error.log
+.rubocop-https---raw-githubusercontent-com-discourse-*
diff --git a/.template-lintrc.js b/.template-lintrc.js
new file mode 100644
index 0000000..a558b8e
--- /dev/null
+++ b/.template-lintrc.js
@@ -0,0 +1,4 @@
+module.exports = {
+  plugins: ["ember-template-lint-plugin-discourse"],
+  extends: "discourse:recommended",
+};
diff --git a/assets/javascripts/discourse/controllers/admin-plugins-patreon.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-patreon.js.es6
index 820380d..f5bd737 100644
--- a/assets/javascripts/discourse/controllers/admin-plugins-patreon.js.es6
+++ b/assets/javascripts/discourse/controllers/admin-plugins-patreon.js.es6
@@ -1,3 +1,4 @@
+import I18n from "I18n";
 import { default as computed } from "ember-addons/ember-computed-decorators";
 import getURL from "discourse-common/lib/get-url";
 import FilterRule from "discourse/plugins/discourse-patreon/discourse/models/filter-rule";
@@ -5,13 +6,13 @@ import { ajax } from "discourse/lib/ajax";
 import { popupAjaxError } from "discourse/lib/ajax-error";
 
 export default Ember.Controller.extend({
-  prettyPrintReward: reward => {
+  prettyPrintReward: (reward) => {
     return `$${reward.amount_cents / 100} - ${reward.title}`;
   },
 
   @computed("rewards")
   rewardsNames() {
-    return _.filter(this.rewards, r => r.id >= 0).map(r =>
+    return _.filter(this.rewards, (r) => r.id >= 0).map((r) =>
       this.prettyPrintReward(r)
     );
   },
@@ -25,21 +26,23 @@ export default Ember.Controller.extend({
 
       rule.set(
         "group",
-        this.groups.find(x => x.id === parseInt(rule.get("group_id"), 10))
+        this.groups.find((x) => x.id === parseInt(rule.get("group_id"), 10))
       );
       rule.set(
         "rewards_ids",
-        _.filter(this.rewards, v =>
+        _.filter(this.rewards, (v) =>
           rule.get("reward_list").includes(this.prettyPrintReward(v))
-        ).map(r => r.id)
+        ).map((r) => r.id)
       );
 
       ajax("/patreon/list.json", {
         method: "POST",
-        data: rule.getProperties("group_id", "rewards_ids")
+        data: rule.getProperties("group_id", "rewards_ids"),
       })
         .then(() => {
-          var obj = model.find(x => x.get("group_id") === rule.get("group_id"));
+          var obj = model.find(
+            (x) => x.get("group_id") === rule.get("group_id")
+          );
           const rewards = rule.get("reward_list").filter(Boolean);
           if (obj) {
             obj.set("reward_list", rewards);
@@ -49,7 +52,7 @@ export default Ember.Controller.extend({
             model.pushObject(
               FilterRule.create({
                 group: rule.get("group.name"),
-                rewards: rewards
+                rewards: rewards,
               })
             );
           }
@@ -63,10 +66,12 @@ export default Ember.Controller.extend({
 
       ajax("/patreon/list.json", {
         method: "DELETE",
-        data: rule.getProperties("group_id")
+        data: rule.getProperties("group_id"),
       })
         .then(() => {
-          var obj = model.find(x => x.get("group_id") === rule.get("group_id"));
+          var obj = model.find(
+            (x) => x.get("group_id") === rule.get("group_id")
+          );
           model.removeObject(obj);
         })
         .catch(popupAjaxError);
@@ -88,6 +93,6 @@ export default Ember.Controller.extend({
           window.location.pathname = getURL("/admin/plugins/patreon");
         });
       });
-    }
-  }
+    },
+  },
 });
diff --git a/assets/javascripts/discourse/initializers/patreon.js.es6 b/assets/javascripts/discourse/initializers/patreon.js.es6
index e57c73e..312dda4 100644
--- a/assets/javascripts/discourse/initializers/patreon.js.es6
+++ b/assets/javascripts/discourse/initializers/patreon.js.es6
@@ -6,7 +6,7 @@ const cookieName = "PatreonDonationPromptClosed";
 function initWithApi(api) {
   const currentUser = api.getCurrentUser();
 
-  api.onAppEvent("page:topic-loaded", topic => {
+  api.onAppEvent("page:topic-loaded", (topic) => {
     if (!topic) {
       return;
     }
@@ -31,7 +31,7 @@ function initWithApi(api) {
     },
 
     setupComponent(_args, component) {
-      component.didInsertElement = function() {
+      component.didInsertElement = function () {
         const showDonationPrompt =
           this.siteSettings.patreon_enabled &&
           this.siteSettings.patreon_donation_prompt_enabled &&
@@ -48,14 +48,12 @@ function initWithApi(api) {
     actions: {
       close() {
         // hide the donation prompt for 30 days
-        const expires = moment()
-          .add(30, "d")
-          .toDate();
+        const expires = moment().add(30, "d").toDate();
         $.cookie(cookieName, "t", { expires });
 
         this.$().fadeOut(700);
-      }
-    }
+      },
+    },
   });
 }
 
@@ -63,5 +61,5 @@ export default {
   name: "patreon",
   initialize() {
     withPluginApi("0.8", initWithApi);
-  }
+  },
 };
diff --git a/assets/javascripts/discourse/models/filter-rule.js.es6 b/assets/javascripts/discourse/models/filter-rule.js.es6
index 6846e0f..71b0825 100644
--- a/assets/javascripts/discourse/models/filter-rule.js.es6
+++ b/assets/javascripts/discourse/models/filter-rule.js.es6
@@ -2,5 +2,5 @@ import RestModel from "discourse/models/rest";
 
 export default RestModel.extend({
   group_id: -1,
-  reward_list: ""
+  reward_list: "",
 });

[... diff too long, it was truncated ...]

GitHub sha: 37e70251

This commit appears in #37 which was merged by jjaffeux.