Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update jshint settings and fix some warnings

  • Loading branch information...
commit f4b52d2e7b721d0391fcee40ce60794fa4182887 1 parent a23c693
Jacob Rask authored
22 .jshintrc
View
@@ -1,6 +1,22 @@
{
- "strict": true,
- "node": true,
"browser": true,
- "eqnull": true
+ "node": true,
+
+ "camelcase": true,
+ "immed": true,
+ "newcap": true,
+ "undef": true,
+ "unused": true,
+ "strict": true,
+ "maxparams": 3,
+ "maxdepth": 3,
+ "maxstatements": 15,
+ "maxcomplexity": 6,
+ "maxlen": 80,
+
+ "boss": true,
+ "eqnull": true,
+ "es5": true,
+ "laxbreak": true,
+ "supernew": true
}
16 Makefile
View
@@ -1,4 +1,3 @@
-BUSTER := ./node_modules/.bin/buster
GRUNT := ./node_modules/grunt/bin/grunt
all: build
@@ -9,20 +8,7 @@ build:
build-dev:
@$(GRUNT) dev
-test-server:
- @$(BUSTER)-server
-
-test:
- @$(BUSTER)-test
- @$(BUSTER)-test --browser
-
-examples: build-dev
- @./bin/styledocco -n StyleDocco -o ./examples/styledocco \
- --include share/previews.css share/docs.css
- @./bin/styledocco -n "Twitter Bootstrap" -o ./examples/bootstrap/docs \
- examples/bootstrap/less
-
lint:
$(GRUNT) lint
-.PHONY: all build test examples lint
+.PHONY: all build lint
21 grunt.js
View
@@ -40,13 +40,30 @@ module.exports = function(grunt) {
files: [ 'web/**', 'grunt.js' ],
tasks: 'browserify concat'
},
+ lint: {
+ files: [ 'web/app.js', 'web/models/*.js', 'web/views/*.js' ]
+ },
jshint: {
options: {
- strict: true,
browser: true,
node: true,
+ camelcase: true,
+ immed: true,
+ newcap: true,
+ undef: true,
+ unused: true,
+ strict: true,
+ maxparams: 3,
+ maxdepth: 3,
+ maxstatements: 15,
+ maxcomplexity: 6,
+ maxlen: 80,
+ boss: true,
eqnull: true,
- globalstrict: true
+ es5: true,
+ globalstrict: true,
+ laxbreak: true,
+ supernew: true
},
globals: {
styledocco: true
10 web/app.js
View
@@ -4,6 +4,7 @@
'use strict';
var doc = document;
+var project = window.styledocco.project;
// External dependencies
// =====================
@@ -25,7 +26,6 @@ var DocuView = require('./views/Documentation');
// Initialize models
// =================
-// Do as much as possible before DOM ready to start sending out XHR's immediately.
// Wrapper around jQuery.ajax to make it compatible with async.
var ajax = function (path, cb) {
@@ -36,19 +36,19 @@ var ajax = function (path, cb) {
};
var docus = new DocuCollection();
-_.forEach(styledocco.project.stylesheets, function (file) {
+_.forEach(project.stylesheets, function (file) {
docus.add(new Docu({ path: file }));
});
-if (styledocco.project.includes) {
- async.map(styledocco.project.includes, ajax, function (err, res) {
+if (project.includes) {
+ async.map(project.includes, ajax, function (err, res) {
docus.forEach(function (docu) {
docu.set('extraCss', res.join(''));
});
});
}
-var navbar = new NavbarModel({ name: styledocco.project.name });
+var navbar = new NavbarModel({ name: project.name });
var Router = Backbone.Router.extend({
routes: {
34 web/models/Preview.js
View
@@ -1,34 +0,0 @@
-'use strict';
-
-var Backbone = require('backbone');
-var Model = Backbone.Model;
-
-var Preview = Model.extend({
-
- initialize: function() {
-
-
- },
-
- // Get the actual height of the iframe's content by getting the distance
- // between the element`s offsetParent and the bottom-most point of any child
- // elements. `offsetHeight` does not work with absolute or fixed positioned elements.
- getHeight: function() {
- var elem = this.iframe.contentDocument.body;
- if (elem.childElementCount === 0) return elem.offsetHeight;
- var win = elem.ownerDocument.defaultView;
- var children = elem.getElementsByTagName('*');
- for (var i = 0, l = children.length, childHeights = [], child; i < l; i++) {
- child = children[i];
- childHeights.push(child.offsetTop + child.offsetHeight +
- parseInt(win.getComputedStyle(child).getPropertyValue('margin-bottom'), 10)
- );
- }
- var extraHeight = parseInt(win.getComputedStyle(elem).getPropertyValue('padding-bottom'), 10);
- var height = Math.max.apply(Math, childHeights) + extraHeight;
- return Math.max(height, elem.offsetHeight);
- }
-
-});
-
-module.exports = Preview;
6 web/views/Preview.js
View
@@ -27,7 +27,7 @@ var PreviewView = View.extend({
// Get the actual height of the iframe's content by getting the distance
// between the element`s offsetParent and the bottom-most point of any child
- // elements. `offsetHeight` does not work with absolute or fixed positioned elements.
+ // elements. `offsetHeight` does not work with positioned elements.
getHeight: function(cb) {
this.getIframeDoc(function(doc) {
$(doc).ready(function() {
@@ -73,7 +73,7 @@ var PreviewView = View.extend({
]),
el
);
- this.getIframeDoc(function(doc, ev) {
+ this.getIframeDoc(function(doc) {
doc.write(
'<!DOCTYPE html><html><head><style></style><script></script></head><body>' +
el.innerText || ''
@@ -90,7 +90,7 @@ var PreviewView = View.extend({
updateCss: function() {
var coll = this.model.collection;
var css = coll.pluck('css').join('') + this.model.get('extraCss');
- this.getIframeDoc(_.bind(function(doc, ev) {
+ this.getIframeDoc(_.bind(function(doc) {
doc.head.getElementsByTagName('style')[0].textContent = css;
this.trigger('iframeChange');
}, this));
Please sign in to comment.
Something went wrong with that request. Please try again.