Skip to content

Commit 66400c0

Browse files
committed
adding linting via grunt
1 parent a0ea08c commit 66400c0

12 files changed

+266
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.jshintrc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"maxerr" : 50,
3+
4+
"indent" : 2,
5+
"bitwise" : true,
6+
"camelcase" : true,
7+
"curly" : true,
8+
"eqeqeq" : true,
9+
"forin" : true,
10+
"immed" : false,
11+
"latedef" : false,
12+
"newcap" : true,
13+
"noarg" : true,
14+
"noempty" : true,
15+
"nonew" : false,
16+
"plusplus" : false,
17+
"quotmark" : "single",
18+
"undef" : true,
19+
"unused" : true,
20+
"strict" : false,
21+
"trailing" : false,
22+
"maxparams" : 4,
23+
"maxdepth" : 3,
24+
"maxstatements" : 20,
25+
"maxcomplexity" : 20,
26+
"maxlen" : 120,
27+
28+
"asi" : false,
29+
"boss" : false,
30+
"debug" : false,
31+
"eqnull" : false,
32+
"es5" : false,
33+
"esnext" : false,
34+
"moz" : false,
35+
"evil" : false,
36+
"expr" : false,
37+
"funcscope" : false,
38+
"globalstrict" : false,
39+
"iterator" : false,
40+
"lastsemic" : false,
41+
"laxbreak" : false,
42+
"laxcomma" : false,
43+
"loopfunc" : false,
44+
"multistr" : false,
45+
"proto" : false,
46+
"scripturl" : false,
47+
"smarttabs" : true,
48+
"shadow" : false,
49+
"sub" : false,
50+
"supernew" : false,
51+
"validthis" : false,
52+
53+
"browser" : true,
54+
"couch" : false,
55+
"devel" : true,
56+
"dojo" : false,
57+
"jquery" : false,
58+
"mootools" : false,
59+
"node" : false,
60+
"nonstandard" : false,
61+
"prototypejs" : false,
62+
"rhino" : false,
63+
"worker" : false,
64+
"wsh" : false,
65+
"yui" : false,
66+
67+
"nomen" : false,
68+
"onevar" : false,
69+
"passfail" : false,
70+
"white" : false,
71+
72+
"globals" : {
73+
}
74+
}

Gruntfile.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module.exports = function(grunt) {
2+
'use strict';
3+
4+
var sourceFiles = [
5+
'*.js', '!Gruntfile.js'
6+
];
7+
8+
grunt.initConfig({
9+
pkg: grunt.file.readJSON('package.json'),
10+
11+
sync: {
12+
all: {
13+
options: {
14+
sync: ['author', 'name', 'version', 'main',
15+
'private', 'license', 'keywords', 'homepage'],
16+
}
17+
}
18+
},
19+
20+
jshint: {
21+
all: sourceFiles,
22+
options: {
23+
jshintrc: '.jshintrc'
24+
}
25+
},
26+
27+
eslint: {
28+
target: sourceFiles,
29+
options: {
30+
config: 'eslint.json',
31+
rulesdir: ['./node_modules/eslint-rules']
32+
}
33+
},
34+
35+
jscs: {
36+
src: sourceFiles,
37+
options: {
38+
config: 'jscs.json'
39+
}
40+
}
41+
});
42+
43+
var plugins = require('matchdep').filterDev('grunt-*');
44+
plugins.forEach(grunt.loadNpmTasks);
45+
46+
grunt.registerTask('lint', ['jshint', 'eslint', 'jscs']);
47+
grunt.registerTask('default', ['nice-package', 'deps-ok', 'sync', 'lint']);
48+
};

bower.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "code-snippets",
3+
"main": "turtles.js",
4+
"version": "0.1.0",
5+
"homepage": "https://github.com/bahmutov/code-snippets",
6+
"license": "MIT",
7+
"ignore": [
8+
"**/.*",
9+
"node_modules",
10+
"bower_components",
11+
"test",
12+
"tests",
13+
"docs",
14+
"Gruntfile.js",
15+
"package.json",
16+
"index.html"
17+
],
18+
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>",
19+
"keywords": [
20+
"testing",
21+
"test",
22+
"exploratory",
23+
"mock",
24+
"chrome",
25+
"devtools",
26+
"code",
27+
"snippets"
28+
]
29+
}

