Skip to content

Commit

Permalink
adding linting via grunt
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Dec 21, 2014
1 parent a0ea08c commit 66400c0
Show file tree
Hide file tree
Showing 12 changed files with 266 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
74 changes: 74 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"maxerr" : 50,

"indent" : 2,
"bitwise" : true,
"camelcase" : true,
"curly" : true,
"eqeqeq" : true,
"forin" : true,
"immed" : false,
"latedef" : false,
"newcap" : true,
"noarg" : true,
"noempty" : true,
"nonew" : false,
"plusplus" : false,
"quotmark" : "single",
"undef" : true,
"unused" : true,
"strict" : false,
"trailing" : false,
"maxparams" : 4,
"maxdepth" : 3,
"maxstatements" : 20,
"maxcomplexity" : 20,
"maxlen" : 120,

"asi" : false,
"boss" : false,
"debug" : false,
"eqnull" : false,
"es5" : false,
"esnext" : false,
"moz" : false,
"evil" : false,
"expr" : false,
"funcscope" : false,
"globalstrict" : false,
"iterator" : false,
"lastsemic" : false,
"laxbreak" : false,
"laxcomma" : false,
"loopfunc" : false,
"multistr" : false,
"proto" : false,
"scripturl" : false,
"smarttabs" : true,
"shadow" : false,
"sub" : false,
"supernew" : false,
"validthis" : false,

"browser" : true,
"couch" : false,
"devel" : true,
"dojo" : false,
"jquery" : false,
"mootools" : false,
"node" : false,
"nonstandard" : false,
"prototypejs" : false,
"rhino" : false,
"worker" : false,
"wsh" : false,
"yui" : false,

"nomen" : false,
"onevar" : false,
"passfail" : false,
"white" : false,

"globals" : {
}
}
48 changes: 48 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = function(grunt) {
'use strict';

var sourceFiles = [
'*.js', '!Gruntfile.js'
];

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

sync: {
all: {
options: {
sync: ['author', 'name', 'version', 'main',
'private', 'license', 'keywords', 'homepage'],
}
}
},

jshint: {
all: sourceFiles,
options: {
jshintrc: '.jshintrc'
}
},

eslint: {
target: sourceFiles,
options: {
config: 'eslint.json',
rulesdir: ['./node_modules/eslint-rules']
}
},

jscs: {
src: sourceFiles,
options: {
config: 'jscs.json'
}
}
});

var plugins = require('matchdep').filterDev('grunt-*');
plugins.forEach(grunt.loadNpmTasks);

grunt.registerTask('lint', ['jshint', 'eslint', 'jscs']);
grunt.registerTask('default', ['nice-package', 'deps-ok', 'sync', 'lint']);
};
29 changes: 29 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "code-snippets",
"main": "turtles.js",
"version": "0.1.0",
"homepage": "https://github.com/bahmutov/code-snippets",
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"docs",
"Gruntfile.js",
"package.json",
"index.html"
],
"author": "Gleb Bahmutov <[email protected]>",
"keywords": [
"testing",
"test",
"exploratory",
"mock",
"chrome",
"devtools",
"code",
"snippets"
]
}
41 changes: 41 additions & 0 deletions eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
// this is JSON file, but ESLint allows C-style comments

"env": {
"browser": true,
"node": false
},

// 0 - turn rule off
// 1 - rule generates warnings
// 2 - rule generates errors
"rules": {
"camelcase": 0,
"camel_case": 0,
"strict": 0,
"no-undef": 1,
"no-console": 0,
"no-unused-vars": 1,
"no-underscore-dangle": 1,
"quotes": [2, "single"],
"brace-style": [2, "1tbs"],
"eol-last": 1,
"semi": [2, "always"],
"no-extra-strict": 0,
"no-single-line-objects": 2,
"no-nested-ternary": 2,
"no-space-before-semi": 2,
"no-shadow": 2,
"no-undef-init": 2,
"no-undefined": 0,
"no-sequences": 2,
"no-for-loops": 2,
"no-process-exit": 0
},

"globals": {
"navigator": true,
"console": true,
"Promise": true
}
}
15 changes: 15 additions & 0 deletions jscs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"requireCurlyBraces": true,
"requireDotNotation": true,
"requireSpaceAfterLineComment": true,
"validateQuoteMarks": "'",
"validateIndentation": 2,
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInsideObjectBrackets": "all"
}
2 changes: 2 additions & 0 deletions ng-profile-local-digest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ function profileDirectiveDigest(selector) {
console.assert(selector && typeof selector === 'string', 'expected selector', selector);
var el = document.querySelector(selector);
console.assert(el, 'cannot find element with selector', selector);

/* global angular */
var ngEl = angular.element(el);
var scope = ngEl.scope() || ngEl.isolateScope();
console.assert(scope, 'cannot find scope from element', selector);
Expand Down
1 change: 1 addition & 0 deletions ng-profile-scope-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
var methodName = 'find';
var name = selector + ':' + methodName;

/* global angular */
var el = angular.element(document.getElementById(selector));
var scope = el.scope() || el.isolateScope();
console.assert(scope, 'cannot find scope from ' + name);
Expand Down
1 change: 1 addition & 0 deletions ng-run-digest-cycle.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// runs application digest cycle starting from root scope
/* global angular */
angular.element(document).injector().get('$rootScope').$apply();
48 changes: 48 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "code-snippets",
"description": "Chrome DevTools code snippets ",
"version": "0.1.0",
"author": "Gleb Bahmutov <[email protected]>",
"bugs": {
"url": "https://github.com/bahmutov/code-snippets/issues"
},
"contributors": [],
"dependencies": {},
"devDependencies": {
"eslint-rules": "0.1.1",
"grunt": "0.4.5",
"grunt-contrib-jshint": "0.10.0",
"grunt-deps-ok": "0.5.1",
"grunt-eslint": "2.1.0",
"grunt-gh-pages": "0.9.1",
"grunt-jscs": "1.0.0",
"grunt-nice-package": "0.9.2",
"grunt-npm2bower-sync": "0.4.0",
"matchdep": "0.3.0",
"pre-git": "0.1.1"
},
"engines": {
"node": "> 0.10.*"
},
"homepage": "https://github.com/bahmutov/code-snippets",
"keywords": [
"testing",
"test",
"exploratory",
"mock",
"chrome",
"devtools",
"code",
"snippets"
],
"license": "MIT",
"main": "turtles.js",
"pre-commit": "npm test",
"repository": {
"type": "git",
"url": "[email protected]:bahmutov/code-snippets.git"
},
"scripts": {
"test": "grunt"
}
}
4 changes: 3 additions & 1 deletion profile-method-call.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(function profileMethodCall() {
var object = primesApp;
var object = window.primesApp;
console.assert(object, 'cannot find object to profile');

var methodName = 'findFirstPrimes';
var originalMethod = object[methodName];
console.assert(typeof originalMethod === 'function', 'cannot find method ' + methodName);
Expand Down
4 changes: 3 additions & 1 deletion time-method-call.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(function timeMethodCall() {
var object = primesApp;
var object = window.primesApp;
console.assert(object, 'cannot find object to profile');

var methodName = 'findFirstPrimes';
var originalMethod = object[methodName];
console.assert(typeof originalMethod === 'function', 'cannot find method ' + methodName);
Expand Down

0 comments on commit 66400c0

Please sign in to comment.