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: func-name-matching

See original GitHub issue

From requireMatchingFunctionName.

This rule will enforce function expression names with the variable name (or property name) which is the destination of the assignment.

Options

{
    "func-name-matching": ["error", {"module.exports": "ignore"}]
}
  • module.exports - The setting for module.exports = function foo() {};
    • "ignore" (default) - The function is ignored.
    • "propertyName" - The function’s name should be exports. Original JSCS rule has this option.
    • (in my head, in future) "fileName" - The function’s name should match camelcase of the file name.

Examples:

/*eslint func-name-matching: "error"*/

// ✔ GOOD ---------------------------------------------------------------------
let foo = function foo() {};
foo = function foo() {};
obj.foo = function foo() {};
let obj = {foo: function foo() {}};

// ignore anonymous function expressions.
// it's warned by `func-names` rule.
let foo = function() {};
foo = function() {};
obj.foo = function() {};
let obj = {foo: function() {}};

// ignore it if it's not assigned
foo(function bar() {});

// ignore 'module.exports' by default.
module.exports = function foo() {};


// ✘ BAD ----------------------------------------------------------------------
let foo = function bar() {};
foo = function bar() {};
obj.foo = function bar() {};
let obj = {foo: function bar() {}};

// Should warn simple computed properties from original JSCS rule.
obj["foo"] = function bar() {};
let obj = {["foo"]: function bar() {}};

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:22 (22 by maintainers)

github_iconTop GitHub Comments

3reactions
albertocommented, May 27, 2016

@eslint/eslint-team opinions?

I can champion this one

2reactions
anniecommented, Sep 1, 2016

i can work on this!

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 >
Proposed Rules - GovInfo
Commission has requested comment on a release proposing amendments to its rules under the Securities Act and. Exchange Act that would require.
Read more >
eslint | Yarn - Package Manager
A bug fix in a rule that results in ESLint reporting fewer linting errors. A bug fix to the CLI or core (including...
Read more >
ESLint equivalents in Elm - Elmcraft
228/263 (87%) of the core ESLint rules aren't necessary in Elm: ... func-name-matching ... This is a proposal for elm-format .
Read more >
disallow reassigning exceptions in catch clauses (no-ex-assign)
Since there is no arguments object to offer alternative access to this data, assignment of ... This rule disallows reassigning exceptions in catch...
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