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.

[no-setter-return] Add option to ignore `set: () => value`

See original GitHub issue

What rule do you want to change?
no-setter-return

Does this change cause the rule to produce more or fewer warnings?
Fewer warnings if enabled.

How will the change be implemented? (New option, new default behaviour, etc.)?
Adding an object as an optional second parameter which supports the option ignoreExpressions (or something similarly-named):

{
	"no-setter-return": [
		"error",
		{
			"ignoreExpressions": "always | never | ignore" 
		}
	]
}

Please provide some example code that this change will affect:
In the setter function below, the return value is purely implicit, and shouldn’t be held in the same light as an explicit return statement (which is indicative of a refactoring or authoring error):

let foo;
Object.defineProperty(subject, "foo", {
	get: () => foo,
	set: to => foo = to,
});

What does the rule currently do for this code?
Raise an error because an assigned value is implicitly returned by an arrow-function expression.

What will the rule do after it’s changed?
Allow authors to keep their getter/setter pairs terse and nicely-aligned (as illustrated above).

Are you willing to submit a pull request to implement this change?
Yes.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ljharbcommented, Feb 24, 2020

The rule is precisely to block a return value though - in your case, you’re not trying to return anything, so you definitely should be using curly braces.

0reactions
Alhadiscommented, Feb 24, 2020

@ljharb No, the intent was keeping code brief when a return value is meaningless, irrespective of whether somebody’s siphoned a setter out of a property descriptor or not.

I already regret filing this stupid issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to ignore whitespace inside of the value of a ...
I've tried using Javascript.trim() on the JSON data which didn't seem to have any effect. I also can't strip the entire JSON file...
Read more >
Ignore an import set value if the Target is not blank - ServiceNow
Solved: Hi, We have 2 different sources which automatically import into the cmdb_ci_computer table. The issue is that i want one to be...
Read more >
spec: require return values to be explicitly used or ignored (Go ...
Today, if a Go function returns both a value and an error, the user must either assign the error to a variable v,...
Read more >
Setting data ignore to "********" values - L3Harris Geospatial -
I have some imported MODIS images which have ***** as the pixel values (not entirely sure what this is -- NaN? +Inf?) I'd...
Read more >
16.10 - IGNORE QUERY_BAND VALUES - Teradata Database
Defines the set of name-value pairs to ignore if specified in a SET QUERY_BAND statement for all users assigned the profile. When a...
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