Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Commit b46f2c2

Browse files
committed
coffeelint enforcing
1 parent 8883f40 commit b46f2c2

38 files changed

+409
-311
lines changed

Gruntfile.coffee

+17-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ log = require('util').log
22
_ = require 'lodash'
33
kickoff = require 'karma-kickoff'
44
argv = require('yargs').argv
5+
coffeelint = require './grunt/coffeelint'
6+
watch = require './grunt/options/watch'
7+
58

69
module.exports = (grunt) ->
710
# Load the required plugins
@@ -41,23 +44,35 @@ module.exports = (grunt) ->
4144
allExamplesOpen[root] =
4245
path: pathValue
4346

44-
# console.log allExamplesOpen, true
4547

4648
showOpenType = (toIterate = allExamplesOpen) ->
4749
_(toIterate).each (v, k) ->
4850
log "#{k} -> #{v.path}"
51+
4952
#showAllExamples()
53+
5054
options.open = _.extend options.open, allExamplesOpen
5155
grunt.initConfig options
5256

57+
lints = _.keys(_.omit(watch.coffeelint, 'options'))
58+
59+
lints.forEach (n) ->
60+
grunt.registerTask "coffeelint:#{n}", ->
61+
coffeelint({src:watch.coffeelint[n].files, doThrow:false}, @async())
62+
63+
grunt.registerTask "coffeelint:#{n}:throw", ->
64+
coffeelint({src:watch.coffeelint[n].files}, @async())
65+
66+
grunt.registerTask 'lint', (lints.map (n) -> "coffeelint:#{n}").concat (lints.map (n) -> "watch:coffeelint-#{n}")
67+
5368
grunt.registerTask 'build', ['bower', 'clean:dist', 'jshint', 'mkdir', 'coffee', 'ngAnnotate',
5469
'concat:libs', 'replace', 'webpack:commonjsDeps']
5570

5671
grunt.registerTask 'buildDist', ['build', 'concat:dist']
5772

5873
grunt.registerTask "default", [ 'verbosity', 'buildDist', 'copy', 'uglify:dist', 'uglify:streetview', 'karma']
5974

60-
grunt.registerTask "buildAll", [ "build", "concat",
75+
grunt.registerTask "buildAll", (lints.map (n) -> "coffeelint:#{n}:throw").concat [ "build", "concat",
6176
"uglify", "copy", "karma", "graph"]
6277

6378
# run default "grunt" prior to generate _SpecRunner.html

coffeelint.json

+26-1
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,30 @@
110110
"non_empty_constructor_needs_parens": {
111111
"name": "non_empty_constructor_needs_parens",
112112
"level": "ignore"
113-
}
113+
},
114+
"check_scope": {
115+
"module": "coffeescope2",
116+
"level": "error",
117+
"environments": ["es5", "node", "commonjs", "jasmine", "browser"],
118+
"globals": {
119+
"_": true,
120+
"angular": true,
121+
"google": true,
122+
"inject": true,
123+
"NgMapMarkerClusterer": true,
124+
"MarkerWithLabel": true,
125+
"RichMarker": true,
126+
"PropMap": true
127+
},
128+
"overwrite": false,
129+
"shadow": false,
130+
"shadow_builtins": true,
131+
"shadow_exceptions": ["err", "next"],
132+
"undefined": true,
133+
"hoist_local": true,
134+
"hoist_parent": true,
135+
"unused_variables": true,
136+
"unused_arguments": false,
137+
"unused_classes": false
138+
}
114139
}

