Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

No spaces between property access #4565

Closed
ghost opened this issue Mar 5, 2019 · 1 comment
Closed

No spaces between property access #4565

ghost opened this issue Mar 5, 2019 · 1 comment
Labels
Formatting rule Relates to a rule which enforces code formatting and likely overlaps with prettier Resolution: Declined Type: Rule Suggestion

Comments

@ghost
Copy link

ghost commented Mar 5, 2019

Rule Suggestion

I suggest a rule which disallows spaces or tabs between property accesses. Newlines would still be allowed.
I imagine a similar behaviour to the spaces before and after arithmetic symbols.

Is your rule for a general problem or is it specific to your development style?
General problem - . and , look very similar so a bug might easily be overlooked.

What does your suggested rule do?
Inform the user about the whitespace.

List several examples where your rule could be used
Example1

sampleFunction(some.property. another.property)

vs

sampleFunction(some.property, another.property)

Example2

const a, b. c = something

vs

const a, b, c = something

Example3

sampleFunction(some
       .property, something.else)

Example4

sampleFunction(some.
       property, something.else)

In example 1 & 2 the user would be notified about the space between the property accesses.
In example 3 & 4 the rule would not apply as newline between property access would be allowed.

Additional context
This rule is intended to warn the user about a potential access to undefined during runtime.

@JoshuaKGoldberg JoshuaKGoldberg added the Formatting rule Relates to a rule which enforces code formatting and likely overlaps with prettier label Mar 10, 2019
@JoshuaKGoldberg
Copy link
Contributor

Hi @c-niederer, thanks for the suggestion! Per #4534, TSLint is avoiding adding new code formatting rules to core. If you want to enforce this specific check, it can live happily in a custom rule set outside this repo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Formatting rule Relates to a rule which enforces code formatting and likely overlaps with prettier Resolution: Declined Type: Rule Suggestion
Projects
None yet
Development

No branches or pull requests

1 participant