DEV: apply coding standards (#9)

DEV: apply coding standards (#9)

diff --git a/.eslintrc b/.eslintrc
index 86ed71b..7898fbf 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,93 +1,3 @@
 {
-  "env": {
-    "jasmine": true,
-    "node": true,
-    "mocha": true,
-    "browser": true,
-    "builtin": true
-  },
-  "parserOptions": {
-    "ecmaVersion": 7,
-    "sourceType": "module"
-  },
-  "globals": {
-    "Ember": true,
-    "jQuery": true,
-    "$": true,
-    "QUnit": true,
-    "RSVP": true,
-    "Discourse": true,
-    "Handlebars": true,
-    "I18n": true,
-    "bootbox": true,
-    "moduleFor": true,
-    "moduleForComponent": true,
-    "Pretender": true,
-    "sandbox": true,
-    "controllerFor": true,
-    "test": 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,
-    "asyncTestDiscourse": true,
-    "fixture": true,
-    "find": true,
-    "sinon": true,
-    "moment": true,
-    "_": true,
-    "alert": 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-inner-declarations": 2,
-    "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"],
-    "no-mixed-spaces-and-tabs": 2,
-    "no-trailing-spaces": 2
-  },
-  "parser": "babel-eslint"
+  "extends": "eslint-config-discourse"
 }
diff --git a/.gitignore b/.gitignore
index e69de29..2d83702 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1,3 @@
+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/initializers/initialize-discourse-prometheus-alert-receiver.js.es6 b/assets/javascripts/discourse/initializers/initialize-discourse-prometheus-alert-receiver.js.es6
index 0ca4dfe..a701c77 100644
--- a/assets/javascripts/discourse/initializers/initialize-discourse-prometheus-alert-receiver.js.es6
+++ b/assets/javascripts/discourse/initializers/initialize-discourse-prometheus-alert-receiver.js.es6
@@ -5,7 +5,7 @@ export default {
   name: "discourse-prometheus-alert-receiver",
 
   initialize() {
-    withPluginApi("0.8.9", api => {
+    withPluginApi("0.8.9", (api) => {
       const messageBus = api.container.lookup("message-bus:main");
       if (!messageBus) {
         return;
@@ -13,16 +13,16 @@ export default {
 
       const site = api.container.lookup("site:main");
 
-      messageBus.subscribe("/alert-receiver", payload => {
+      messageBus.subscribe("/alert-receiver", (payload) => {
         site.set("firing_alerts_count", payload.firing_alerts_count);
       });
 
-      api.decorateWidget("post-contents:after-cooked", dec => {
+      api.decorateWidget("post-contents:after-cooked", (dec) => {
         if (dec.attrs.post_number === 1) {
           const postModel = dec.getModel();
           if (postModel && postModel.topic.alert_data) {
             return dec.attach("alert-receiver-data", {
-              alerts: postModel.topic.alert_data
+              alerts: postModel.topic.alert_data,
             });
           }
         }
@@ -33,7 +33,7 @@ export default {
         _alertDataChanged() {
           if (this.model && this.model.alert_data && this.model.postStream) {
             this.appEvents.trigger("post-stream:refresh", {
-              id: this.model.postStream.firstPostId
+              id: this.model.postStream.firstPostId,
             });
           }
         },
@@ -51,8 +51,8 @@ export default {
         willDestroy() {
           this._super(...arguments);
           this.appEvents.off("alerts:quote-alert", this, "_quoteAlert");
-        }
+        },
       });
     });
-  }
+  },
 };
diff --git a/assets/javascripts/discourse/widgets/alert-receiver.js.es6 b/assets/javascripts/discourse/widgets/alert-receiver.js.es6
index cf69850..85b957c 100644
--- a/assets/javascripts/discourse/widgets/alert-receiver.js.es6
+++ b/assets/javascripts/discourse/widgets/alert-receiver.js.es6
@@ -7,7 +7,7 @@ import { h } from "virtual-dom";
 const STATUS_NAMES = ["firing", "suppressed", "stale", "resolved"];
 const STATUS_EMOJIS = {
   firing: "fire",
-  suppressed: "shushing_face"
+  suppressed: "shushing_face",
 };
 
 const COLLAPSE_THRESHOLD = 30;
@@ -22,7 +22,7 @@ createWidget("alert-receiver-data", {
     const groupedByStatus = {};
     const statusCounts = {};
 
-    attrs.alerts.forEach(a => {
+    attrs.alerts.forEach((a) => {
       if (!groupedByStatus[a.status]) {
         groupedByStatus[a.status] = {};
         statusCounts[a.status] = 0;
@@ -39,7 +39,7 @@ createWidget("alert-receiver-data", {
 
     let collapsed = false;
 
-    STATUS_NAMES.forEach(statusName => {
+    STATUS_NAMES.forEach((statusName) => {
       const groupedByDc = groupedByStatus[statusName];
       if (!groupedByDc) return;
 
@@ -61,7 +61,7 @@ createWidget("alert-receiver-data", {
           alerts: alerts,
           heading: dcName,
           headingLink: alerts[0].external_url,
-          defaultCollapsed: collapsed
+          defaultCollapsed: collapsed,
         });
 
         content.push(table);
@@ -69,7 +69,7 @@ createWidget("alert-receiver-data", {
     });
 
     return content;
-  }
+  },
 });
 
 createWidget("alert-receiver-date", {
@@ -104,7 +104,7 @@ createWidget("alert-receiver-date", {
     if ($().applyLocalDates) $(dateElement).applyLocalDates();
 
     return new RawHtml({ html: dateElement.outerHTML });
-  }
+  },
 });
 
 createWidget("alert-receiver-date-range", {
@@ -127,13 +127,13 @@ createWidget("alert-receiver-date-range", {
       content.push(
         this.attach("alert-receiver-date", {
           timestamp: attrs.endsAt,
-          hideDate
+          hideDate,
         })
       );
     }
 
     return content;
-  }
+  },
 });
 
 createWidget("alert-receiver-row", {
@@ -143,7 +143,7 @@ createWidget("alert-receiver-row", {
     return {
       logsUrl: this.buildLogsUrl(attrs),
       graphUrl: this.buildGraphUrl(attrs),
-      grafanaUrl: this.buildGrafanaUrl(attrs)
+      grafanaUrl: this.buildGrafanaUrl(attrs),
     };
   },
 
@@ -235,7 +235,7 @@ createWidget("alert-receiver-row", {
         {{/if}}
       </div>
     </td>
-  `
+  `,
 });
 
 createWidget("alert-receiver-external-link", {
@@ -245,7 +245,7 @@ createWidget("alert-receiver-external-link", {
     <a target='_blank' href={{attrs.link}} title={{i18n "prom_alert_receiver.actions.alertmanager"}}>
       {{d-icon 'external-link-alt'}}
     </a>
-  `
+  `,
 });
 
 createWidget("alert-receiver-collapse-toggle", {
@@ -263,7 +263,7 @@ createWidget("alert-receiver-collapse-toggle", {
 
   transform(attrs) {
     return {
-      icon: attrs.collapsed ? "caret-right" : "caret-down"
+      icon: attrs.collapsed ? "caret-right" : "caret-down",
     };
   },
 
@@ -276,23 +276,23 @@ createWidget("alert-receiver-collapse-toggle", {
       ({{attrs.count}})
     </div>

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

GitHub sha: fd5f7be6

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