Skip to content

Commit

Permalink
fix(ambiguous-coffee-script): ensure compilation is unambiguous
Browse files Browse the repository at this point in the history
Before:
angular.module 'app'
.controller 'homeController', [Home]

After:
angular.module('app')
.controller('homeController', [Home])

Closes #20
  • Loading branch information
CaryLandholt committed Aug 15, 2014
1 parent 09366a4 commit a73cedc
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 81 deletions.
2 changes: 1 addition & 1 deletion index.coffee
Expand Up @@ -65,7 +65,7 @@ module.exports = (content, options) ->
modDetails.appTypes.forEach (appType) ->
lines.push appType
else
lines.push "angular.module '#{app}'"
lines.push "angular.module('#{app}')"

if modDetails.nonAppTypes and modDetails.nonAppTypes.length > 0
modDetails.nonAppTypes.forEach (nonAppType) ->
Expand Down
24 changes: 12 additions & 12 deletions lib/moduleOptions.coffee
Expand Up @@ -4,18 +4,18 @@ module.exports = (formatOptions, options) ->
moduleOptions =
appName: 'app'
formats:
animation: ".{{moduleType|lowerCase}} '#{formatOptions.animation.prefix}{{className|#{formatOptions.animation.format}}}#{formatOptions.animation.suffix}', [{{parameters}}]"
app: "angular.module '{{appName}}', {{className}}()"
config: ".{{moduleType|lowerCase}} [{{parameters}}]"
constant: ".{{moduleType|lowerCase}} '#{formatOptions.constant.prefix}{{className|#{formatOptions.constant.format}}}#{formatOptions.constant.suffix}', {{className}}()"
controller: ".{{moduleType|lowerCase}} '#{formatOptions.controller.prefix}{{className|#{formatOptions.controller.format}}}#{formatOptions.controller.suffix}', [{{parameters}}]"
directive: ".{{moduleType|lowerCase}} '#{formatOptions.directive.prefix}{{className|#{formatOptions.directive.format}}}#{formatOptions.directive.suffix}', [{{parameters}}]"
factory: ".{{moduleType|lowerCase}} '#{formatOptions.factory.prefix}{{className|#{formatOptions.factory.format}}}#{formatOptions.factory.suffix}', [{{parameters}}]"
filter: ".{{moduleType|lowerCase}} '#{formatOptions.filter.prefix}{{className|#{formatOptions.filter.format}}}#{formatOptions.filter.suffix}', [{{parameters}}]"
provider: ".{{moduleType|lowerCase}} '#{formatOptions.provider.prefix}{{className|#{formatOptions.provider.format}}}#{formatOptions.provider.suffix}', [{{parameters}}]"
run: ".{{moduleType|lowerCase}} [{{parameters}}]"
service: ".{{moduleType|lowerCase}} '#{formatOptions.service.prefix}{{className|#{formatOptions.service.format}}}#{formatOptions.service.suffix}', [{{parameters}}]"
value: ".{{moduleType|lowerCase}} '#{formatOptions.value.prefix}{{className|#{formatOptions.value.format}}}#{formatOptions.value.suffix}', {{className}}()"
animation: ".{{moduleType|lowerCase}}('#{formatOptions.animation.prefix}{{className|#{formatOptions.animation.format}}}#{formatOptions.animation.suffix}', [{{parameters}}])"
app: "angular.module('{{appName}}', {{className}}())"
config: ".{{moduleType|lowerCase}}([{{parameters}}])"
constant: ".{{moduleType|lowerCase}}('#{formatOptions.constant.prefix}{{className|#{formatOptions.constant.format}}}#{formatOptions.constant.suffix}', {{className}}())"
controller: ".{{moduleType|lowerCase}}('#{formatOptions.controller.prefix}{{className|#{formatOptions.controller.format}}}#{formatOptions.controller.suffix}', [{{parameters}}])"
directive: ".{{moduleType|lowerCase}}('#{formatOptions.directive.prefix}{{className|#{formatOptions.directive.format}}}#{formatOptions.directive.suffix}', [{{parameters}}])"
factory: ".{{moduleType|lowerCase}}('#{formatOptions.factory.prefix}{{className|#{formatOptions.factory.format}}}#{formatOptions.factory.suffix}', [{{parameters}}])"
filter: ".{{moduleType|lowerCase}}('#{formatOptions.filter.prefix}{{className|#{formatOptions.filter.format}}}#{formatOptions.filter.suffix}', [{{parameters}}])"
provider: ".{{moduleType|lowerCase}}('#{formatOptions.provider.prefix}{{className|#{formatOptions.provider.format}}}#{formatOptions.provider.suffix}', [{{parameters}}])"
run: ".{{moduleType|lowerCase}}([{{parameters}}])"
service: ".{{moduleType|lowerCase}}('#{formatOptions.service.prefix}{{className|#{formatOptions.service.format}}}#{formatOptions.service.suffix}', [{{parameters}}])"
value: ".{{moduleType|lowerCase}}('#{formatOptions.value.prefix}{{className|#{formatOptions.value.format}}}#{formatOptions.value.suffix}', {{className}}())"
prefix: ''

