xojs/xo

suggestion / help: min-lines of a file

MatanGbr opened this issue · 1 comments

I know it sounds weirds, but I believe there is no place for really short JavaScript file, and that these tiny bits of code should be combined with other tiny bits of code to make a file of at least 5 lines.
I have tried to play with ESLint's default max-lines without much success (it always broke all the other problems from showing) so I decided to start with a very basic version, but with no luck yet:

'use strict'
module.exports = {
  meta: {
    type: 'suggestion',
    schema: [],
  },
  create(context) {
    const sourceCode = context.getSourceCode();
    let lines = sourceCode.lines.map((text, i) => ({
      lineNumber: i + 1,
      text
    }));
    return {
      "Program:exit"() {
        if (lines.length < 5) {
          context.report({
            node: node.property,
            message: 'File should have more lines',
          })
        }
      },
    }
  },
}

Any help would be welcomed!