Skip to content
This repository was archived by the owner on May 25, 2019. It is now read-only.

Commit 9096e9e

Browse files
committed
style: makes jshint happy
1 parent d41874c commit 9096e9e

File tree

5 files changed

+78
-52
lines changed

5 files changed

+78
-52
lines changed

.jshintrc

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
{
2-
"immed": true,
3-
"newcap": true,
4-
"noarg": true,
5-
"noempty": true,
6-
"nonew": true,
7-
"trailing": true,
8-
"maxlen": 200,
92
"boss": true,
3+
"browser": true,
104
"eqnull": true,
115
"expr": true,
126
"globalstrict": true,
7+
"immed": true,
138
"laxbreak": true,
149
"loopfunc": true,
10+
"newcap": true,
11+
"noarg": true,
12+
"noempty": true,
13+
"nonew": true,
14+
"quotmark": true,
15+
"smarttabs": true,
1516
"sub": true,
17+
"trailing": true,
1618
"undef": true,
17-
"browser": true,
18-
"quotmark": true,
19+
"unused": true,
1920
"globals": {
20-
"module" : false,
21-
"angular" : false,
22-
"require" : false,
23-
"process" : false
21+
"angular": false
2422
}
2523
}

demo/demo.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
angular.module('doc.ui-codeMirror', ['ui.codemirror', 'prettifyDirective', 'ui.bootstrap', 'plunker' ])
24
.controller('CodemirrorCtrl', ['$scope', function ($scope) {
35

@@ -14,7 +16,7 @@ angular.module('doc.ui-codeMirror', ['ui.codemirror', 'prettifyDirective', 'ui.b
1416

1517
// HACK to have the codemirror instance in the scope...
1618
$scope.modeChanged = function () {
17-
_cm.setOption("mode", $scope.mode.toLowerCase());
19+
_cm.setOption('mode', $scope.mode.toLowerCase());
1820
};
1921

2022
}
@@ -29,4 +31,4 @@ angular.module('doc.ui-codeMirror', ['ui.codemirror', 'prettifyDirective', 'ui.b
2931
'// Javascript code in here.\n' +
3032
'function foo(msg) {\n\tvar r = Math.random();\n\treturn "" + r + " : " + msg;\n}';
3133

32-
}]);
34+
}]);