eslint.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
// this is JSON file, but ESLint allows C-style comments
3+
4+
"env": {
5+
"browser": true,
6+
"node": false
7+
},
8+
9+
// 0 - turn rule off
10+
// 1 - rule generates warnings
11+
// 2 - rule generates errors
12+
"rules": {
13+
"camelcase": 0,
14+
"camel_case": 0,
15+
"strict": 0,
16+
"no-undef": 1,
17+
"no-console": 0,
18+
"no-unused-vars": 1,
19+
"no-underscore-dangle": 1,
20+
"quotes": [2, "single"],
21+
"brace-style": [2, "1tbs"],
22+
"eol-last": 1,
23+
"semi": [2, "always"],
24+
"no-extra-strict": 0,
25+
"no-single-line-objects": 2,
26+
"no-nested-ternary": 2,
27+
"no-space-before-semi": 2,
28+
"no-shadow": 2,
29+
"no-undef-init": 2,
30+
"no-undefined": 0,
31+
"no-sequences": 2,
32+
"no-for-loops": 2,
33+
"no-process-exit": 0
34+
},
35+
36+
"globals": {
37+
"navigator": true,
38+
"console": true,
39+
"Promise": true
40+
}
41+
}

jscs.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"requireCurlyBraces": true,
3+
"requireDotNotation": true,
4+
"requireSpaceAfterLineComment": true,
5+
"validateQuoteMarks": "'",
6+
"validateIndentation": 2,
7+
"requireSpacesInFunctionExpression": {
8+
"beforeOpeningCurlyBrace": true
9+
},
10+
"requireSpacesInAnonymousFunctionExpression": {
11+
"beforeOpeningRoundBrace": true,
12+
"beforeOpeningCurlyBrace": true
13+
},
14+
"requireSpacesInsideObjectBrackets": "all"
15+
}

ng-profile-local-digest.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ function profileDirectiveDigest(selector) {
77
console.assert(selector && typeof selector === 'string', 'expected selector', selector);
88
var el = document.querySelector(selector);
99
console.assert(el, 'cannot find element with selector', selector);
10+
11+
/* global angular */
1012
var ngEl = angular.element(el);
1113
var scope = ngEl.scope() || ngEl.isolateScope();
1214
console.assert(scope, 'cannot find scope from element', selector);

ng-profile-scope-method.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
var methodName = 'find';
1313
var name = selector + ':' + methodName;
1414

15+
/* global angular */
1516
var el = angular.element(document.getElementById(selector));
1617
var scope = el.scope() || el.isolateScope();
1718
console.assert(scope, 'cannot find scope from ' + name);

ng-run-digest-cycle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
// runs application digest cycle starting from root scope
2+
/* global angular */
23
angular.element(document).injector().get('$rootScope').$apply();

package.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "code-snippets",
3+
"description": "Chrome DevTools code snippets ",
4+
"version": "0.1.0",
5+
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>",
6+
"bugs": {
7+
"url": "https://github.com/bahmutov/code-snippets/issues"
8+
},
9+
"contributors": [],
10+
"dependencies": {},
11+
"devDependencies": {
12+
"eslint-rules": "0.1.1",
13+
"grunt": "0.4.5",
14+
"grunt-contrib-jshint": "0.10.0",
15+
"grunt-deps-ok": "0.5.1",
16+
"grunt-eslint": "2.1.0",
17+
"grunt-gh-pages": "0.9.1",
18+
"grunt-jscs": "1.0.0",
19+
"grunt-nice-package": "0.9.2",
20+
"grunt-npm2bower-sync": "0.4.0",
21+
"matchdep": "0.3.0",
22+
"pre-git": "0.1.1"
23+
},
24+
"engines": {
25+
"node": "> 0.10.*"
26+
},
27+
"homepage": "https://github.com/bahmutov/code-snippets",
28+
"keywords": [
29+
"testing",
30+
"test",
31+
"exploratory",
32+
"mock",
33+
"chrome",
34+
"devtools",
35+
"code",
36+
"snippets"
37+
],
38+
"license": "MIT",
39+
"main": "turtles.js",
40+
"pre-commit": "npm test",
41+
"repository": {
42+
"type": "git",
43+
"url": "git@github.com:bahmutov/code-snippets.git"
44+
},
45+
"scripts": {
46+
"test": "grunt"
47+
}
48+
}

0 commit comments

Comments
 (0)