Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upRequire Dot Notation Whenever Possible (dot-notation) #1344
Comments
This comment has been minimized.
This comment has been minimized.
|
Generally positive, although I prefer using the |
This comment has been minimized.
This comment has been minimized.
Couldn’t we solve this by using a utility such as And couldn’t we use a similar wrapper solution in other cases someone needs I suspect minor efficiency cost should not prove to be a real issue given the improved readability in what seem to be exceptional cases. |
This comment has been minimized.
This comment has been minimized.
|
I would love to see this considered for Standard 14 (#1321). |
feross
transferred this issue from standard/eslint-config-standard
Jul 28, 2019
This comment has been minimized.
This comment has been minimized.
|
Modest ecosystem impact:
And they're all cases where dot notation would be a bit better. Since the rule is automatically fixable, I think this rule is a go for |
feross
added
accepted
enhancement
labels
Jul 28, 2019
feross
added this to the standard v14 milestone
Jul 28, 2019
feross
added a commit
to standard/standard-packages
that referenced
this issue
Jul 28, 2019
feross
changed the title
Favor dot notation for property access
Require Dot Notation Whenever Possible (dot-notation)
Jul 28, 2019
This comment has been minimized.
This comment has been minimized.
|
After fixing repos I control, only 3 ecosystem repos fail.
|
feross
closed this
in
5e3161b
Jul 28, 2019
This comment has been minimized.
This comment has been minimized.
|
Funnily enough, it's exactly the case I described in my first comment and I actually think that the code will be a bit uglier Oh well, it's for the greater good |
This comment has been minimized.
This comment has been minimized.
|
Yeah, I actually agree with you. There's a small amount information that it feels like we're losing by always using dot notation. I noticed when I went through all the failing cases that I was using Happy to reconsider this if we end up not liking it. But it's only required changes in a few places so I'm guessing it won't be that big of a deal :) |
This comment has been minimized.
This comment has been minimized.
I think this is what does it for me. JavaScript doesn't really have a distinction between objects with specific properties, and just general maps/dictionaries (or, it has now It would be awesome if it could somehow be enforced that |
This comment has been minimized.
This comment has been minimized.
vweevers
commented
Aug 23, 2019
In the case of headers['user-agent'] = 'example'
headers['connection'] = 'keep-alive'
headers['accept-encoding'] = 'gzip, deflate, identity'Over: headers['user-agent'] = 'example'
headers.connection = 'keep-alive'
headers['accept-encoding'] = 'gzip, deflate, identity' |
This comment has been minimized.
This comment has been minimized.
|
Perhaps I would write that way, as well, @vweevers. If you could contribute that as an option to the ESLint rule, then we'd have the option to consider it. I personally feel that it would be better to choose a not-always pleasing style over not choosing. |
julien-f commentedFeb 18, 2019
Hey folks, what do you think about enabling the dot-notation rule?