Bug 1303871 - Lines generated by xbl preprocessor can cause various rule incompatibilities. r?miker
MozReview-Commit-ID: 5x63vEptBIn
--- 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"
],