summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/tools/eslint-plugin-gpuweb-cts/trailing-space-anywhere.js
blob: 811b379ff648a296910bac1f9e731919997bd947 (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
module.exports = {
  meta: {
    type: 'suggestion',
    docs: {
      description: 'Trailing spaces are not allowed, even in multiline strings, due to WPT lint rules.',
    },
    schema: [],
  },
  create: context => {
    const sourceCode = context.getSourceCode();

    return {
      Program: node => {
        for (let lineIdx = 0; lineIdx < sourceCode.lines.length; ++lineIdx) {
          const line = sourceCode.lines[lineIdx];
          const match = /\s+$/.exec(line);
          if (match) {
            context.report({
              node,
              loc: { line: lineIdx + 1, column: match.index },
              message: 'Trailing spaces not allowed.',
              // fixer is hard to implement, so not implemented.
            });
          }
        }
      },
    };
  },
};