gruntFile.js

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ module.exports = function (grunt) {
5151
watch: {
5252
src: {
5353
files: ['src/*'],
54-
tasks: ['jshint', 'karma:unit:run', 'dist', 'build:gh-pages']
54+
tasks: ['jshint:src', 'karma:unit:run', 'dist', 'build:gh-pages']
5555
},
5656
test: {
5757
files: ['test/*.js'],
58-
tasks: ['jshint', 'karma:unit:run']
58+
tasks: ['jshint:test', 'karma:unit:run']
5959
},
6060
demo: {
61-
files: ['demo/*'],
62-
tasks: ['build:gh-pages']
61+
files: ['demo/*', 'publish.js'],
62+
tasks: ['jshint', 'build:gh-pages']
6363
}
6464
},
6565

@@ -81,9 +81,34 @@ module.exports = function (grunt) {
8181
continuous: { options: { keepalive: false } }
8282
},
8383

84-
jshint:{
85-
files:['src/*.js', 'demo/**/*.js', 'gruntFile.js'],
86-
options: { jshintrc: '.jshintrc' }
84+
jshint: {
85+
src: {
86+
files:{ src : ['src/*.js', 'demo/**/*.js'] },
87+
options: { jshintrc: '.jshintrc' }
88+
},
89+
test: {
90+
files:{ src : [ 'test/*.spec.js', 'publish.js', 'gruntFile.js'] },
91+
options: grunt.util._.extend({}, grunt.file.readJSON('.jshintrc'), {
92+
node: true,
93+
globals: {
94+
angular: false,
95+
inject: false,
96+
jQuery: false,
97+
98+
jasmine: false,
99+
afterEach: false,
100+
beforeEach: false,
101+
ddescribe: false,
102+
describe: false,
103+
expect: false,
104+
iit: false,
105+
it: false,
106+
spyOn: false,
107+
xdescribe: false,
108+
xit: false
109+
}
110+
})
111+
}
87112
},
88113

89114
uglify: {

src/ui-codemirror.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
'use strict';
2+
13
/**
24
* Binds a CodeMirror widget to a <textarea> element.
35
*/
46
angular.module('ui.codemirror', [])
57
.constant('uiCodemirrorConfig', {})
68
.directive('uiCodemirror', ['uiCodemirrorConfig', function (uiCodemirrorConfig) {
7-
'use strict';
89

910
return {
1011
restrict: 'EA',
1112
require: '?ngModel',
1213
priority: 1,
13-
compile: function compile(tElement, tAttrs, transclude) {
14+
compile: function compile(tElement) {
1415

1516
// Require CodeMirror
1617
if (angular.isUndefined(window.CodeMirror)) {
@@ -22,27 +23,27 @@ angular.module('ui.codemirror', [])
2223
// - the initial content of the editor.
2324
// see http://codemirror.net/doc/manual.html#api_constructor
2425
var value = tElement.text();
25-
var codeMirror = new CodeMirror(function (cm_el) {
26+
var codeMirror = new window.CodeMirror(function (cm_el) {
2627

27-
angular.forEach(tElement.prop("attributes"), function (a) {
28-
if (a.name === "ui-codemirror") {
29-
cm_el.setAttribute("ui-codemirror-opts", a.textContent);
28+
angular.forEach(tElement.prop('attributes'), function (a) {
29+
if (a.name === 'ui-codemirror') {
30+
cm_el.setAttribute('ui-codemirror-opts', a.textContent);
3031
} else {
3132
cm_el.setAttribute(a.name, a.textContent);
3233
}
3334
});
3435

3536
// FIX replaceWith throw not parent Error !
3637
if (tElement.parent().length <= 0) {
37-
tElement.wrap("<div>");
38+
tElement.wrap('<div>');
3839
}
3940

4041
tElement.replaceWith(cm_el);
4142
}, {value: value});
4243

4344
return function postLink(scope, iElement, iAttrs, ngModel) {
4445

45-
var options, opts, onChange;
46+
var options, opts;
4647

4748
options = uiCodemirrorConfig.codemirror || {};
4849
opts = angular.extend({}, options, scope.$eval(iAttrs.uiCodemirror), scope.$eval(iAttrs.uiCodemirrorOpts));
@@ -61,7 +62,7 @@ angular.module('ui.codemirror', [])
6162
scope.$watch(iAttrs.uiCodemirror, updateOptions, true);
6263
}
6364
// Specialize change event
64-
codeMirror.on("change", function (instance, changeObj) {
65+
codeMirror.on('change', function (instance) {
6566
var newValue = instance.getValue();
6667
if (ngModel && newValue !== ngModel.$viewValue) {
6768
ngModel.$setViewValue(newValue);

test/codemirror.spec.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,17 @@ describe('uiCodemirror', function () {
7171
it('should call the CodeMirror constructor with a function', function () {
7272
$compile('<div ui-codemirror></div>')(scope);
7373

74-
expect(CodeMirror.callCount).toEqual(1);
75-
expect(CodeMirror).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Object));
74+
expect(window.CodeMirror.callCount).toEqual(1);
75+
expect(window.CodeMirror).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Object));
7676

7777
expect(codemirror).toBeDefined();
7878
});
7979

8080
it('should work as an element', function () {
8181
$compile('<ui-codemirror></ui-codemirror>')(scope);
8282

83-
expect(CodeMirror.callCount).toEqual(1);
84-
expect(CodeMirror).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Object));
83+
expect(window.CodeMirror.callCount).toEqual(1);
84+
expect(window.CodeMirror).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Object));
8585

8686
expect(codemirror).toBeDefined();
8787
});
@@ -91,10 +91,10 @@ describe('uiCodemirror', function () {
9191
var element = $compile('<div><div ui-codemirror></div></div>')(scope).children();
9292

9393
expect(element).toBeDefined();
94-
expect(element.prop("tagName")).toBe("DIV");
95-
expect(element.prop("classList").length).toEqual(2);
96-
expect(element.prop("classList")[0]).toEqual("CodeMirror");
97-
expect(element.prop("classList")[1]).toEqual("cm-s-default");
94+
expect(element.prop('tagName')).toBe('DIV');
95+
expect(element.prop('classList').length).toEqual(2);
96+
expect(element.prop('classList')[0]).toEqual('CodeMirror');
97+
expect(element.prop('classList')[1]).toEqual('cm-s-default');
9898
});
9999

100100

@@ -114,13 +114,13 @@ describe('uiCodemirror', function () {
114114

115115
expect(codemirror.setOption).toHaveBeenCalled();
116116
expect(codemirror.setOption.calls.length).toEqual(1);
117-
expect(codemirror.setOption).toHaveBeenCalledWith("oof", "baar");
117+
expect(codemirror.setOption).toHaveBeenCalledWith('oof', 'baar');
118118

119119
$compile('<ui-codemirror ui-codemirror-opts="{oof: \'baar\'}"></ui-codemirror>')(scope);
120120

121121
expect(codemirror.setOption).toHaveBeenCalled();
122122
expect(codemirror.setOption.calls.length).toEqual(1);
123-
expect(codemirror.setOption).toHaveBeenCalledWith("oof", "baar");
123+
expect(codemirror.setOption).toHaveBeenCalledWith('oof', 'baar');
124124
});
125125

126126
it('should include the default options', function () {
@@ -130,7 +130,7 @@ describe('uiCodemirror', function () {
130130

131131
expect(codemirror.setOption).toHaveBeenCalled();
132132
expect(codemirror.setOption.calls.length).toEqual(1);
133-
expect(codemirror.setOption).toHaveBeenCalledWith("bar", "baz");
133+
expect(codemirror.setOption).toHaveBeenCalledWith('bar', 'baz');
134134
});
135135

136136
it('should extent the default options', function () {
@@ -140,8 +140,8 @@ describe('uiCodemirror', function () {
140140

141141
expect(codemirror.setOption).toHaveBeenCalled();
142142
expect(codemirror.setOption.calls.length).toEqual(2);
143-
expect(codemirror.setOption).toHaveBeenCalledWith("oof", "baar");
144-
expect(codemirror.setOption).toHaveBeenCalledWith("bar", "baz");
143+
expect(codemirror.setOption).toHaveBeenCalledWith('oof', 'baar');
144+
expect(codemirror.setOption).toHaveBeenCalledWith('bar', 'baz');
145145
});
146146

147147
it('should impact codemirror', function () {
@@ -150,10 +150,10 @@ describe('uiCodemirror', function () {
150150
$compile('<div ui-codemirror="{theme: \'baar\'}"></div>')(scope);
151151
expect(codemirror.setOption).toHaveBeenCalled();
152152
expect(codemirror.setOption.calls.length).toEqual(1);
153-
expect(codemirror.setOption).toHaveBeenCalledWith("theme", "baar");
153+
expect(codemirror.setOption).toHaveBeenCalledWith('theme', 'baar');
154154

155155

156-
expect(codemirror.getOption("theme")).toEqual("baar");
156+
expect(codemirror.getOption('theme')).toEqual('baar');
157157
});
158158
});
159159

@@ -193,13 +193,13 @@ describe('uiCodemirror', function () {
193193
var element = $compile('<div><div ui-codemirror ng-model="foo"></div></div>')(scope).children();
194194

195195
expect(element).toBeDefined();
196-
expect(element.attr("class")).toEqual('CodeMirror cm-s-default ng-pristine ng-valid');
196+
expect(element.attr('class')).toEqual('CodeMirror cm-s-default ng-pristine ng-valid');
197197

198198
var value = 'baz';
199199
codemirror.setValue(value);
200200
expect(scope.foo).toBe(value);
201201

202-
expect(element.attr("class")).toEqual('CodeMirror cm-s-default ng-valid ng-dirty');
202+
expect(element.attr('class')).toEqual('CodeMirror cm-s-default ng-valid ng-dirty');
203203

204204
});
205205

@@ -208,18 +208,18 @@ describe('uiCodemirror', function () {
208208
var element = $compile('<div><div ui-codemirror ng-model="foo"></div></div>')(scope).children();
209209

210210
expect(element).toBeDefined();
211-
expect(element.attr("class")).toEqual('CodeMirror cm-s-default ng-pristine ng-valid');
211+
expect(element.attr('class')).toEqual('CodeMirror cm-s-default ng-pristine ng-valid');
212212

213213
scope.$apply('foo = "bar"');
214214
expect(codemirror.getValue()).toBe(scope.foo);
215215

216-
expect(element.attr("class")).toEqual('CodeMirror cm-s-default ng-pristine ng-valid');
216+
expect(element.attr('class')).toEqual('CodeMirror cm-s-default ng-pristine ng-valid');
217217
});
218218

219219

220220
it('when the IDE changes should use ngChange', function () {
221221
scope.change = angular.noop;
222-
spyOn(scope, "change").andCallFake(function() { expect(scope.foo).toBe('baz'); });
222+
spyOn(scope, 'change').andCallFake(function() { expect(scope.foo).toBe('baz'); });
223223

224224
$compile('<div ui-codemirror ng-model="foo" ng-change="change()"></div>')(scope);
225225

@@ -239,7 +239,7 @@ describe('uiCodemirror', function () {
239239

240240
it('should runs the onLoad callback', function () {
241241
scope.codemirrorLoaded = angular.noop;
242-
spyOn(scope, "codemirrorLoaded");
242+
spyOn(scope, 'codemirrorLoaded');
243243

244244
$compile('<div ui-codemirror="{onLoad: codemirrorLoaded}"></div>')(scope);
245245

0 commit comments

Comments
 (0)