ADD linting

This commit is contained in:
unpregnant 2017-02-14 22:34:19 +01:00
parent ef04b8e0c7
commit 8fe7a74bc0
22 changed files with 83 additions and 52 deletions

38
.eslintrc.js Executable file
View File

@ -0,0 +1,38 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
4, {
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-console": [
"error",
{
allow: ["warn", "error", "log"]
}
]
}
};

0
index.html Normal file → Executable file
View File

0
less/fonts/chivo.less Normal file → Executable file
View File

View File

@ -8,6 +8,16 @@
},
"author": "salomonelli",
"homepage": "https://github.com/salomonelli/best-resume-ever",
"keywords": [
"resume",
"template",
"mustache",
"less",
"cv",
"curriculum",
"vitae",
"electron"
],
"scripts": {
"server": "node --harmony-async-await src/app.js",
"less": "node --harmony-async-await src/less.js",
@ -15,7 +25,8 @@
"readme": "node --harmony-async-await src/RenderReadMe.js",
"start": "npm run babel && npm run less && npm run server",
"dev": "watch 'npm start' src/ resumes/ less/",
"pdf": "npm run babel && npm run less && node --harmony-async-await src/ResumeToPdf.js"
"pdf": "npm run babel && npm run less && node --harmony-async-await src/ResumeToPdf.js",
"lint": "eslint src/"
},
"dependencies": {
"@typopro/web-montserrat": "3.4.9",
@ -52,5 +63,9 @@
"typeface-chivo": "0.0.22",
"watch": "1.0.1",
"write": "0.3.2"
},
"devDependencies": {
"eslint": "^3.15.0",
"pre-commit": "^1.2.2"
}
}

0
pdf/resume-grey-boxes.pdf Normal file → Executable file
View File

0
pdf/resume-left-right.pdf Normal file → Executable file
View File

0
pdf/resume-oblique.pdf Normal file → Executable file
View File

0
pdf/resume-side-bar.pdf Normal file → Executable file
View File

0
pdf/resume-spotify.pdf Normal file → Executable file
View File

0
pdf/resume-wanted.pdf Normal file → Executable file
View File

0
public/javascript.js Normal file → Executable file
View File

0
public/style.min.css vendored Normal file → Executable file
View File

0
src/Config.js Normal file → Executable file
View File

View File

@ -1,16 +1,14 @@
const showdown = require('showdown');
const converter = new showdown.Converter();
const fs = require('fs');
const path = require('path');
const Mustache = require('mustache');
const writeFile = require('write');
const Util = require('./Util');
/**
* renders readme to html for github Pages
* @return {Promise}
*/
RenderReadMe = async function() {
const RenderReadMe = async function() {
let dir = path.join(__dirname, '../' + 'README.md');
const readmeContent = await Util.readFileContent(dir);
const readmeHTML = converter.makeHtml(readmeContent);
@ -20,7 +18,7 @@ RenderReadMe = async function() {
content: readmeHTML
});
await Util.writeFile('index.html', readme);
}
};
RenderReadMe();

View File

@ -1,10 +1,8 @@
const pdf = require('html-pdf');
const path = require('path');
const Config = require('./Config');
const Util = require('./Util');
const Server = require('./Server');
const ResumeToPdf = {
/**
* generates electroshot command for screenshoting resume
@ -13,7 +11,7 @@ const ResumeToPdf = {
*/
electroshotScript: function(resume) {
const dir = path.join(__dirname, '../pdf');
return 'electroshot localhost:3000/' + resume +
return 'electroshot localhost:' + Config.port + '/' + resume +
' 2481x3508 --pdf-margin none --format pdf --out ' + dir +
' --filename "' + resume + '.pdf" --pdf-background; ';
},
@ -30,6 +28,6 @@ const ResumeToPdf = {
await Util.execBash(script);
await Server.kill();
}
}
};
ResumeToPdf.convert();

View File

