]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-tabs.js
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 //------------------------------------------------------------------------------
19 /** @type {import('../shared/types').Rule} */
25 description
: "disallow all tabs",
27 url
: "https://eslint.org/docs/rules/no-tabs"
32 allowIndentationTabs
: {
37 additionalProperties
: false
41 unexpectedTab
: "Unexpected tab character."
46 const sourceCode
= context
.getSourceCode();
47 const allowIndentationTabs
= context
.options
&& context
.options
[0] && context
.options
[0].allowIndentationTabs
;
51 sourceCode
.getLines().forEach((line
, index
) => {
54 while ((match
= tabRegex
.exec(line
)) !== null) {
55 if (allowIndentationTabs
&& !anyNonWhitespaceRegex
.test(line
.slice(0, match
.index
))) {
68 column
: match
.index
+ match
[0].length
71 messageId
: "unexpectedTab"