question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule Proposal: lines-around-commonjs-default-exports

See original GitHub issue

From requirePaddingNewLinesBeforeExport and disallowPaddingNewLinesBeforeExport.

This rule will require/disallow blank lines before/after the assignment of module.exports.

{
    "lines-around-commonjs-default-exports": ["error", "always" or "never"],
    // or
    "lines-around-commonjs-default-exports": ["error", {
        "after": "always" or "never",
        "before": "always" or "never"
    }]
}

Valid:

/*eslint lines-around-commonjs-default-exports: ["error", "always"]*/
var a = 2;

module.exports = a;

if (cond) {
   module.exports = a;  // ignore at the first/last of a block. this is warned by padded-blocks
}
/*eslint lines-around-commonjs-default-exports: ["error", "never"]*/
var a = 2;
module.exports = a;
if (cond) {

   module.exports = a;  // ignore at the first/last of a block. this is warned by padded-blocks

}

Invalid:

/*eslint lines-around-commonjs-default-exports: ["error", "always"]*/
var a = 2;
module.exports = a;
foo();
/*eslint lines-around-commonjs-default-exports: ["error", "never"]*/
var a = 2;

module.exports = a;

foo();

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:37 (37 by maintainers)

github_iconTop GitHub Comments

4reactions
TheSaviorcommented, Nov 9, 2016

imo, it’s fine to ship without it being fixable. Adding that in the future should be a reasonable thing to do.

3reactions
mysticateacommented, Sep 16, 2016

If it handles exports, I remove -default from the rule name and imagine options:

{
    "lines-around-commonjs-exports": ["error", "always" or "never"],
    // or
    "lines-around-commonjs-exports": ["error", {
        "module.exports": "always" or "never" or "ignore",
        "exports": "always" or "never" or "ignore"
    }]
    // or
    "lines-around-commonjs-exports": ["error", {
        "module.exports": {
            "after": "always" or "never" or "ignore",
            "before": "always" or "never" or "ignore"
        },
        "exports": {
            "after": "always" or "never" or "ignore",
            "before": "always" or "never" or "ignore"
        }
    }]
}
// Schema
{
    "definitions": {
        "optionValue": {
            "anyOf": [
                {"enum": ["always", "never", "ignore"]},
                {
                    "type": "object",
                    "properties": {
                        "after": {"enum": ["always", "never", "ignore"]},
                        "before": {"enum": ["always", "never", "ignore"]}
                    },
                    "additionalProperties": false
                }
            ]
        }
    },
    "anyOf": [
        {"enum": ["always", "never"]},
        {
            "type": "object",
            "properties": {
                "module.exports": {"$ref": "#/definitions/optionValue"},
                "exports": {"$ref": "#/definitions/optionValue"}
            },
            "additionalProperties": false
        }
    ]
}
// Examples
{
    "lines-around-commonjs-exports": "error",

    "lines-around-commonjs-exports": ["error", "never"],

    "lines-around-commonjs-exports": ["error", {
        "module.exports": {"before": "always"},
        "exports": "ignore"
    }],
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Proposed rule: Order Competition Rule - SEC.gov
proposed rule would prohibit a restricted competition trading center from internally executing certain orders of individual investors at a ...
Read more >
Federal Register/Vol. 87, No. 46/Wednesday, March 9, 2022 ...
ACTION: Proposed rule. SUMMARY: The Securities and Exchange. Commission is proposing new rules under the Investment Advisers Act of.
Read more >
SEC Proposes New Rules on Adviser Oversight of Service ...
The SEC's objective in proposing the outsourcing rule is to establish “minimum and consistent” requirements for the oversight of outsourcing by ...
Read more >
SEC Proposes Amendments to the Shareholder Proposal Rules
The SEC proposed modifying certain bases for excluding shareholder proposals from company proxy statements. If adopted, these amendments are ...
Read more >
SEC proposes rules impacting private funds and advisers
The SEC proposed rules to enhance private fund reporting on Form PF and aimed at enhancing investor protection.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found