mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
style(jshint): add jshint config and setup grunt task
This commit is contained in:
100
.jshintrc
Normal file
100
.jshintrc
Normal file
@ -0,0 +1,100 @@
|
||||
{
|
||||
// http://www.jshint.com/docs/
|
||||
// Based on node-jshint@2.x.x
|
||||
|
||||
// ENFORCING OPTIONS
|
||||
// These options tell JSHint to be more strict towards your code. Use them if
|
||||
// you want to allow only a safe subset of JavaScript—very useful when your
|
||||
// codebase is shared with a big number of developers with different skill
|
||||
// levels.
|
||||
|
||||
"bitwise": true, //prohibits the use of bitwise operators such as ^ (XOR), | (OR) and others
|
||||
"camelcase": false, //force all variable names to use either camelCase style or UPPER_CASE with underscores
|
||||
"curly": true, //requires you to always put curly braces around blocks in loops and conditionals
|
||||
"eqeqeq": true, //prohibits the use of == and != in favor of === and !==
|
||||
"es3": false, //tells JSHint that your code needs to adhere to ECMAScript 3 specification
|
||||
"forin": true, //requires all `for in` loops to filter object's items with `hasOwnProperty()`
|
||||
"immed": true, //prohibits the use of immediate function invocations without wrapping them in parentheses
|
||||
"indent": 2, //enforces specific tab width
|
||||
"latedef": true, //prohibits the use of a variable before it was defined
|
||||
"newcap": true, //requires you to capitalize names of constructor functions
|
||||
"noarg": true, //prohibits the use of `arguments.caller` and `arguments.callee`
|
||||
"noempty": true, //warns when you have an empty block in your code
|
||||
"nonew": true, //prohibits the use of constructor functions for side-effects
|
||||
"plusplus": false, //prohibits the use of unary increment and decrement operators
|
||||
"quotmark": true, //enforces the consistency of quotation marks used throughout your code
|
||||
"undef": true, //prohibits the use of explicitly undeclared variables
|
||||
"unused": "vars", //warns when you define and never use your variables
|
||||
"strict": true, //requires all functions to run in ECMAScript 5's strict mode
|
||||
"trailing": true, //makes it an error to leave a trailing whitespace in your code
|
||||
"maxparams": false, //set the max number of formal parameters allowed per function
|
||||
"maxdepth": 3, //control how nested do you want your blocks to be
|
||||
"maxstatements": false, //set the max number of statements allowed per function
|
||||
"maxcomplexity": false, //control cyclomatic complexity throughout your code
|
||||
"maxlen": 99, //set the maximum length of a line
|
||||
|
||||
// RELAXING OPTIONS
|
||||
// These options allow you to suppress certain types of warnings. Use them
|
||||
// only if you are absolutely positive that you know what you are doing.
|
||||
|
||||
"asi": false, //suppresses warnings about missing semicolons
|
||||
"boss": false, //suppresses warnings about the use of assignments in cases where comparisons are expected
|
||||
"debug": false, //suppresses warnings about the debugger statements in your code
|
||||
"eqnull": false, //suppresses warnings about == null comparisons
|
||||
"esnext": false, //your code uses ES.next specific features such as const
|
||||
"evil": false, //suppresses warnings about the use of eval
|
||||
"expr": true, //suppresses warnings about the use of expressions where normally you would expect to see assignments or function calls
|
||||
"funcscope": false, //suppresses warnings about declaring variables inside of control structures while accessing them later from the outside
|
||||
"globalstrict": false, //suppresses warnings about the use of global strict mode
|
||||
"iterator": false, //suppresses warnings about the `__iterator__` property
|
||||
"lastsemic": false, //suppresses warnings about missing semicolons, but only when the semicolon is omitted for the last statement in a one-line block
|
||||
"laxbreak": false, //suppresses most of the warnings about possibly unsafe line breakings in your code
|
||||
"laxcomma": false, //suppresses warnings about comma-first coding style
|
||||
"loopfunc": false, //suppresses warnings about functions inside of loops
|
||||
"moz": false, //tells JSHint that your code uses Mozilla JavaScript extensions
|
||||
"multistr": false, //suppresses warnings about multi-line strings
|
||||
"proto": false, //suppresses warnings about the `__proto__` property
|
||||
"scripturl": false, //suppresses warnings about the use of script-targeted URLs—such as `javascript:...`
|
||||
"smarttabs": false, //suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only
|
||||
"shadow": false, //suppresses warnings about variable shadowing
|
||||
"sub": false, //suppresses warnings about using `[]` notation when it can be expressed in dot notation
|
||||
"supernew": false, //suppresses warnings about "weird" constructions like `new function () { ... }` and `new Object;`
|
||||
"validthis": false, //suppresses warnings about possible strict violations when the code is running in strict mode and you use `this` in a non-constructor function
|
||||
|
||||
// ENVIRONMENTS
|
||||
// These options pre-define global variables that are exposed by popular
|
||||
// JavaScript libraries and runtime environments—such as browser or node.js.
|
||||
// Essentially they are shortcuts for explicit declarations like
|
||||
// /*global $:false, jQuery:false */
|
||||
|
||||
"browser": true, //defines globals exposed by modern browsers
|
||||
"couch": false, //defines globals exposed by CouchDB
|
||||
"devel": true, //defines globals that are usually used for logging poor-man's debugging: `console`, `alert`, etc.
|
||||
"dojo": false, //defines globals exposed by the Dojo Toolkit
|
||||
"jquery": true, //defines globals exposed by the jQuery JavaScript library
|
||||
"mootools": false, //defines globals exposed by the MooTools JavaScript framework
|
||||
"node": true, //defines globals available when your code is running inside of the Node runtime environment
|
||||
"nonstandard": false, //defines non-standard but widely adopted globals such as `escape` and `unescape`
|
||||
"phantom": false, //defines globals available when your core is running inside of the PhantomJS runtime environment
|
||||
"prototypejs": false, //defines globals exposed by the Prototype JavaScript framework
|
||||
"rhino": false, //defines globals available when your code is running inside of the Rhino runtime environment
|
||||
"worker": true, //defines globals available when your code is running inside of a Web Worker
|
||||
"wsh": false, //defines globals available when your code is running as a script for the Windows Script Host
|
||||
"yui": false, //defines globals exposed by the YUI JavaScript framework
|
||||
|
||||
"globals": {
|
||||
"define": false,
|
||||
"throttle": false,
|
||||
"delay": false,
|
||||
"debounce": false
|
||||
},
|
||||
|
||||
// LEGACY
|
||||
// These options are legacy from JSLint. Aside from bug fixes they will not
|
||||
// be improved in any way and might be removed at any point.
|
||||
|
||||
"nomen": false, //disallows the use of dangling `_` in variables
|
||||
"onevar": false, //allows only one `var` statement per function
|
||||
"passfail": false, //makes JSHint stop on the first error or warning
|
||||
"white": false //make JSHint check your source code against Douglas Crockford's JavaScript coding style
|
||||
}
|
110
Gruntfile.js
110
Gruntfile.js
@ -1,9 +1,12 @@
|
||||
/*global module:false*/
|
||||
// global module:false
|
||||
module.exports = function(grunt) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
|
||||
meta: {
|
||||
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
|
||||
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
|
||||
@ -17,41 +20,46 @@ module.exports = function(grunt) {
|
||||
'Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
|
||||
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */ '
|
||||
},
|
||||
|
||||
concat: {
|
||||
options: {
|
||||
stripBanners: true,
|
||||
banner: '<%= meta.banner %>'
|
||||
},
|
||||
dist_js: {
|
||||
src: ['src/jquery.coords.js', 'src/jquery.collision.js', 'src/utils.js', 'src/jquery.draggable.js', 'src/jquery.<%= pkg.name %>.js'],
|
||||
src: ['src/jquery.coords.js', 'src/jquery.collision.js', 'src/utils.js',
|
||||
'src/jquery.draggable.js', 'src/jquery.<%= pkg.name %>.js'],
|
||||
dest: 'dist/jquery.<%= pkg.name %>.js'
|
||||
},
|
||||
|
||||
dist_extras_js: {
|
||||
src: ['src/jquery.coords.js', 'src/jquery.collision.js', 'src/utils.js', 'src/jquery.draggable.js', 'src/jquery.<%= pkg.name %>.js', 'src/jquery.<%= pkg.name %>.extras.js'],
|
||||
src: ['src/jquery.coords.js', 'src/jquery.collision.js', 'src/utils.js',
|
||||
'src/jquery.draggable.js', 'src/jquery.<%= pkg.name %>.js',
|
||||
'src/jquery.<%= pkg.name %>.extras.js'],
|
||||
dest: 'dist/jquery.<%= pkg.name %>.with-extras.js'
|
||||
},
|
||||
|
||||
dist_css: {
|
||||
src: ['src/jquery.<%= pkg.name %>.css'],
|
||||
dest: 'dist/jquery.<%= pkg.name %>.css'
|
||||
},
|
||||
|
||||
dist_demo_js: {
|
||||
src: ['src/jquery.coords.js', 'src/jquery.collision.js', 'src/utils.js', 'src/jquery.draggable.js', 'src/jquery.<%= pkg.name %>.js'],
|
||||
src: ['src/jquery.coords.js', 'src/jquery.collision.js',
|
||||
'src/utils.js', 'src/jquery.draggable.js',
|
||||
'src/jquery.<%= pkg.name %>.js'],
|
||||
dest: 'gh-pages/dist/jquery.<%= pkg.name %>.js'
|
||||
},
|
||||
|
||||
dist_extras_demo_js: {
|
||||
src: ['src/jquery.coords.js', 'src/jquery.collision.js', 'src/utils.js', 'src/jquery.draggable.js', 'src/jquery.<%= pkg.name %>.js', 'src/jquery.<%= pkg.name %>.extras.js'],
|
||||
src: ['src/jquery.coords.js', 'src/jquery.collision.js',
|
||||
'src/utils.js', 'src/jquery.draggable.js',
|
||||
'src/jquery.<%= pkg.name %>.js',
|
||||
'src/jquery.<%= pkg.name %>.extras.js'],
|
||||
dest: 'gh-pages/dist/jquery.<%= pkg.name %>.with-extras.js'
|
||||
},
|
||||
|
||||
dist_demo_css: {
|
||||
src: ['src/jquery.<%= pkg.name %>.css'],
|
||||
dest: 'gh-pages/dist/jquery.<%= pkg.name %>.css'
|
||||
}
|
||||
},
|
||||
|
||||
uglify: {
|
||||
options: {
|
||||
banner: '<%= meta.minibanner %>'
|
||||
@ -61,22 +69,25 @@ module.exports = function(grunt) {
|
||||
'dist/jquery.<%= pkg.name %>.min.js': ['<%= concat.dist_js.dest %>']
|
||||
}
|
||||
},
|
||||
|
||||
dist_extras: {
|
||||
files: {
|
||||
'dist/jquery.<%= pkg.name %>.with-extras.min.js': ['<%= concat.dist_extras_js.dest %>']
|
||||
'dist/jquery.<%= pkg.name %>.with-extras.min.js': [
|
||||
'<%= concat.dist_extras_js.dest %>'
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
dist_demo: {
|
||||
files: {
|
||||
'gh-pages/dist/jquery.<%= pkg.name %>.min.js': ['<%= concat.dist_js.dest %>'],
|
||||
'gh-pages/dist/jquery.<%= pkg.name %>.min.js': [
|
||||
'<%= concat.dist_js.dest %>'
|
||||
],
|
||||
}
|
||||
},
|
||||
|
||||
dist_extras_demo: {
|
||||
files: {
|
||||
'gh-pages/dist/jquery.<%= pkg.name %>.with-extras.min.js': ['<%= concat.dist_extras_js.dest %>']
|
||||
'gh-pages/dist/jquery.<%= pkg.name %>.with-extras.min.js': [
|
||||
'<%= concat.dist_extras_js.dest %>'
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -87,46 +98,34 @@ module.exports = function(grunt) {
|
||||
banner: '<%= meta.minibanner %>'
|
||||
},
|
||||
files: {
|
||||
"dist/jquery.<%= pkg.name %>.min.css": ["dist/jquery.<%= pkg.name %>.css"],
|
||||
"gh-pages/dist/jquery.<%= pkg.name %>.min.css": ["dist/jquery.<%= pkg.name %>.css"]
|
||||
'dist/jquery.<%= pkg.name %>.min.css': [
|
||||
'dist/jquery.<%= pkg.name %>.css'
|
||||
],
|
||||
'gh-pages/dist/jquery.<%= pkg.name %>.min.css': [
|
||||
'dist/jquery.<%= pkg.name %>.css'
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
jshint: {
|
||||
files: ['grunt.js', 'src/**/*.js', 'test/**/*.js']
|
||||
},
|
||||
watch: {
|
||||
files: ['<%= lint.files %>', 'src/jquery.<%= pkg.name %>.css'],
|
||||
tasks: 'min concat'
|
||||
},
|
||||
jshint: {
|
||||
files: ['Gruntfile.js', 'src/**.js'],
|
||||
options: {
|
||||
curly: true,
|
||||
eqeqeq: true,
|
||||
immed: true,
|
||||
latedef: true,
|
||||
newcap: true,
|
||||
noarg: true,
|
||||
sub: true,
|
||||
undef: true,
|
||||
boss: true,
|
||||
eqnull: true,
|
||||
browser: true
|
||||
},
|
||||
globals: {
|
||||
jQuery: true
|
||||
jshintrc: true,
|
||||
reporter: require('jshint-stylish')
|
||||
}
|
||||
},
|
||||
|
||||
yuidoc: {
|
||||
compile: {
|
||||
"name": 'gridster.js',
|
||||
"description": 'gridster.js, a drag-and-drop multi-column jQuery grid plugin',
|
||||
"version": '0.1.0',
|
||||
"url": 'http://gridster.net/',
|
||||
"logo": 'https://ducksboard.com/static/images/svg/logo-ducksboard-black-small.svg',
|
||||
name: 'gridster.js',
|
||||
description: 'gridster.js, a drag-and-drop multi-column jQuery grid plugin',
|
||||
version: '0.1.0',
|
||||
url: 'http://gridster.net/',
|
||||
logo: 'https://ducksboard.com/static/images/svg/logo-ducksboard-black-small.svg',
|
||||
options: {
|
||||
paths: "src/",
|
||||
outdir: "gh-pages/docs/"
|
||||
paths: 'src/',
|
||||
outdir: 'gh-pages/docs/'
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -143,7 +142,8 @@ module.exports = function(grunt) {
|
||||
tagMessage: 'Version %VERSION%',
|
||||
push: false,
|
||||
pushTo: 'origin',
|
||||
gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
|
||||
// options to use with '$ git describe'
|
||||
gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d'
|
||||
}
|
||||
},
|
||||
|
||||
@ -180,11 +180,17 @@ module.exports = function(grunt) {
|
||||
grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'cssmin']);
|
||||
grunt.registerTask('build', ['default']);
|
||||
grunt.registerTask('docs', ['yuidoc']);
|
||||
grunt.registerTask('test', ['karma']);
|
||||
|
||||
grunt.registerTask('release', ['build', 'bump-only:patch', 'build', 'docs', 'changelog']);
|
||||
grunt.registerTask('release:minor', ['build', 'bump-only:minor', 'build', 'docs', 'changelog']);
|
||||
grunt.registerTask('release:major', ['build', 'bump-only:major', 'build', 'docs', 'changelog']);
|
||||
grunt.registerTask('release:git', ['build', 'bump-only:git', 'build', 'docs', 'changelog', 'bump-commit']);
|
||||
grunt.registerTask('release:commit', ['bump-commit']);
|
||||
grunt.registerTask('release', [
|
||||
'build', 'bump-only:patch', 'build', 'docs', 'changelog']);
|
||||
grunt.registerTask('release:minor', [
|
||||
'build', 'bump-only:minor', 'build', 'docs', 'changelog']);
|
||||
grunt.registerTask('release:major', [
|
||||
'build', 'bump-only:major', 'build', 'docs', 'changelog']);
|
||||
grunt.registerTask('release:git', [
|
||||
'build', 'bump-only:git', 'build', 'docs', 'changelog', 'bump-commit']);
|
||||
grunt.registerTask('release:commit', [
|
||||
'bump-commit']);
|
||||
|
||||
};
|
||||
|
@ -31,12 +31,13 @@
|
||||
"grunt-bump": "0.0.11",
|
||||
"grunt-contrib-concat": "~0.1.3",
|
||||
"grunt-contrib-cssmin": "~0.5.0",
|
||||
"grunt-contrib-jshint": "~0.3.0",
|
||||
"grunt-contrib-jshint": "^0.11.2",
|
||||
"grunt-contrib-uglify": "~0.2.0",
|
||||
"grunt-contrib-watch": "~0.3.1",
|
||||
"grunt-contrib-yuidoc": "~0.4.0",
|
||||
"grunt-conventional-changelog": "~1.0.0",
|
||||
"grunt-karma": "^0.10.1",
|
||||
"jshint-stylish": "^1.0.1",
|
||||
"karma": "^0.12.31",
|
||||
"karma-chai": "^0.1.0",
|
||||
"karma-chrome-launcher": "^0.1.7",
|
||||
|
Reference in New Issue
Block a user