ADD linting
This commit is contained in:
parent
ef04b8e0c7
commit
8fe7a74bc0
38
.eslintrc.js
Executable file
38
.eslintrc.js
Executable 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
0
index.html
Normal file → Executable file
0
less/fonts/chivo.less
Normal file → Executable file
0
less/fonts/chivo.less
Normal file → Executable file
17
package.json
17
package.json
@ -8,6 +8,16 @@
|
|||||||
},
|
},
|
||||||
"author": "salomonelli",
|
"author": "salomonelli",
|
||||||
"homepage": "https://github.com/salomonelli/best-resume-ever",
|
"homepage": "https://github.com/salomonelli/best-resume-ever",
|
||||||
|
"keywords": [
|
||||||
|
"resume",
|
||||||
|
"template",
|
||||||
|
"mustache",
|
||||||
|
"less",
|
||||||
|
"cv",
|
||||||
|
"curriculum",
|
||||||
|
"vitae",
|
||||||
|
"electron"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"server": "node --harmony-async-await src/app.js",
|
"server": "node --harmony-async-await src/app.js",
|
||||||
"less": "node --harmony-async-await src/less.js",
|
"less": "node --harmony-async-await src/less.js",
|
||||||
@ -15,7 +25,8 @@
|
|||||||
"readme": "node --harmony-async-await src/RenderReadMe.js",
|
"readme": "node --harmony-async-await src/RenderReadMe.js",
|
||||||
"start": "npm run babel && npm run less && npm run server",
|
"start": "npm run babel && npm run less && npm run server",
|
||||||
"dev": "watch 'npm start' src/ resumes/ less/",
|
"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": {
|
"dependencies": {
|
||||||
"@typopro/web-montserrat": "3.4.9",
|
"@typopro/web-montserrat": "3.4.9",
|
||||||
@ -52,5 +63,9 @@
|
|||||||
"typeface-chivo": "0.0.22",
|
"typeface-chivo": "0.0.22",
|
||||||
"watch": "1.0.1",
|
"watch": "1.0.1",
|
||||||
"write": "0.3.2"
|
"write": "0.3.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "^3.15.0",
|
||||||
|
"pre-commit": "^1.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
0
pdf/resume-grey-boxes.pdf
Normal file → Executable file
0
pdf/resume-grey-boxes.pdf
Normal file → Executable file
0
pdf/resume-left-right.pdf
Normal file → Executable file
0
pdf/resume-left-right.pdf
Normal file → Executable file
0
pdf/resume-oblique.pdf
Normal file → Executable file
0
pdf/resume-oblique.pdf
Normal file → Executable file
0
pdf/resume-side-bar.pdf
Normal file → Executable file
0
pdf/resume-side-bar.pdf
Normal file → Executable file
0
pdf/resume-spotify.pdf
Normal file → Executable file
0
pdf/resume-spotify.pdf
Normal file → Executable file
0
pdf/resume-wanted.pdf
Normal file → Executable file
0
pdf/resume-wanted.pdf
Normal file → Executable file
0
public/javascript.js
Normal file → Executable file
0
public/javascript.js
Normal file → Executable file
0
public/style.min.css
vendored
Normal file → Executable file
0
public/style.min.css
vendored
Normal file → Executable file
0
src/Config.js
Normal file → Executable file
0
src/Config.js
Normal file → Executable file
@ -1,16 +1,14 @@
|
|||||||
const showdown = require('showdown');
|
const showdown = require('showdown');
|
||||||
const converter = new showdown.Converter();
|
const converter = new showdown.Converter();
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const Mustache = require('mustache');
|
const Mustache = require('mustache');
|
||||||
const writeFile = require('write');
|
|
||||||
const Util = require('./Util');
|
const Util = require('./Util');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* renders readme to html for github Pages
|
* renders readme to html for github Pages
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
RenderReadMe = async function() {
|
const RenderReadMe = async function() {
|
||||||
let dir = path.join(__dirname, '../' + 'README.md');
|
let dir = path.join(__dirname, '../' + 'README.md');
|
||||||
const readmeContent = await Util.readFileContent(dir);
|
const readmeContent = await Util.readFileContent(dir);
|
||||||
const readmeHTML = converter.makeHtml(readmeContent);
|
const readmeHTML = converter.makeHtml(readmeContent);
|
||||||
@ -20,7 +18,7 @@ RenderReadMe = async function() {
|
|||||||
content: readmeHTML
|
content: readmeHTML
|
||||||
});
|
});
|
||||||
await Util.writeFile('index.html', readme);
|
await Util.writeFile('index.html', readme);
|
||||||
}
|
};
|
||||||
|
|
||||||
RenderReadMe();
|
RenderReadMe();
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
const pdf = require('html-pdf');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const Config = require('./Config');
|
const Config = require('./Config');
|
||||||
const Util = require('./Util');
|
const Util = require('./Util');
|
||||||
const Server = require('./Server');
|
const Server = require('./Server');
|
||||||
|
|
||||||
|
|
||||||
const ResumeToPdf = {
|
const ResumeToPdf = {
|
||||||
/**
|
/**
|
||||||
* generates electroshot command for screenshoting resume
|
* generates electroshot command for screenshoting resume
|
||||||
@ -13,7 +11,7 @@ const ResumeToPdf = {
|
|||||||
*/
|
*/
|
||||||
electroshotScript: function(resume) {
|
electroshotScript: function(resume) {
|
||||||
const dir = path.join(__dirname, '../pdf');
|
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 +
|
' 2481x3508 --pdf-margin none --format pdf --out ' + dir +
|
||||||
' --filename "' + resume + '.pdf" --pdf-background; ';
|
' --filename "' + resume + '.pdf" --pdf-background; ';
|
||||||
},
|
},
|
||||||
@ -30,6 +28,6 @@ const ResumeToPdf = {
|
|||||||
await Util.execBash(script);
|
await Util.execBash(script);
|
||||||
await Server.kill();
|
await Server.kill();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
ResumeToPdf.convert();
|
ResumeToPdf.convert();
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const mustacheExpress = require('mustache-express');
|
|
||||||
const request = require('request-promise');
|
const request = require('request-promise');
|
||||||
const Config = require('./Config');
|
const Config = require('./Config');
|
||||||
const Util = require('./Util');
|
const Util = require('./Util');
|
||||||
@ -31,7 +29,7 @@ const Server = {
|
|||||||
*/
|
*/
|
||||||
kill: function() {
|
kill: function() {
|
||||||
request.get('http://localhost:' + Config.port + '/kill')
|
request.get('http://localhost:' + Config.port + '/kill')
|
||||||
.catch(error => {});
|
.catch(error => console.log(error));
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* sets route of express app
|
* sets route of express app
|
||||||
@ -78,6 +76,6 @@ const Server = {
|
|||||||
await Util.setTimeout(500);
|
await Util.setTimeout(500);
|
||||||
Server.start();
|
Server.start();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports = Server;
|
module.exports = Server;
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
const less = require('less');
|
const less = require('less');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
|
||||||
const CleanCSS = require('clean-css');
|
const CleanCSS = require('clean-css');
|
||||||
const writeFile = require('write');
|
|
||||||
const Util = require('./Util');
|
const Util = require('./Util');
|
||||||
|
|
||||||
const StyleCompiler = {
|
const StyleCompiler = {
|
||||||
@ -31,13 +29,13 @@ const StyleCompiler = {
|
|||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
new CleanCSS().minify(css, (err, output) => {
|
new CleanCSS().minify(css, (err, output) => {
|
||||||
if (err) rej(err);
|
if (err) rej(err);
|
||||||
else res(output)
|
else res(output);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* compiles less files to minified css file
|
* compiles less files to minified css file
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
run: async function() {
|
run: async function() {
|
||||||
const directories = Util.getResumesFromDirectories();
|
const directories = Util.getResumesFromDirectories();
|
||||||
@ -60,6 +58,6 @@ const StyleCompiler = {
|
|||||||
const p = path.join(__dirname, '../public/style.min.css');
|
const p = path.join(__dirname, '../public/style.min.css');
|
||||||
await Util.writeFile(p, minCSS.styles);
|
await Util.writeFile(p, minCSS.styles);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports = StyleCompiler;
|
module.exports = StyleCompiler;
|
||||||
|
|||||||
14
src/Util.js
Normal file → Executable file
14
src/Util.js
Normal file → Executable file
@ -1,19 +1,17 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const request = require('request-promise');
|
|
||||||
const writeFile = require('write');
|
const writeFile = require('write');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const Config = require('./Util');
|
|
||||||
var exec = require('child_process').exec;
|
var exec = require('child_process').exec;
|
||||||
|
|
||||||
const Util = {
|
const Util = {
|
||||||
/**
|
/**
|
||||||
* gets directories starting with 'resume-'
|
* gets directories starting with 'resume-'
|
||||||
* @return {[]}
|
* @return {[]}
|
||||||
*/
|
*/
|
||||||
getDirectories: function() {
|
getDirectories: function() {
|
||||||
const srcpath = path.join(__dirname, '../resumes');
|
const srcpath = path.join(__dirname, '../resumes');
|
||||||
return fs.readdirSync(srcpath)
|
return fs.readdirSync(srcpath)
|
||||||
.filter(file => file.includes('resume-'))
|
.filter(file => file.includes('resume-'));
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* gets resumes names and paths from directories
|
* gets resumes names and paths from directories
|
||||||
@ -27,7 +25,7 @@ const Util = {
|
|||||||
resumes.push({
|
resumes.push({
|
||||||
path: dir,
|
path: dir,
|
||||||
name: name.replace('-', ' ')
|
name: name.replace('-', ' ')
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
return resumes;
|
return resumes;
|
||||||
},
|
},
|
||||||
@ -75,12 +73,12 @@ const Util = {
|
|||||||
execBash: function(script) {
|
execBash: function(script) {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
exec(script,
|
exec(script,
|
||||||
(error, stdout, stderr) => {
|
error => {
|
||||||
if (error) rej(err);
|
if (error) rej(error);
|
||||||
else res();
|
else res();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports = Util;
|
module.exports = Util;
|
||||||
|
|||||||
0
src/app.js
Normal file → Executable file
0
src/app.js
Normal file → Executable file
0
src/less.js
Normal file → Executable file
0
src/less.js
Normal file → Executable file
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: {
|
name: {
|
||||||
first: 'John',
|
first: 'John',
|
||||||
|
|||||||
@ -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
|
// all dom elements
|
||||||
let elements;
|
let elements;
|
||||||
|
|
||||||
@ -11,16 +7,7 @@ let elements;
|
|||||||
*/
|
*/
|
||||||
const getAllDOMElements = () => {
|
const getAllDOMElements = () => {
|
||||||
elements = document.getElementsByTagName('*');
|
elements = document.getElementsByTagName('*');
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* gets DOM-element of #resumeX
|
|
||||||
* @return {HTMLElement}
|
|
||||||
*/
|
|
||||||
const getResumeDOMElement = () => {
|
|
||||||
return page.children[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if DOM-element has box-shadow
|
* checks if DOM-element has box-shadow
|
||||||
@ -33,7 +20,7 @@ const hasBoxShadow = element => {
|
|||||||
.getPropertyValue('box-shadow');
|
.getPropertyValue('box-shadow');
|
||||||
if (style != 'none') return style;
|
if (style != 'none') return style;
|
||||||
else return '';
|
else return '';
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets absolute position of element
|
* gets absolute position of element
|
||||||
@ -44,8 +31,8 @@ const getAbsolutePositionOfElement = element => {
|
|||||||
return {
|
return {
|
||||||
top: element.getBoundingClientRect().top,
|
top: element.getBoundingClientRect().top,
|
||||||
left: element.getBoundingClientRect().left
|
left: element.getBoundingClientRect().left
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +41,7 @@ const getAbsolutePositionOfElement = element => {
|
|||||||
*/
|
*/
|
||||||
const removeBoxShadowOfElement = element => {
|
const removeBoxShadowOfElement = element => {
|
||||||
element.style.boxShadow = 'none';
|
element.style.boxShadow = 'none';
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +53,7 @@ const getBorderRadiusOfElement = element => {
|
|||||||
return window
|
return window
|
||||||
.getComputedStyle(element, null)
|
.getComputedStyle(element, null)
|
||||||
.getPropertyValue('border-radius');
|
.getPropertyValue('border-radius');
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds new box shadow
|
* adds new box shadow
|
||||||
@ -86,7 +73,7 @@ const addNewBoxShadow = (element, position, boxShadow) => {
|
|||||||
div.style.top = position.top;
|
div.style.top = position.top;
|
||||||
div.style.left = position.left;
|
div.style.left = position.left;
|
||||||
document.getElementsByTagName('body')[0].appendChild(div);
|
document.getElementsByTagName('body')[0].appendChild(div);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fixes box shadow of element
|
* fixes box shadow of element
|
||||||
@ -97,7 +84,7 @@ const fixBoxShadow = (element, boxShadow) => {
|
|||||||
const position = getAbsolutePositionOfElement(element);
|
const position = getAbsolutePositionOfElement(element);
|
||||||
removeBoxShadowOfElement(element);
|
removeBoxShadowOfElement(element);
|
||||||
addNewBoxShadow(element, position, boxShadow);
|
addNewBoxShadow(element, position, boxShadow);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets all elements with shadows
|
* gets all elements with shadows
|
||||||
@ -115,7 +102,7 @@ const getElementsWithShadows = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fixes shadows, since normal box-shadow cannot be printed in chrome,
|
* 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++) {
|
for (let i = 0; i < elementsWithShadow.length; i++) {
|
||||||
fixBoxShadow(elementsWithShadow[i].element, elementsWithShadow[i].shadow);
|
fixBoxShadow(elementsWithShadow[i].element, elementsWithShadow[i].shadow);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if the page contains a resume
|
* checks if the page contains a resume
|
||||||
@ -135,7 +122,7 @@ const fixBoxShadows = () => {
|
|||||||
const isResume = () => {
|
const isResume = () => {
|
||||||
if (document.getElementsByTagName('page')[0]) return true;
|
if (document.getElementsByTagName('page')[0]) return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fixes resume
|
* fixes resume
|
||||||
@ -144,6 +131,6 @@ const fixResume = () => {
|
|||||||
if (!isResume()) return;
|
if (!isResume()) return;
|
||||||
getAllDOMElements();
|
getAllDOMElements();
|
||||||
fixBoxShadows();
|
fixBoxShadows();
|
||||||
}
|
};
|
||||||
|
|
||||||
fixResume();
|
fixResume();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user