angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Allow comments in .angular-cli.json

Open mxii opened this issue 9 years ago • 13 comments

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ x ] feature request

Versions.

v1.0.0

Repro steps.

ng s

The log given by the failure.

InvalidConfigError: Parsing .angular-cli.json failed. Please make sure your .angular-cli.json is valid JSON. Error: SyntaxError: Unexpected token / in JSON at position 533

Desired functionality.

Would be really great to be able to put comments to that file. :)

mxii avatar Mar 24 '17 07:03 mxii

JSON file can not contain comments!

aslan92 avatar Mar 24 '17 09:03 aslan92

JSON format doesn't allow comments. This is not a limitation with the CLI. It's a limitation of JSON itself.

trevor-hackett avatar Mar 24 '17 12:03 trevor-hackett

Closing as the community already answered this, thanks guys!

filipesilva avatar Mar 24 '17 14:03 filipesilva

Actually, let's keep this open... I misread it as a bug report, but it's a very reasonable feature request.

filipesilva avatar Mar 24 '17 14:03 filipesilva

Sorry if you have answered it elsewhere, but can this file actually be a .js file instead of .json? It will be much more flexible and easier to work with.

bekos avatar Aug 28 '17 17:08 bekos

@bekos no, that is not supported.

filipesilva avatar Aug 31 '17 15:08 filipesilva

@filipesilva This would help if we actually needed a bit different setup for production and development setups in angular-cli. Does this make sense for a new feature request?

bekos avatar Aug 31 '17 16:08 bekos

@bekos I'm curious on the particulars of your scenario. Can you open a new issue to discuss your request?

filipesilva avatar Aug 31 '17 17:08 filipesilva

Would be nice to use https://www.npmjs.com/package/strip-json-comments

const json = '{/*rainbows*/"unicorn":"cake"}';
 
JSON.parse(stripJsonComments(json));
//=> {unicorn: 'cake'} 

manuel-di-iorio avatar Sep 15 '17 13:09 manuel-di-iorio

I think strip-json-comments this is a very good solution. @filipesilva what do you think?

listepo avatar Dec 26 '17 20:12 listepo

I think this is a great feature and the tsconfig.json also allows comments, https://github.com/Microsoft/TypeScript/issues/4987.

The config files need comments for clarification and future reading.

aristotll avatar Feb 09 '18 08:02 aristotll

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

alan-agius4 avatar Oct 30 '18 13:10 alan-agius4

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.