Have 'func-name-matching' ignore defineProperty function values by default
See original GitHub issueWhat rule do you want to change?
func-name-matching
Does this change cause the rule to produce more or fewer warnings?
Fewer.
How will the change be implemented? (New option, new default behavior, etc.)?
New default behavior where we allow { value }
property descriptor a different name than value
.
Please provide some example code that this change will affect:
var model = {};
Object.defineProperty(model, 'key', {
value: function key() {
//
}
});
console.log(model.key.name); // logs 'key'
What does the rule currently do for this code?
Function name
key
should match property namevalue
What will the rule do after it’s changed?
No error.
Issue Analytics
- State:
- Created 7 years ago
- Comments:25 (25 by maintainers)
Top Results From Across the Web
func-name-matching - ESLint - Pluggable JavaScript Linter
This rule requires function names to match the name of the variable or property to which they are assigned. The rule will ignore...
Read more >Why is it possible to omit default values in overridden member ...
Declare in both, allow subtype to override the default in the supertype. ... function is not allowed to specify default values for its...
Read more >Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
Read more >func-name-matching - Rules - ESLint中文文档
要求函数名与赋值给它们的变量名或属性名相匹配(func-name-matching). Rule Details. This rule requires function names to match the name of the variable ...
Read more >Understanding Default Parameters in JavaScript - DigitalOcean
These allow developers to initialize a function with default values if the arguments are not supplied to the function call.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @ljharb, your point is well taken.
Let’s step back a bit and just follow our process. If the team champions and endorses not only the standard property-descriptor functions, but also user-configurable ones, then that’s what we’ll implement. If the team champions and endorses just the standard property-descriptor functions, then we’ll implement that instead and we can re-evaluate later if we get more demand for customizability. (And until that point, @ljharb can certainly create a custom rule for his use case.)
I’m 👍 for the standard property descriptor functions for sure-- it should be fairly easy to do. I’m not outright opposed to customizations, but I’m not yet convinced we have enough demand from the community just yet.
Sounds reasonable to me.
This is same as
The function
foo
is the value ofmodel.foo
. Also,function value
in the stacktrace is not helpful to developers.value
does not express what the function is. It should befoo
. So I think the rule should enforce the name tofoo
rather thanvalue
.