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

Moved 'use strict'; to a functional scope inside js templates.

Open qed2000 opened this issue 10 years ago • 8 comments
trafficstars

By placing the 'use strict'; outside of a functional scope, it can force an entire application to be strict even if some 3rd party components are not. By moving this statement into each component's function, it forces that component into strict mode, without causing conflicts with non strict outside code. Besides, I found that placing it outside of the app functions didn't enforce strict anyway.

qed2000 avatar Jun 28 '15 00:06 qed2000

Please read the contribution guidelines before opening a pull request. https://github.com/yeoman/generator-angular/blob/master/contributing.md#git-commit-guidelines

arthurvr avatar Jun 30 '15 07:06 arthurvr

ideally there would be a tool that would add this automatically for us

eddiemonge avatar Jun 30 '15 18:06 eddiemonge

ideally there would be a tool that would add this automatically for us

Agreed. Is there such a tool?

arthurvr avatar Jul 02 '15 09:07 arthurvr

style(templates): move 'use strict'; to a functional scope inside js templates

'use strict'; does not behave as expected when outside of a functional scope. This change moves the 'use strict'; into each function within the templates.

This does not contain breaking changes.

qed2000 avatar Jul 05 '15 07:07 qed2000

The specs dont need it moved since they don't get concatenated. Also, these should be squashed.

As for the tool that would do this, it should take each file, wrap it in an iife and put the 'use strict' at the top of the iife. Although this could cause problems if the enduser doesn't know this is happening.

These shouldn't affect the vendor.js files since those are separate from the app files

eddiemonge avatar Jul 07 '15 18:07 eddiemonge

Also, should the CoffeeScript files get these changes?

eddiemonge avatar Jul 24 '15 18:07 eddiemonge

https://github.com/gruntjs/grunt-contrib-concat#custom-process-function

stevemao avatar Aug 15 '15 12:08 stevemao

CoffeeScript should probably be replaced by babel?

stevemao avatar Aug 15 '15 12:08 stevemao