merged = extend true, moduleOptions, options
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -29,7 +29,7 @@
"devDependencies": {
"conventional-changelog": "0.0.11",
"gulp": "^3.8.0",
"gulp-jasmine": "0.2.0",
"gulp-jasmine": "^1.0.0",
"gulp-util": "^3.0.0"
},
"scripts": {
Expand Down
134 changes: 67 additions & 67 deletions test/ng-classify.spec.coffee
Expand Up @@ -31,8 +31,8 @@ describe 'ng-classify', ->
# flag will be set to true if cancelled).
}
angular.module 'app'
.animation '.my-crazy-fader', [MyCrazyFader]
angular.module('app')
.animation('.my-crazy-fader', [MyCrazyFader])
'''

expect(result).toEqual(expectation)
Expand All @@ -57,7 +57,7 @@ describe 'ng-classify', ->
'ngRoute'
]
angular.module 'app', App()
angular.module('app', App())
'''

expect(result).toEqual(expectation)
Expand Down Expand Up @@ -88,8 +88,8 @@ describe 'ng-classify', ->
'ngRoute'
]
angular.module 'app', App()
.controller 'homeController', [Home]
angular.module('app', App())
.controller('homeController', [Home])
'''

expect(result).toEqual(expectation)
Expand Down Expand Up @@ -124,8 +124,8 @@ describe 'ng-classify', ->
.otherwise
redirectTo: '/home'
angular.module 'app'
.config ['$routeProvider', Routes]
angular.module('app')
.config(['$routeProvider', Routes])
'''

expect(result).toEqual(expectation)
Expand All @@ -152,8 +152,8 @@ describe 'ng-classify', ->
'404': 'Not Found'
}
angular.module 'app'
.constant 'HTTP_STATUS_CODES', HttpStatusCodes()
angular.module('app')
.constant('HTTP_STATUS_CODES', HttpStatusCodes())
'''

expect(result).toEqual(expectation)
Expand All @@ -174,8 +174,8 @@ describe 'ng-classify', ->
@save = (username) ->
userService.addUser username
angular.module 'app'
.controller 'homeController', ['userService', Home]
angular.module('app')
.controller('homeController', ['userService', Home])
'''

expect(result).toEqual(expectation)
Expand All @@ -202,8 +202,8 @@ describe 'ng-classify', ->
templateUrl: 'dialog.html'
}
angular.module 'app'
.directive 'dialog', [Dialog]
angular.module('app')
.directive('dialog', [Dialog])
'''

expect(result).toEqual(expectation)
Expand Down Expand Up @@ -318,8 +318,8 @@ describe 'ng-classify', ->
@
angular.module 'app'
.factory 'Collection', ['$log', Collection]
angular.module('app')
.factory('Collection', ['$log', Collection])
'''

expect(result).toEqual(expectation)
Expand All @@ -340,8 +340,8 @@ describe 'ng-classify', ->
return (username) ->
"@#{username}"
angular.module 'app'
.filter 'twitterfy', [Twitterfy]
angular.module('app')
.filter('twitterfy', [Twitterfy])
'''

expect(result).toEqual(expectation)
Expand Down Expand Up @@ -378,8 +378,8 @@ describe 'ng-classify', ->
@setName = (name) ->
@name = name
angular.module 'app'
.provider 'greetingsProvider', ['$log', Greetings]
angular.module('app')
.provider('greetingsProvider', ['$log', Greetings])
'''

expect(result).toEqual(expectation)
Expand All @@ -398,8 +398,8 @@ describe 'ng-classify', ->
constructor: ($httpBackend) ->
$httpBackend.whenGET(/^.*\.(html|htm)$/).passThrough()
angular.module 'app'
.run ['$httpBackend', ViewsBackend]
angular.module('app')
.run(['$httpBackend', ViewsBackend])
'''

expect(result).toEqual(expectation)
Expand All @@ -420,8 +420,8 @@ describe 'ng-classify', ->
@sayHello = (name) ->
$log.info name
angular.module 'app'
.service 'greetingService', ['$log', Greeting]
angular.module('app')
.service('greetingService', ['$log', Greeting])
'''

expect(result).toEqual(expectation)
Expand Down Expand Up @@ -458,8 +458,8 @@ describe 'ng-classify', ->
}
]
angular.module 'app'
.value 'people', People()
angular.module('app')
.value('people', People())
'''

expect(result).toEqual(expectation)
Expand All @@ -480,8 +480,8 @@ describe 'ng-classify', ->
@save = (username) ->
userService.addUser username
angular.module 'app'
.controller 'homeController', ['userService', Home]
angular.module('app')
.controller('homeController', ['userService', Home])
'''

notExpectation = '''
Expand All @@ -490,8 +490,8 @@ describe 'ng-classify', ->
@save = (username) ->
userService.addUser username
angular.module 'app'
.controller 'homeController', ['@userService', Home]
angular.module('app')
.controller('homeController', ['@userService', Home])
'''

