]> git.proxmox.com Git - pve-eslint.git/blobdiff - eslint/lib/rules/no-mixed-spaces-and-tabs.js
import and build new upstream release 7.2.0
[pve-eslint.git] / eslint / lib / rules / no-mixed-spaces-and-tabs.js
index 16c2bd4122e8511bdde6e499af2b1688113eab61..287cbda03daf5a6795aedc74c74e883512765ce8 100644 (file)
@@ -67,7 +67,7 @@ module.exports = {
                  * or the reverse before non-tab/-space
                  * characters begin.
                  */
-                let regex = /^(?=[\t ]*(\t | \t))/u;
+                let regex = /^(?=( +|\t+))\1(?:\t| )/u;
 
                 if (smartTabs) {
 
@@ -75,19 +75,27 @@ module.exports = {
                      * At least one space followed by a tab
                      * before non-tab/-space characters begin.
                      */
-                    regex = /^(?=[\t ]* \t)/u;
+                    regex = /^(?=(\t*))\1(?=( +))\2\t/u;
                 }
 
                 lines.forEach((line, i) => {
                     const match = regex.exec(line);
 
                     if (match) {
-                        const lineNumber = i + 1,
-                            column = match.index + 1,
-                            loc = { line: lineNumber, column };
+                        const lineNumber = i + 1;
+                        const loc = {
+                            start: {
+                                line: lineNumber,
+                                column: match[0].length - 2
+                            },
+                            end: {
+                                line: lineNumber,
+                                column: match[0].length
+                            }
+                        };
 
                         if (!ignoredCommentLines.has(lineNumber)) {
-                            const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc));
+                            const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc.start));
 
                             if (!(containingNode && ["Literal", "TemplateElement"].includes(containingNode.type))) {
                                 context.report({