Skip to content
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

Add empty-brace-spaces rule #933

Merged
merged 4 commits into from Dec 12, 2020

Conversation

fisker
Copy link
Collaborator

@fisker fisker commented Dec 10, 2020

I renamed empty-brace-space to empty-brace-spaces, consistent with no-console-spaces rule name.

Fixes #900

@fisker fisker force-pushed the empty-brace-space branch 2 times, most recently from db4003e to a99a89d Compare December 11, 2020 01:15
@fisker fisker changed the title Add empty-brace-space rule Add empty-brace-spaces rule Dec 11, 2020
@fisker fisker force-pushed the empty-brace-space branch 2 times, most recently from fbd2115 to c50ebe7 Compare December 11, 2020 01:26
@fisker fisker marked this pull request as ready for review December 11, 2020 02:06
[MESSAGE_ID]: 'Do not add spaces between braces.'
};

const selector = `:matches(${
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it easier to just do this?

const selector = ":matches(BlockStatement[body.length=0], ClassBody[body.length=0], ObjectExpression[properties.length=0])"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, same. But I prefer current one, it's more readable add diff friendly, if we want add more.

const selector = `:matches(${
	[
		'BlockStatement[body.length=0]',
		'ClassBody[body.length=0]',
+		'ImportNamespaceSpecifier[assertions.length=0]',
		'ObjectExpression[properties.length=0]'
	].join(', ')
})`;

VS

- const selector = ":matches(BlockStatement[body.length=0], ClassBody[body.length=0], ObjectExpression[properties.length=0])"
+ const selector = ":matches(BlockStatement[body.length=0], ClassBody[body.length=0], ImportNamespaceSpecifier[assertions.length=0], ObjectExpression[properties.length=0])"

'function foo(){/* */}',
'foo = {/* */}',
'class Foo {bar() {/* */}}',
'foo = class {bar() {/* */}}'
Copy link
Contributor

Choose a reason for hiding this comment

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

We also need to test for () => {}.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

rules/empty-brace-spaces.js Show resolved Hide resolved
};
};

const schema = [];
Copy link
Owner

Choose a reason for hiding this comment

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

I don't see the point of adding empty schema.

Copy link
Collaborator Author

@fisker fisker Dec 12, 2020

Choose a reason for hiding this comment

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

It's in template, forgot to remove.

BTW: Do you know eslint-plugin-eslint-plugin not working on our rules? And actually this is enforced by it.

Even when there are no options for a rule, a schema should still be defined (as an empty array) so that eslint can validate that no data is passed to the rule.

Copy link
Owner

Choose a reason for hiding this comment

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

Not sure why it didn't catch this. It has caught issues in the past though.

@sindresorhus sindresorhus merged commit c137daa into sindresorhus:master Dec 12, 2020
@fisker fisker deleted the empty-brace-space branch December 12, 2020 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule proposal: empty-brace-space
3 participants