Bug 1303871 - Lines generated by xbl preprocessor can cause various rule incompatibilities. r?miker draft
authorPhilipp Kewisch <mozilla@kewis.ch>
Tue, 20 Sep 2016 11:34:40 +0200
changeset 423540 6f05ac213ec9f2a40e546b27587b16413fb5065c
parent 423389 1c0b369b2df5b9dbdcde375e5fc729b090119ad8
child 533481 2db637e1e4f66ab0e6b4cd479cebac0df5742e93
push id31937
push usermozilla@kewis.ch
push dateTue, 11 Oct 2016 11:22:20 +0000
reviewersmiker
bugs1303871
milestone52.0a1
Bug 1303871 - Lines generated by xbl preprocessor can cause various rule incompatibilities. r?miker MozReview-Commit-ID: 5x63vEptBIn
tools/lint/eslint/eslint-plugin-mozilla/lib/processors/xbl-bindings.js
tools/lint/eslint/eslint-plugin-mozilla/package.json
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/xbl-bindings.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/xbl-bindings.js
@@ -103,34 +103,34 @@ XMLParser.prototype = {
     this._currentNode.comments.push(text);
   }
 }
 
 // -----------------------------------------------------------------------------
 // Processor Definition
 // -----------------------------------------------------------------------------
 
-const INDENT_LEVEL = 2;
+const INDENT_LEVEL = 4;
 
 function indent(count) {
   return " ".repeat(count * INDENT_LEVEL);
 }
 
 // Stores any XML parse error
 let xmlParseError = null;
 
 // Stores the lines of JS code generated from the XBL
 let scriptLines = [];
 // Stores a map from the synthetic line number to the real line number
 // and column offset.
 let lineMap = [];
 
-function addSyntheticLine(line, linePos) {
+function addSyntheticLine(line, linePos, eslintDisable=true) {
   lineMap[scriptLines.length] = { line: linePos, offset: null };
-  scriptLines.push(line);
+  scriptLines.push(line + (eslintDisable ? " // eslint-disable-line" : ""))
 }
 
 /**
  * Adds generated lines from an XBL node to the script to be passed back to eslint.
  */
 function addNodeLines(node, reindent) {
   let lines = node.textContent.split("\n");
   let startLine = node.textLine;
@@ -212,21 +212,21 @@ module.exports = {
     }
 
     let bindings = document.children[0];
     if (bindings.local != "bindings" || bindings.namespace != NS_XBL) {
       return [];
     }
 
     for (let comment of document.comments) {
-      addSyntheticLine(`/*`, 0);
+      addSyntheticLine(`/*`, 0, false);
       for (let line of comment.split("\n")) {
-        addSyntheticLine(`${line.trim()}`, 0);
+        addSyntheticLine(`${line.trim()}`, 0, false);
       }
-      addSyntheticLine(`*/`, 0);
+      addSyntheticLine(`*/`, 0, false);
     }
 
     addSyntheticLine(`this.bindings = {`, bindings.textLine);
 
     for (let binding of bindings.children) {
       if (binding.local != "binding" || binding.namespace != NS_XBL) {
         continue;
       }
--- a/tools/lint/eslint/eslint-plugin-mozilla/package.json
+++ b/tools/lint/eslint/eslint-plugin-mozilla/package.json
@@ -1,11 +1,11 @@
 {
   "name": "eslint-plugin-mozilla",
-  "version": "0.2.2",
+  "version": "0.2.3",
   "description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
   "keywords": [
     "eslint",
     "eslintplugin",
     "eslint-plugin",
     "mozilla",
     "firefox"
   ],