Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestion / help: min-lines of a file #648

Closed
MatanGbr opened this issue Jan 16, 2022 · 1 comment
Closed

suggestion / help: min-lines of a file #648

MatanGbr opened this issue Jan 16, 2022 · 1 comment

Comments

@MatanGbr
Copy link

MatanGbr commented Jan 16, 2022

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!

@papb
Copy link

papb commented Jan 18, 2022

Duplicate of sindresorhus/eslint-plugin-unicorn#1696

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants