Sha256: 8aeeb5bae183cf34f748a4223bb9a67a1f3687c7085668e85c85ff64d331c655
Contents?: true
Size: 1.97 KB
Versions: 2
Compression:
Stored size: 1.97 KB
Contents
/** * @fileoverview Disallow mixed spaces and tabs for indentation * @author Jary Niebur * @copyright 2014 Nicholas C. Zakas. All rights reserved. * @copyright 2014 Jary Niebur. All rights reserved. */ "use strict"; //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = function(context) { var smartTabs; switch (context.options[0]) { case true: // Support old syntax, maybe add deprecation warning here case "smart-tabs": smartTabs = true; break; default: smartTabs = false; } var COMMENT_START = /^\s*\/\*/, MAYBE_COMMENT = /^\s*\*/; //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- return { "Program": function(node) { /* * At least one space followed by a tab * or the reverse before non-tab/-space * characters begin. */ var regex = /^(?=[\t ]*(\t | \t))/, match, lines = context.getSourceLines(); if (smartTabs) { /* * At least one space followed by a tab * before non-tab/-space characters begin. */ regex = /^(?=[\t ]* \t)/; } lines.forEach(function(line, i) { match = regex.exec(line); if (match) { if (!MAYBE_COMMENT.test(line) && !COMMENT_START.test(lines[i - 1])) { context.report(node, { line: i + 1, column: match.index + 1 }, "Mixed spaces and tabs."); } } }); } }; }; module.exports.schema = [ { "enum": ["smart-tabs", true, false] } ];
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
eslint_node_modules-1.6.0.1 | vendor/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js |
eslint_node_modules-1.6.0 | vendor/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js |