orionsoft-react-scripts
Version:
Orionsoft Configuration and scripts for Create React App.
48 lines (41 loc) • 1.31 kB
JavaScript
/**
* @fileoverview Rule to check for tabs inside a file
* @author Gyandeep Singh
*/
;
//------------------------------------------------------------------------------
// 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."
);
}
});
}
};
}
};