-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require Dot Notation Whenever Possible (dot-notation) #1344
Comments
Generally positive, although I prefer using the |
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. |
I would love to see this considered for Standard 14 (#1321). |
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 |
After fixing repos I control, only 3 ecosystem repos fail.
|
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 🚀 |
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 :) |
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 |
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' |
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. |
crap, now i must override this rule where i use closure compiler in advance mode applies to when i want to keep something that should be exported as it's named function displayNoteTitle(note) {
alert(note['myTitle'])
}
// Store the function in a global property referenced by a string:
window['displayNoteTitle'] = displayNoteTitle didn't like this addition.
Getting more and more tiered of linters that is strict about formatting. hence why i don't use them so much any longer. Actually thinking of removing standard from my package now. |
I generally feel this way too.
In general, this is probably true. The ecosystem impact of this change was low.
I didn't realize that Closure Compiler was still a popular compiler. Does anyone else use Closure and is affected by this change?
You could try doing using eslint-config-standard and eslint-config-prettier (which disables style-related rules) |
I'll re-open this issue for a little while to give it visibility. If others have issues with this rule, we can reconsider it for the next minor version. |
Hey folks, what do you think about enabling the dot-notation rule?
The text was updated successfully, but these errors were encountered: