mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
/**
|
|
* @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 tabs in file",
|
|
category: "Stylistic Issues",
|
|
recommended: false
|
|
},
|
|
schema: []
|
|
},
|
|
|
|
create(context) {
|
|
return {
|
|
Program(node) {
|
|
context.getSourceLines().forEach((line, index) => {
|
|
const match = regex.exec(line);
|
|
|
|
if (match) {
|
|
context.report(
|
|
node,
|
|
{
|
|
line: index + 1,
|
|
column: match.index + 1
|
|
},
|
|
"Unexpected tab character."
|
|
);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}
|
|
};
|
|
|