]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-tabs.js
1f3921a9a70fd620e614c409335b0071ec244301
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",
26 url
: "https://eslint.org/docs/rules/no-tabs"
31 allowIndentationTabs
: {
36 additionalProperties
: false
40 unexpectedTab
: "Unexpected tab character."
45 const sourceCode
= context
.getSourceCode();
46 const allowIndentationTabs
= context
.options
&& context
.options
[0] && context
.options
[0].allowIndentationTabs
;
50 sourceCode
.getLines().forEach((line
, index
) => {
53 while ((match
= tabRegex
.exec(line
)) !== null) {
54 if (allowIndentationTabs
&& !anyNonWhitespaceRegex
.test(line
.slice(0, match
.index
))) {
67 column
: match
.index
+ match
[0].length
70 messageId
: "unexpectedTab"