@ -1,7 +1,5 @@
const path = require('path');
const fs = require('fs');
const express = require('express');
const mustacheExpress = require('mustache-express');
const request = require('request-promise');
const Config = require('./Config');
const Util = require('./Util');
@ -31,7 +29,7 @@ const Server = {
*/
kill: function() {
request.get('http://localhost:' + Config.port + '/kill')
.catch(error => {});
.catch(error => console.log(error));
},
/**
* sets route of express app
@ -78,6 +76,6 @@ const Server = {
await Util.setTimeout(500);
Server.start();
}
}
};
module.exports = Server;

View File

@ -1,8 +1,6 @@
const less = require('less');
const path = require('path');
const fs = require('fs');
const CleanCSS = require('clean-css');
const writeFile = require('write');
const Util = require('./Util');
const StyleCompiler = {
@ -31,7 +29,7 @@ const StyleCompiler = {
return new Promise((res, rej) => {
new CleanCSS().minify(css, (err, output) => {
if (err) rej(err);
else res(output)
else res(output);
});
});
},
@ -60,6 +58,6 @@ const StyleCompiler = {
const p = path.join(__dirname, '../public/style.min.css');
await Util.writeFile(p, minCSS.styles);
}
}
};
module.exports = StyleCompiler;

12
src/Util.js Normal file → Executable file
View File

@ -1,8 +1,6 @@
const path = require('path');
const request = require('request-promise');
const writeFile = require('write');
const fs = require('fs');
const Config = require('./Util');
var exec = require('child_process').exec;
const Util = {
@ -13,7 +11,7 @@ const Util = {
getDirectories: function() {
const srcpath = path.join(__dirname, '../resumes');
return fs.readdirSync(srcpath)
.filter(file => file.includes('resume-'))
.filter(file => file.includes('resume-'));
},
/**
* gets resumes names and paths from directories
@ -27,7 +25,7 @@ const Util = {
resumes.push({
path: dir,
name: name.replace('-', ' ')
})
});
});
return resumes;
},
@ -75,12 +73,12 @@ const Util = {
execBash: function(script) {
return new Promise((res, rej) => {
exec(script,
(error, stdout, stderr) => {
if (error) rej(err);
error => {
if (error) rej(error);
else res();
});
});
}
}
};
module.exports = Util;

0
src/app.js Normal file → Executable file
View File

0
src/less.js Normal file → Executable file
View File

View File

@ -1,3 +1,4 @@
/* eslint-disable */
module.exports = {
name: {
first: 'John',

View File

@ -1,7 +1,3 @@
// minimum margin of content to bottom of page
const marginBottom = 50;
// DOM-element of <page></page>
let page;
// all dom elements
let elements;
@ -11,16 +7,7 @@ let elements;
*/
const getAllDOMElements = () => {
elements = document.getElementsByTagName('*');
}
/**
* gets DOM-element of #resumeX
* @return {HTMLElement}
*/
const getResumeDOMElement = () => {
return page.children[0];
}
};
/**
* checks if DOM-element has box-shadow
@ -33,7 +20,7 @@ const hasBoxShadow = element => {
.getPropertyValue('box-shadow');
if (style != 'none') return style;
else return '';
}
};
/**
* gets absolute position of element
@ -44,8 +31,8 @@ const getAbsolutePositionOfElement = element => {
return {
top: element.getBoundingClientRect().top,
left: element.getBoundingClientRect().left
}
}
};
};
/**
@ -54,7 +41,7 @@ const getAbsolutePositionOfElement = element => {
*/
const removeBoxShadowOfElement = element => {
element.style.boxShadow = 'none';
}
};
/**
@ -66,7 +53,7 @@ const getBorderRadiusOfElement = element => {
return window
.getComputedStyle(element, null)
.getPropertyValue('border-radius');
}
};
/**
* adds new box shadow
@ -86,7 +73,7 @@ const addNewBoxShadow = (element, position, boxShadow) => {
div.style.top = position.top;
div.style.left = position.left;
document.getElementsByTagName('body')[0].appendChild(div);
}
};
/**
* fixes box shadow of element
@ -97,7 +84,7 @@ const fixBoxShadow = (element, boxShadow) => {
const position = getAbsolutePositionOfElement(element);
removeBoxShadowOfElement(element);
addNewBoxShadow(element, position, boxShadow);
}
};
/**
* gets all elements with shadows
@ -115,7 +102,7 @@ const getElementsWithShadows = () => {
});
}
return ret;
}
};
/**
* fixes shadows, since normal box-shadow cannot be printed in chrome,
@ -126,7 +113,7 @@ const fixBoxShadows = () => {
for (let i = 0; i < elementsWithShadow.length; i++) {
fixBoxShadow(elementsWithShadow[i].element, elementsWithShadow[i].shadow);
}
}
};
/**
* checks if the page contains a resume
@ -135,7 +122,7 @@ const fixBoxShadows = () => {
const isResume = () => {
if (document.getElementsByTagName('page')[0]) return true;
else return false;
}
};
/**
* fixes resume
@ -144,6 +131,6 @@ const fixResume = () => {
if (!isResume()) return;
getAllDOMElements();
fixBoxShadows();
}
};
fixResume();