summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/lib/rules/no-tabs.js
blob: 08a8fa5b758b4fded7d575b606b31f2b2bbbe13d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
 * @fileoverview Rule to check for tabs inside a file
 * @author Gyandeep Singh
 */

"use strict";

//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
const regex = /\t/;

//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------

module.exports = {
    meta: {
        docs: {
            description: "disallow all tabs",
            category: "Stylistic Issues",
            recommended: false,
            url: "https://eslint.org/docs/rules/no-tabs"
        },
        schema: []
    },

    create(context) {
        return {
            Program(node) {
                context.getSourceCode().getLines().forEach((line, index) => {
                    const match = regex.exec(line);

                    if (match) {
                        context.report({
                            node,
                            loc: {
                                line: index + 1,
                                column: match.index + 1
                            },
                            message: "Unexpected tab character."
                        });
                    }
                });
            }
        };
    }
};