Skip to content

Object whitespace rule#9332

Merged
weswigham merged 4 commits into
masterfrom
object-whitespace-rule
Jun 23, 2016
Merged

Object whitespace rule#9332
weswigham merged 4 commits into
masterfrom
object-whitespace-rule

Conversation

@weswigham
Copy link
Copy Markdown
Member

As discussed at the end of #9068 - this codifies our object literal whitespace lint rules.

If an object literal is on a single line, it must have a space at the beginning and at the end.

@weswigham
Copy link
Copy Markdown
Member Author

@sandersn @rbuckton Would you two like to give this a look?

if (node.kind === ts.SyntaxKind.ObjectLiteralExpression) {
const literal = node as ts.ObjectLiteralExpression;
const text = literal.getText();
if (text.match(/^{[^\n]+}$/g)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you check for exactly one instead of at least one?

@weswigham
Copy link
Copy Markdown
Member Author

Now looks for exactly one space.

}
}

class ObjectLiteralSpaceWalker extends Lint.RuleWalker {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe should be SkyWalker instead of SpaceWalker?

@sandersn
Copy link
Copy Markdown
Member

👍

@weswigham weswigham merged commit 9cd1f78 into master Jun 23, 2016
@weswigham weswigham deleted the object-whitespace-rule branch August 11, 2016 01:43
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants