Browse Source

add linter

pull/342/head
Guillaume Vincent 8 years ago
parent
commit
c35ed5b8fd
3 changed files with 33 additions and 25 deletions
  1. +12
    -12
      gulpfile.js
  2. +14
    -2
      package.json
  3. +7
    -11
      password-generator.js

+ 12
- 12
gulpfile.js View File

@@ -1,4 +1,4 @@
"use strict";
'use strict';


var gulp = require('gulp'); var gulp = require('gulp');
var del = require('del'); var del = require('del');
@@ -7,21 +7,21 @@ var autoprefixer = require('gulp-autoprefixer');
var minifyCss = require('gulp-cssnano'); var minifyCss = require('gulp-cssnano');


var paths = { var paths = {
build: "dist/",
build: 'dist/',
html: [ html: [
'index.html' 'index.html'
], ],
js: [ js: [
'password-generator.js' 'password-generator.js'
], ],
js_vendors: [
jsVendors: [
'node_modules/lesspass/dist/lesspass.min.js', 'node_modules/lesspass/dist/lesspass.min.js',
'node_modules/clipboard/dist/clipboard.min.js' 'node_modules/clipboard/dist/clipboard.min.js'
], ],
styles: [ styles: [
'style.css' 'style.css'
], ],
styles_vendors: [
stylesVendors: [
'node_modules/bootstrap/dist/css/bootstrap.min.css', 'node_modules/bootstrap/dist/css/bootstrap.min.css',
'node_modules/font-awesome/css/font-awesome.min.css', 'node_modules/font-awesome/css/font-awesome.min.css',
'node_modules/hint.css/hint.min.css' 'node_modules/hint.css/hint.min.css'
@@ -61,8 +61,8 @@ gulp.task('styles', function () {
.pipe(gulp.dest(paths.build + '/styles')); .pipe(gulp.dest(paths.build + '/styles'));
}); });


gulp.task('styles_vendors', function () {
return gulp.src(paths.styles_vendors)
gulp.task('stylesVendors', function () {
return gulp.src(paths.stylesVendors)
.pipe(gulp.dest(paths.build + 'styles/')); .pipe(gulp.dest(paths.build + 'styles/'));
}); });


@@ -71,20 +71,20 @@ gulp.task('js', function () {
.pipe(gulp.dest(paths.build + 'js/')); .pipe(gulp.dest(paths.build + 'js/'));
}); });


gulp.task('js_vendors', function () {
return gulp.src(paths.js_vendors)
gulp.task('jsVendors', function () {
return gulp.src(paths.jsVendors)
.pipe(gulp.dest(paths.build + 'js/')); .pipe(gulp.dest(paths.build + 'js/'));
}); });


gulp.task('build', ['clean'], function () { gulp.task('build', ['clean'], function () {
gulp.start('js', 'js_vendors', 'html', 'styles', 'styles_vendors', 'fonts', 'images');
gulp.start('js', 'jsVendors', 'html', 'styles', 'stylesVendors', 'fonts', 'images');
}); });


gulp.task('watch', ['build'], function () { gulp.task('watch', ['build'], function () {
gulp.watch(paths.js, ['js']); gulp.watch(paths.js, ['js']);
gulp.watch(paths.js_vendors, ['js_vendors']);
gulp.watch(paths.jsVendors, ['jsVendors']);
gulp.watch(paths.styles, ['styles']); gulp.watch(paths.styles, ['styles']);
gulp.watch(paths.styles_vendors, ['styles_vendors']);
gulp.watch(paths.stylesVendors, ['stylesVendors']);
gulp.watch(paths.html, ['html']); gulp.watch(paths.html, ['html']);
gulp.watch(paths.images, ['images']); gulp.watch(paths.images, ['images']);
gulp.watch(paths.fonts, ['fonts']); gulp.watch(paths.fonts, ['fonts']);
@@ -92,4 +92,4 @@ gulp.task('watch', ['build'], function () {


gulp.task('default', ['watch'], function () { gulp.task('default', ['watch'], function () {


});
});

+ 14
- 2
package.json View File

@@ -1,7 +1,8 @@
{ {
"scripts": { "scripts": {
"build": "gulp build", "build": "gulp build",
"build:watch": "gulp"
"build:watch": "gulp",
"test": "xo"
}, },
"dependencies": { "dependencies": {
"bootstrap": "^4.0.0-alpha.2", "bootstrap": "^4.0.0-alpha.2",
@@ -15,6 +16,17 @@
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-autoprefixer": "^3.1.0", "gulp-autoprefixer": "^3.1.0",
"gulp-concat": "^2.6.0", "gulp-concat": "^2.6.0",
"gulp-cssnano": "^2.1.2"
"gulp-cssnano": "^2.1.2",
"xo": "^0.16.0"
},
"xo": {
"space": true,
"envs": [
"browser",
"webextensions"
],
"ignores": [
"dist/**"
]
} }
} }

+ 7
- 11
password-generator.js View File

@@ -1,3 +1,5 @@
/* global lesspass Clipboard */

function showTooltip(elem, msg) { function showTooltip(elem, msg) {
var classNames = elem.className; var classNames = elem.className;
elem.setAttribute('class', classNames + ' hint--top'); elem.setAttribute('class', classNames + ' hint--top');
@@ -39,7 +41,6 @@ function displayPasswordIndication() {
}); });
} }



document.getElementById('copyPasswordButton').addEventListener('click', generatePassword); document.getElementById('copyPasswordButton').addEventListener('click', generatePassword);
document.getElementById('generatedPasswordForm').addEventListener('change', generatePassword); document.getElementById('generatedPasswordForm').addEventListener('change', generatePassword);
document.getElementById('passwordLength').addEventListener('input', generatePassword); document.getElementById('passwordLength').addEventListener('input', generatePassword);
@@ -83,17 +84,15 @@ function generatePassword() {
}); });
} }



document.getElementById('displayMasterPasswordButton').addEventListener('click', toggleMasterPassword); document.getElementById('displayMasterPasswordButton').addEventListener('click', toggleMasterPassword);
function toggleMasterPassword() { function toggleMasterPassword() {
if (document.getElementById('masterPassword').type == 'password') {
if (document.getElementById('masterPassword').type === 'password') {
document.getElementById('masterPassword').type = 'text'; document.getElementById('masterPassword').type = 'text';
} else { } else {
document.getElementById('masterPassword').type = 'password'; document.getElementById('masterPassword').type = 'password';
} }
} }



var clipboard = new Clipboard('.btn-copy'); var clipboard = new Clipboard('.btn-copy');


clipboard.on('success', function (e) { clipboard.on('success', function (e) {
@@ -102,17 +101,14 @@ clipboard.on('success', function (e) {
e.clearSelection(); e.clearSelection();
} }
}); });
clipboard.on('error', function (e) {
});



document.getElementById('displayOptionsButton').addEventListener('click', toggleBlocks); document.getElementById('displayOptionsButton').addEventListener('click', toggleBlocks);


function toggle_visibility(className) {
function toggleVisibility(className) {
var elements = document.getElementsByClassName(className); var elements = document.getElementsByClassName(className);
for (var i = 0; i < elements.length; i++) { for (var i = 0; i < elements.length; i++) {
var e = elements[i]; var e = elements[i];
if (e.style.display == 'block') {
if (e.style.display === 'block') {
e.style.display = 'none'; e.style.display = 'none';
} else { } else {
e.style.display = 'block'; e.style.display = 'block';
@@ -121,5 +117,5 @@ function toggle_visibility(className) {
} }


function toggleBlocks() { function toggleBlocks() {
toggle_visibility('option-block');
}
toggleVisibility('option-block');
}

Loading…
Cancel
Save