tabs-anywhere.js (859B)
1 module.exports = { 2 meta: { 3 type: 'suggestion', 4 docs: { 5 description: 6 'Indentation tabs are not allowed, even in multiline strings, due to WPT lint rules. This rule simply disallows tabs anywhere.', 7 }, 8 schema: [], 9 }, 10 create: context => { 11 const sourceCode = context.getSourceCode(); 12 13 return { 14 Program: node => { 15 for (let lineIdx = 0; lineIdx < sourceCode.lines.length; ++lineIdx) { 16 const line = sourceCode.lines[lineIdx]; 17 const matches = line.matchAll(/\t/g); 18 for (const match of matches) { 19 context.report({ 20 node, 21 loc: { line: lineIdx + 1, column: match.index }, 22 message: 'Tabs not allowed.', 23 // fixer is hard to implement, so not implemented. 24 }); 25 } 26 } 27 }, 28 }; 29 }, 30 };