2 * @fileoverview Rule to check for tabs inside a file
3 * @author Gyandeep Singh
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const tabRegex = /\t+/gu;
13 const anyNonWhitespaceRegex = /\S/u;
15 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
24 description: "disallow all tabs",
25 category: "Stylistic Issues",
27 url: "https://eslint.org/docs/rules/no-tabs"
32 allowIndentationTabs: {
37 additionalProperties: false
42 const sourceCode = context.getSourceCode();
43 const allowIndentationTabs = context.options && context.options[0] && context.options[0].allowIndentationTabs;
47 sourceCode.getLines().forEach((line, index) => {
50 while ((match = tabRegex.exec(line)) !== null) {
51 if (allowIndentationTabs && !anyNonWhitespaceRegex.test(line.slice(0, match.index))) {
64 column: match.index + match[0].length
67 message: "Unexpected tab character."