expect(result).toEqual(expectation)
Expand Down Expand Up @@ -523,9 +523,9 @@ describe 'ng-classify', ->
@save = (username) ->
userService.addUser username
angular.module 'app'
.controller 'homeController', ['userService', Home]
.controller 'anotherHomeController', ['anotherService', AnotherHome]
angular.module('app')
.controller('homeController', ['userService', Home])
.controller('anotherHomeController', ['anotherService', AnotherHome])
'''

expect(result).toEqual(expectation)
Expand All @@ -552,8 +552,8 @@ describe 'ng-classify', ->
@save = (username) ->
userService.addUser username
angular.module 'app'
.controller 'homeController', ['userService', Home]
angular.module('app')
.controller('homeController', ['userService', Home])
'''

expect(result).toEqual(expectation)
Expand All @@ -580,8 +580,8 @@ describe 'ng-classify', ->
@save = (username) ->
userService.addUser username
angular.module 'app'
.controller 'homeController', ['userService', Home]
angular.module('app')
.controller('homeController', ['userService', Home])
'''

expect(result).toEqual(expectation)
Expand All @@ -604,8 +604,8 @@ describe 'ng-classify', ->
@save = (username) ->
userService.addUser username
angular.module 'app'
.controller 'homeController', ['userService', Home]
angular.module('app')
.controller('homeController', ['userService', Home])
'''

expect(result).toEqual(expectation)
Expand Down Expand Up @@ -662,9 +662,9 @@ describe 'ng-classify', ->
@save = (username) ->
userService.addUser username + square(2)
angular.module 'app'
.controller 'homeController', ['userService', Home]
.controller 'anotherHomeController', ['anotherService', AnotherHome]
angular.module('app')
.controller('homeController', ['userService', Home])
.controller('anotherHomeController', ['anotherService', AnotherHome])
'''

expect(result).toEqual(expectation)
Expand Down Expand Up @@ -727,8 +727,8 @@ describe 'ng-classify', ->
constructor: ($log) ->
$log.info 'controller with prefix'
angular.module 'app'
.controller 'homeController', ['$log', Home]
angular.module('app')
.controller('homeController', ['$log', Home])
'''

expect(result).toEqual(expectation)
Expand All @@ -747,8 +747,8 @@ describe 'ng-classify', ->
constructor: ($log) ->
$log.info 'controller with prefix'
angular.module 'app'
.controller 'homeController', ['$log', Home]
angular.module('app')
.controller('homeController', ['$log', Home])
'''

expect(result).toEqual(expectation)
Expand All @@ -765,8 +765,8 @@ describe 'ng-classify', ->
class Home
constructor: do ->
angular.module 'app'
.controller 'homeController', [Home]
angular.module('app')
.controller('homeController', [Home])
'''

expect(result).toEqual(expectation)
Expand All @@ -784,8 +784,8 @@ describe 'ng-classify', ->
class Home
constructor: ->
angular.module 'common'
.controller 'homeController', [Home]
angular.module('common')
.controller('homeController', [Home])
'''

expect(result).toEqual(expectation)
Expand All @@ -808,9 +808,9 @@ describe 'ng-classify', ->
class About
constructor: ->
angular.module 'common.a'
.controller 'homeController', [Home]
.controller 'aboutController', [About]
angular.module('common.a')
.controller('homeController', [Home])
.controller('aboutController', [About])
'''

expect(result).toEqual(expectation)
Expand Down Expand Up @@ -839,12 +839,12 @@ describe 'ng-classify', ->
class Admin
constructor: ->
angular.module 'common.a'
.controller 'homeController', [Home]
.controller 'aboutController', [About]
angular.module('common.a')
.controller('homeController', [Home])
.controller('aboutController', [About])
angular.module 'app'
.controller 'adminController', [Admin]
angular.module('app')
.controller('adminController', [Admin])
'''

expect(result).toEqual(expectation)
Expand Down Expand Up @@ -873,12 +873,12 @@ describe 'ng-classify', ->
class Admin
constructor: ->
angular.module 'common.a'
.controller 'homeController', [Home]
.controller 'aboutController', [About]
angular.module('common.a')
.controller('homeController', [Home])
.controller('aboutController', [About])
angular.module 'myAppName'
.controller 'adminController', [Admin]
angular.module('myAppName')
.controller('adminController', [Admin])
'''

expect(result).toEqual(expectation)
Expand Down Expand Up @@ -913,12 +913,12 @@ describe 'ng-classify', ->
class Admin
constructor: ->
angular.module 'common.a', CommonA()
.controller 'homeController', [Home]
.controller 'aboutController', [About]
angular.module('common.a', CommonA())
.controller('homeController', [Home])
.controller('aboutController', [About])
angular.module 'myAppName'
.controller 'adminController', [Admin]
angular.module('myAppName')
.controller('adminController', [Admin])
'''

expect(result).toEqual(expectation)

0 comments on commit a73cedc

Please sign in to comment.