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

Fix issue with linters that prefer single quotes #57

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

seyDoggy
Copy link

@seyDoggy seyDoggy commented Sep 9, 2016

Activity: /issues/12

I ran into this issue as well where linters (Sonarlint in my case) take
exception to the double-quotes output. I've changed the template and
test files to use single-quotes and am using .replace on the
template.constant.value to replace double-quotes with single-quotes.

Tests pass.

Activity: atticoos/issues/12

I ran into [this issue](atticoos/issues/12) as well where linters (Sonarlint in my case) take
exception to the double-quotes output. I've changed the template and
test files to use single-quotes and am using .replace on the
template.constant.value to replace double-quotes with single-quotes.

Tests pass.
@coveralls
Copy link

coveralls commented Sep 9, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 17490cb on seyDoggy:Values-of-constants-wrapped-in-double-quotes-breaks-JSHint into b6e1c45 on ajwhite:develop.

@@ -104,7 +104,7 @@ function gulpNgConfig (moduleName, configuration) {
_.each(jsonObj, function (value, key) {
constants.push({
name: key,
value: JSON.stringify(value, null, spaces)
value: JSON.stringify(value, null, spaces).replace(/"/g, '\'')
Copy link
Owner

@atticoos atticoos Sep 9, 2016

Choose a reason for hiding this comment

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

What if some of the data contains quotes?

For example:

var input = {
  text: 'The person said "Hello" loudly'
}

JSON.stringify(input)
// '{"text":"The person said \"Hello\" loudly"}'

JSON.stringify(input).replace(/"/g, '\'')
// '{\'text\':\'The person said \'Hello\' loudly\'}'

That would feel like unexpected behavior to modify the contents

Copy link
Author

Choose a reason for hiding this comment

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

While this is entirely valid and reasonable safety ought to be a concern, this seems a bit contrived for a "config" module. It's easy enough to fix though, for those edge cases, so I will account for this.

Copy link
Owner

Choose a reason for hiding this comment

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

Totally - however it is a third party dependency for everyone - so we can't manipulate any inputs we don't control or it can lead to unexpected behavior.

Activity: atticoos/pull/57#issuecomment-245965088

To ensure that edge cases are covered with regards to escaped double
quotes, I've added some checks to replace those with doubles while
replacing the rest with singles.
@coveralls
Copy link

coveralls commented Sep 10, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling e0da517 on seyDoggy:Values-of-constants-wrapped-in-double-quotes-breaks-JSHint into b6e1c45 on ajwhite:develop.

Activity: atticoos/pull/57#issuecomment-245965088

To preserve backwards compatibility, the single-quote feature has been
added as an option.

Fully tested, tests pass.
@coveralls
Copy link

coveralls commented Sep 11, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 88bd010 on seyDoggy:Values-of-constants-wrapped-in-double-quotes-breaks-JSHint into b6e1c45 on ajwhite:develop.

@seyDoggy
Copy link
Author

Fully tested, singleQuotes as a feature, let me know your thoughts.

The README has been update to include the new singleQuote feature.
@coveralls
Copy link

coveralls commented Sep 12, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 8fc5073 on seyDoggy:Values-of-constants-wrapped-in-double-quotes-breaks-JSHint into b6e1c45 on ajwhite:develop.

@seyDoggy
Copy link
Author

Any feedback?

@uatuko
Copy link

uatuko commented Oct 5, 2016

@ajwhite Any idea when this can get merged and released?

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.

4 participants