diff --git a/.eslintignore b/.eslintignore index 35fe41826..f1e4f3b08 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ node_modules lib/static -coverage/ \ No newline at end of file +coverage/ +lib/GUI/ diff --git a/.eslintrc b/.eslintrc index 7ff6e1ae7..14356f71b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,8 +9,11 @@ # Created to work with eslint@0.18.0 # +extends: ["eslint:recommended", "google"] + env: node: true + browser: true es6: true rules: @@ -43,3 +46,22 @@ rules: # useful for code clean-up no-unused-vars: [1, {"vars": "all", "args": "none"}] + max-len: [1, 160] + + # camelcase is standard, but this should be 1 and then 2 soon + camelcase: 0 + + # configuration that should be upgraded progresivelly + require-jsdoc: 1 + valid-jsdoc: 1 + prefer-spread: 1 + no-constant-condition: 1 + no-var: 1 + no-empty: 1 + guard-for-in: 1 + no-invalid-this: 1 + new-cap: 1 + one-var: 1 + no-redeclare: 1 + prefer-rest-params: 1 + no-console: [1, {"allow": ["log", "warn"]}] \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 2bf41a705..9425a3bc5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,36 +4,36 @@ module.exports = function(grunt) { browserify: { dist: { files: { - 'lib/static/main.js': [ 'lib/GUI/js/main.js' ] + 'lib/static/main.js': ['lib/GUI/js/main.js'], }, options: { debug: true, - transform: [ 'browserify-handlebars' ] - } - } + transform: ['browserify-handlebars'], + }, + }, }, less: { dist: { files: { - 'lib/static/main.css': [ 'lib/GUI/css/main.less' ] + 'lib/static/main.css': ['lib/GUI/css/main.less'], }, options: { - sourceMap: false - } - } + sourceMap: false, + }, + }, }, watch: { - files: [ 'lib/GUI/**/*' ], - tasks: [ 'default' ] - } - }) + files: ['lib/GUI/**/*'], + tasks: ['default'], + }, + }); - grunt.loadNpmTasks('grunt-browserify') - grunt.loadNpmTasks('grunt-contrib-watch') - grunt.loadNpmTasks('grunt-contrib-less') + grunt.loadNpmTasks('grunt-browserify'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-less'); grunt.registerTask('default', [ 'browserify', - 'less' - ]) -} + 'less', + ]); +}; diff --git a/bin/verdaccio b/bin/verdaccio index 87170d755..d2316ff6d 100755 --- a/bin/verdaccio +++ b/bin/verdaccio @@ -1,3 +1,3 @@ #!/usr/bin/env node -require('../lib/cli') +require('../lib/cli'); diff --git a/index.js b/index.js index 787844980..3dc713f1a 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ -module.exports = require('./lib') +module.exports = require('./lib'); -/**package +/** package { "name": "verdaccio", "version": "0.0.0", "dependencies": {"js-yaml": "*"}, diff --git a/lib/GUI/js/bootstrap-modal.js b/lib/GUI/js/bootstrap-modal.js index 8b0e269bc..634249010 100644 --- a/lib/GUI/js/bootstrap-modal.js +++ b/lib/GUI/js/bootstrap-modal.js @@ -7,275 +7,272 @@ * ======================================================================== */ -+function ($) { ++function($) { 'use strict'; // MODAL CLASS DEFINITION // ====================== - var Modal = function (element, options) { - this.options = options - this.$body = $(document.body) - this.$element = $(element) - this.$backdrop = - this.isShown = null - this.scrollbarWidth = 0 + let Modal = function(element, options) { + this.options = options; + this.$body = $(document.body); + this.$element = $(element); + this.$backdrop = + this.isShown = null; + this.scrollbarWidth = 0; if (this.options.remote) { this.$element .find('.modal-content') - .load(this.options.remote, $.proxy(function () { - this.$element.trigger('loaded.bs.modal') - }, this)) + .load(this.options.remote, $.proxy(function() { + this.$element.trigger('loaded.bs.modal'); + }, this)); } - } + }; - Modal.VERSION = '3.3.0' + Modal.VERSION = '3.3.0'; - Modal.TRANSITION_DURATION = 300 - Modal.BACKDROP_TRANSITION_DURATION = 150 + Modal.TRANSITION_DURATION = 300; + Modal.BACKDROP_TRANSITION_DURATION = 150; Modal.DEFAULTS = { backdrop: true, keyboard: true, - show: true - } + show: true, + }; - Modal.prototype.toggle = function (_relatedTarget) { - return this.isShown ? this.hide() : this.show(_relatedTarget) - } + Modal.prototype.toggle = function(_relatedTarget) { + return this.isShown ? this.hide() : this.show(_relatedTarget); + }; - Modal.prototype.show = function (_relatedTarget) { - var that = this - var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) + Modal.prototype.show = function(_relatedTarget) { + let that = this; + let e = $.Event('show.bs.modal', {relatedTarget: _relatedTarget}); - this.$element.trigger(e) + this.$element.trigger(e); - if (this.isShown || e.isDefaultPrevented()) return + if (this.isShown || e.isDefaultPrevented()) return; - this.isShown = true + this.isShown = true; - this.checkScrollbar() - this.$body.addClass('modal-open') + this.checkScrollbar(); + this.$body.addClass('modal-open'); - this.setScrollbar() - this.escape() + this.setScrollbar(); + this.escape(); - this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) + this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)); - this.backdrop(function () { - var transition = $.support.transition && that.$element.hasClass('fade') + this.backdrop(function() { + let transition = $.support.transition && that.$element.hasClass('fade'); if (!that.$element.parent().length) { - that.$element.appendTo(that.$body) // don't move modals dom position + that.$element.appendTo(that.$body); // don't move modals dom position } that.$element .show() - .scrollTop(0) + .scrollTop(0); if (transition) { - that.$element[0].offsetWidth // force reflow + that.$element[0].offsetWidth; // force reflow } that.$element .addClass('in') - .attr('aria-hidden', false) + .attr('aria-hidden', false); - that.enforceFocus() + that.enforceFocus(); - var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) + let e = $.Event('shown.bs.modal', {relatedTarget: _relatedTarget}); transition ? that.$element.find('.modal-dialog') // wait for modal to slide in - .one('bsTransitionEnd', function () { - that.$element.trigger('focus').trigger(e) + .one('bsTransitionEnd', function() { + that.$element.trigger('focus').trigger(e); }) .emulateTransitionEnd(Modal.TRANSITION_DURATION) : - that.$element.trigger('focus').trigger(e) - }) - } + that.$element.trigger('focus').trigger(e); + }); + }; - Modal.prototype.hide = function (e) { - if (e) e.preventDefault() + Modal.prototype.hide = function(e) { + if (e) e.preventDefault(); - e = $.Event('hide.bs.modal') + e = $.Event('hide.bs.modal'); - this.$element.trigger(e) + this.$element.trigger(e); - if (!this.isShown || e.isDefaultPrevented()) return + if (!this.isShown || e.isDefaultPrevented()) return; - this.isShown = false + this.isShown = false; - this.escape() + this.escape(); - $(document).off('focusin.bs.modal') + $(document).off('focusin.bs.modal'); this.$element .removeClass('in') .attr('aria-hidden', true) - .off('click.dismiss.bs.modal') + .off('click.dismiss.bs.modal'); $.support.transition && this.$element.hasClass('fade') ? this.$element .one('bsTransitionEnd', $.proxy(this.hideModal, this)) .emulateTransitionEnd(Modal.TRANSITION_DURATION) : - this.hideModal() - } + this.hideModal(); + }; - Modal.prototype.enforceFocus = function () { + Modal.prototype.enforceFocus = function() { $(document) .off('focusin.bs.modal') // guard against infinite focus loop - .on('focusin.bs.modal', $.proxy(function (e) { + .on('focusin.bs.modal', $.proxy(function(e) { if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { - this.$element.trigger('focus') + this.$element.trigger('focus'); } - }, this)) - } + }, this)); + }; - Modal.prototype.escape = function () { + Modal.prototype.escape = function() { if (this.isShown && this.options.keyboard) { - this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) { - e.which == 27 && this.hide() - }, this)) + this.$element.on('keydown.dismiss.bs.modal', $.proxy(function(e) { + e.which == 27 && this.hide(); + }, this)); } else if (!this.isShown) { - this.$element.off('keydown.dismiss.bs.modal') + this.$element.off('keydown.dismiss.bs.modal'); } - } + }; - Modal.prototype.hideModal = function () { - var that = this - this.$element.hide() - this.backdrop(function () { - that.$body.removeClass('modal-open') - that.resetScrollbar() - that.$element.trigger('hidden.bs.modal') - }) - } + Modal.prototype.hideModal = function() { + let that = this; + this.$element.hide(); + this.backdrop(function() { + that.$body.removeClass('modal-open'); + that.resetScrollbar(); + that.$element.trigger('hidden.bs.modal'); + }); + }; - Modal.prototype.removeBackdrop = function () { - this.$backdrop && this.$backdrop.remove() - this.$backdrop = null - } + Modal.prototype.removeBackdrop = function() { + this.$backdrop && this.$backdrop.remove(); + this.$backdrop = null; + }; - Modal.prototype.backdrop = function (callback) { - var that = this - var animate = this.$element.hasClass('fade') ? 'fade' : '' + Modal.prototype.backdrop = function(callback) { + let that = this; + let animate = this.$element.hasClass('fade') ? 'fade' : ''; if (this.isShown && this.options.backdrop) { - var doAnimate = $.support.transition && animate + let doAnimate = $.support.transition && animate; this.$backdrop = $('