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

feat(import-destructuring-spacing): add fixer #595

Merged
merged 1 commit into from May 5, 2018
Merged

feat(import-destructuring-spacing): add fixer #595

merged 1 commit into from May 5, 2018

Conversation

rafaelss95
Copy link
Collaborator

This adds a fixer for import-destructuring-spacing rule and adds a bunch of new tests.


it('should succeed when there is more than one space left and right', () => {
const source = `
import { Foo, Bar, FooBar } from './foo';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should not we throw an error in this case ?

@rafaelss95
Copy link
Collaborator Author

rafaelss95 commented May 2, 2018

Well, that’s how the rule works actually. It just enforces that you must leave whitespaces inside of the import statements curly braces, but not the quantity.

@rafaelss95
Copy link
Collaborator Author

So, @wKoza @mgechev, should the current behavior be changed to report failures in case of multiple spaces?

@mgechev
Copy link
Owner

mgechev commented May 3, 2018

@rafaelss95 yes, it should be a single space.

@rafaelss95
Copy link
Collaborator Author

rafaelss95 commented May 4, 2018

Done.


Not related to this PR, but don't you think it's a good idea to add coveralls to this repo? It seems to be a really great tool to ensure that we cover more specifics parts of a rule, for example. Also, it can be integrated with CI.

@mgechev
Copy link
Owner

mgechev commented May 4, 2018

@rafaelss95 this sounds good to me! @wKoza what are your thoughts?

typescriptOnly: true
};

public static FAILURE_STRING = "You need to leave whitespaces inside of the import statement's curly braces";
static readonly FAILURE_STRING = "Import statements' curly braces must be spaced exactly by a space to the right and a space to the left";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had to change the failure message to reflect the new behavior. What do you guys think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

statements' => statement's ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@wKoza
Copy link
Collaborator

wKoza commented May 4, 2018

Just last one comment and It's ok for me.

@intellix
Copy link

intellix commented May 4, 2018

Just out of curiosity since I didn't see a test for it, what would happen with these (multiple spaces in middle):

import { A,  B, C } from 'somewhere';
import { A, B , C } from 'somewhere';

@rafaelss95
Copy link
Collaborator Author

@intellix Currently, the rule only cares about spaces relative to curly braces.

Copy link
Collaborator

@wKoza wKoza left a comment

Choose a reason for hiding this comment

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

LGTM ! thanks @rafaelss95 !

@wKoza wKoza merged commit 2acc27b into mgechev:master May 5, 2018
@rafaelss95 rafaelss95 deleted the feat-has-fixer-import-destructuring-spacing branch May 5, 2018 17:41
@mgechev mgechev added this to the 4.4.0 - Ken Thompson milestone Jun 24, 2018
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.

None yet

4 participants