-
Notifications
You must be signed in to change notification settings - Fork 35
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
base: develop
Are you sure you want to change the base?
Fix issue with linters that prefer single quotes #57
Conversation
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.
@@ -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, '\'') |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Activity: atticoos/pull/57#issuecomment-245965088 To preserve backwards compatibility, the single-quote feature has been added as an option. Fully tested, tests pass.
Fully tested, singleQuotes as a feature, let me know your thoughts. |
The README has been update to include the new singleQuote feature.
Any feedback? |
@ajwhite Any idea when this can get merged and released? |
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.