dist/angular-google-maps-street-view_dev_mapped.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-google-maps.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -2029,7 +2029,6 @@ Nicholas McCready - https://twitter.com/nmccready
20292029
}
20302030
this.opt_options = opt_options != null ? opt_options : {};
20312031
this.opt_events = opt_events;
2032-
this.checkSync = bind(this.checkSync, this);
20332032
this.getGMarkers = bind(this.getGMarkers, this);
20342033
this.fit = bind(this.fit, this);
20352034
this.destroy = bind(this.destroy, this);
@@ -2347,14 +2346,12 @@ Nicholas McCready - https://twitter.com/nmccready
23472346
this.opt_options = opt_options != null ? opt_options : {};
23482347
this.opt_events = opt_events;
23492348
this.scope = scope;
2350-
this.checkSync = bind(this.checkSync, this);
23512349
this.isSpiderfied = bind(this.isSpiderfied, this);
23522350
this.getGMarkers = bind(this.getGMarkers, this);
23532351
this.fit = bind(this.fit, this);
23542352
this.destroy = bind(this.destroy, this);
23552353
this.attachEvents = bind(this.attachEvents, this);
23562354
this.clear = bind(this.clear, this);
2357-
this.draw = bind(this.draw, this);
23582355
this.removeMany = bind(this.removeMany, this);
23592356
this.remove = bind(this.remove, this);
23602357
this.addMany = bind(this.addMany, this);
@@ -6385,8 +6382,6 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
63856382
;(function() {
63866383
angular.module("uiGmapgoogle-maps.directives.api").service("uiGmapICircle", [
63876384
function() {
6388-
var DEFAULTS;
6389-
DEFAULTS = {};
63906385
return {
63916386
restrict: "EA",
63926387
replace: true,
@@ -6448,7 +6443,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
64486443
}
64496444

64506445
IControl.prototype.link = function(scope, element, attrs, ctrl) {
6451-
throw new Exception("Not implemented!!");
6446+
throw new Error("Not implemented!!");
64526447
};
64536448

64546449
return IControl;
@@ -6629,8 +6624,6 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
66296624
angular.module('uiGmapgoogle-maps.directives.api').service('uiGmapIRectangle', [
66306625
function() {
66316626
'use strict';
6632-
var DEFAULTS;
6633-
DEFAULTS = {};
66346627
return {
66356628
restrict: 'EMA',
66366629
require: '^' + 'uiGmapGoogleMap',

dist/angular-google-maps.min.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

grunt/options.coffee

+12
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,25 @@ _pkg = require './pkg'
33
requireDirectory = require 'require-directory'
44
allOptions = requireDirectory module, './options/'
55

6+
#BEGIN append ./node_modules to our path for this process
7+
#shamelessly copied from gulp-shell
8+
#https://github.com/sun-zheng-an/gulp-shell/blob/825a24c214ce91027d535ca767df2cfe8745f1a3/index.js#L33-L36
9+
path = require 'path'
10+
pathToBin = path.join(process.cwd(), 'node_modules', '.bin')
11+
pathName = if /^win/.test(process.platform) then 'Path' else 'PATH'
12+
newPath = pathToBin + path.delimiter + process.env[pathName]
13+
_.extend(process.env, _.fromPairs([[pathName, newPath]]))
14+
#END adding node_modules to path
15+
616
module.exports = (grunt) ->
717
options =
818
pkg: _pkg
919
pkgFn: ->
1020
grunt.file.readJSON("package.json") #always get latest!
1121

22+
# coffeelint: disable=check_scope
1223
for key, val of allOptions
24+
# coffeelint: enable=check_scope
1325
_.extend options, val
1426

1527
options

grunt/options/watch.coffee

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
1-
module.exports =
2-
watch:
1+
_ = require 'lodash'
2+
3+
coffeelint = {}
4+
for n in ['grunt', 'src', 'spec']
5+
coffeelint[n] =
6+
options: livereload: true
7+
files: [
8+
"#{n}/**/*.coffee"
9+
]
10+
tasks: ["coffeelint:#{n}"]
11+
12+
13+
coffeelint.grunt.files.push '*.coffee'
14+
15+
coffeelintWatches = _.mapKeys coffeelint, (v, k) ->
16+
"coffeelint-#{k}"
17+
18+
19+
module.exports = {
20+
coffeelint
21+
watch: _.extend coffeelintWatches,
322
offline:
423
options:
524
livereload: true
@@ -28,3 +47,6 @@ module.exports =
2847

2948
files: ["src/coffee/**/*.coffee"]
3049
tasks: ["karma"]
50+
}
51+
52+
# console.log(module.exports)

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@
2929
"license": "MIT",
3030
"devDependencies": {
3131
"bower": "~1.4.1",
32+
"coffeelint": "1.16.0",
33+
"coffeescope2": "0.4.4",
3234
"data-structures": "^1.4.2",
3335
"eslint": "3.7.1",
3436
"eslint-config-airbnb": "12.0.0",
3537
"eslint-plugin-import": "1.16.0",
3638
"eslint-plugin-jsx-a11y": "2.2.2",
3739
"eslint-plugin-react": "6.3.0",
40+
"globby": "6.1.0",
3841
"grunt": "~0.4.5",
3942
"grunt-angular-architecture-graph": "^0.2.6",
4043
"grunt-bump": "0.3.1",
@@ -74,6 +77,7 @@
7477
"mocha": "2.X",
7578
"phantomjs-polyfill": "0.0.1",
7679
"require-directory": "2.1.1",
80+
"through2": "2.0.3",
7781
"webpack": "1.X",
7882
"webpack-dev-server": "1.X",
7983
"yargs": "3.32.0"

spec/coffee/bootstrap/google-api-mock.coffee

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
###global _:true, angular:true, google:true ###
22
do ->
3+
#coffeelint:disable=check_scope
34
capitalize = (s) ->
45
return s[0].toUpperCase() + s.slice(1)
6+
#coffeelint:enable=check_scope
57

68
class MapObject
79
getMap: =>
@@ -65,7 +67,9 @@ do ->
6567
class Marker extends MapObject
6668
_.extend @::, PositionObject::, DraggableObject::, VisibleObject::
6769
@instances = 0
70+
#coffeelint:disable=no_private_function_fat_arrows
6871
@resetInstances = =>
72+
#coffeelint:enable=no_private_function_fat_arrows
6973
@instances = 0
7074
@creationSubscribe = (obj, cb) ->
7175
window.google.maps.event.addListener(obj, 'creation', cb)
@@ -115,7 +119,9 @@ do ->
115119
class Circle extends MapObject
116120
_.extend @::, DraggableObject::, VisibleObject::
117121
@instances = 0
122+
#coffeelint:disable=no_private_function_fat_arrows
118123
@resetInstances = =>
124+
#coffeelint:enable=no_private_function_fat_arrows
119125
@instances = 0
120126
@creationSubscribe = (obj, cb) ->
121127
window.google.maps.event.addListener(obj, 'creation', cb)
@@ -128,16 +134,18 @@ do ->
128134
@setOptions opts
129135

130136
#getters
137+
#coffeelint:disable=check_scope
131138
@props.forEach (p) =>
132-
@["get#{capitalize p}"] = =>
139+
@["get#{capitalize(p)}"] = =>
133140
@[p]
134141

135142
#setters
136143
@props.forEach (p) =>
137-
@["set#{capitalize p}"] = (val) =>
144+
@["set#{capitalize(p)}"] = (val) =>
138145
@[p] = val
139146
if p == "radius" or p == "center"
140147
window.google.maps.event.fireAllListeners "#{p}_changed", @
148+
#coffeelint:enable=check_scope
141149

142150
Circle.instances += 1
143151
@instance = Circle.instances
@@ -188,7 +196,9 @@ do ->
188196
getMarkerWithLabel: ->
189197
class MarkerWithLabel extends getMarker()
190198
@instances = 0
199+
#coffeelint:disable=no_private_function_fat_arrows
191200
@resetInstances = =>
201+
#coffeelint:enable=no_private_function_fat_arrows
192202
@instances = 0
193203
constructor: (opts) ->
194204
if opts?
@@ -221,8 +231,10 @@ do ->
221231
getPolyline = ->
222232
class Polyline extends DraggableObject
223233
@instances = 0
234+
#coffeelint:disable=no_private_function_fat_arrows
224235
@resetInstances = =>
225236
@instances = 0
237+
#coffeelint:enable=no_private_function_fat_arrows
226238
constructor: (opts) ->
227239
if opts?
228240
['draggable', 'editable', 'map','path', 'visible'].forEach (o) =>
@@ -241,7 +253,9 @@ do ->
241253
getMVCArray = ->
242254
class MVCArray extends Array
243255
@instances = 0
256+
#coffeelint:disable=no_private_function_fat_arrows
244257
@resetInstances = =>
258+
#coffeelint:enable=no_private_function_fat_arrows
245259
@instances = 0
246260
constructor: ->
247261
MVCArray.instances += 1
@@ -480,7 +494,7 @@ do ->
480494
getLatLng: getLatLng
481495

482496
(new GoogleApiMock()).initAll()
483-
497+
484498
angular.module('uiGmapgoogle-maps.mocks', ['uiGmapgoogle-maps'])
485499
.factory('GoogleApiMock', ->
486500
GoogleApiMock

spec/coffee/bootstrap/google-map-spec-controller.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
do ->
2-
module = angular.module("angular-google-maps-specs", ['uiGmapgoogle-maps'])
2+
angular.module("angular-google-maps-specs", ['uiGmapgoogle-maps'])
33
.controller 'GoogleMapSpecController', ($scope, $timeout, $log) ->
44
self = @
55
@hasRun = false

spec/coffee/directives/api/circle.spec.coffee

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
describe 'uiGmapCircle', ->
2+
#coffeelint:disable=check_scope
23
allDone = undefined
34
GCircle = null
45
modelClicked = false
6+
#coffeelint:enable=check_scope
57

68
afterEach ->
79
window.google.maps.event.clearListeners()
810
GCircle.resetInstances()
11+
#coffeelint:disable=check_scope
912
modelClicked = false
13+
#coffeelint:enable=check_scope
1014

1115
beforeEach ->
1216

@@ -49,7 +53,7 @@ describe 'uiGmapCircle', ->
4953
events: circleEvents
5054
control: {}
5155

52-
apiMock = window.uiGmapInitiator
56+
window.uiGmapInitiator
5357
.initMock(@, ->
5458
GCircle = window.google.maps.Circle
5559
).apiMock
@@ -124,7 +128,7 @@ describe 'uiGmapCircle', ->
124128
@digest =>
125129
@timeout =>
126130
@digest =>
127-
listener = GCircle.creationSubscribe @, (gObject) =>
131+
GCircle.creationSubscribe @, (gObject) =>
128132
_.delay =>
129133
gObject.setCenter
130134
lat: ->

spec/coffee/directives/api/control.spec.coffee

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe "directives.api.control", ->
1515
<ui-gmap-map-control template="mockControl.tpl.html"></ui-gmap-map-control>
1616
</ui-gmap-google-map>
1717
"""
18-
element = @compile(html)(@scope)
18+
@compile(html)(@scope)
1919
@rootScope.$apply()
2020
expect(@log.error).not.toHaveBeenCalled()
2121
@log.error.calls.reset()
@@ -27,7 +27,7 @@ describe "directives.api.control", ->
2727
<ui-gmap-map-control template="mockControl.tpl.html" position="bad-position">
2828
</ui-gmap-map-control>
2929
</ui-gmap-google-map>"""
30-
element = @compile(html)(@scope)
30+
@compile(html)(@scope)
3131
@rootScope.$apply()
3232
expect(@log.error).toHaveBeenCalledWith('mapControl: invalid position property')
3333
@log.error.calls.reset()
@@ -38,7 +38,7 @@ describe "directives.api.control", ->
3838
<ui-gmap-map-control template="mockControl.tpl.html" position="bottom-center"></ui-gmap-map-control>
3939
</ui-gmap-google-map>
4040
"""
41-
element = @compile(html)(@scope)
41+
@compile(html)(@scope)
4242
@rootScope.$apply()
4343
expect(@log.error).not.toHaveBeenCalled()
4444
@log.error.calls.reset()
@@ -49,7 +49,7 @@ describe "directives.api.control", ->
4949
<ui-gmap-map-control template="mockControl.tpl.html" position="ToP_LefT"></ui-gmap-map-control>
5050
</ui-gmap-google-map>
5151
"""
52-
element = @compile(html)(@scope)
52+
@compile(html)(@scope)
5353
@rootScope.$apply()
5454
expect(@log.error).not.toHaveBeenCalled()
5555
@log.error.calls.reset()

spec/coffee/directives/api/drag-zoom.spec.coffee

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
describe 'uiGmapDragZoom spec', ->
2-
allDone = undefined
32

43
beforeEach ->
54

@@ -30,7 +29,7 @@ describe 'uiGmapDragZoom spec', ->
3029

3130
spyOn(scope.spec, 'enableKeyDragZoom')
3231

33-
element = @compile(html)(scope)
32+
@compile(html)(scope)
3433

3534
@digest () =>
3635
@timeout () ->

0 commit comments

Comments
 (0)