trailing-space-anywhere.js (804B)
1 module.exports = { 2 meta: { 3 type: 'suggestion', 4 docs: { 5 description: 6 'Trailing spaces are not allowed, even in multiline strings, due to WPT lint rules.', 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 match = /\s+$/.exec(line); 18 if (match) { 19 context.report({ 20 node, 21 loc: { line: lineIdx + 1, column: match.index }, 22 message: 'Trailing spaces not allowed.', 23 // fixer is hard to implement, so not implemented. 24 }); 25 } 26 } 27 }, 28 }; 29 }, 30 };