added eslint

pull/32/head
Szekeres Bálint 2018-11-19 23:39:28 +01:00
parent 313518413a
commit 6dc438dd46
3 changed files with 209 additions and 135 deletions

47
.eslintrc Normal file
View File

@ -0,0 +1,47 @@
{
"extends": "eslint:recommended",
"rules": {
"array-bracket-spacing": ["error", "never"],
"brace-style": "error",
"comma-dangle": ["error", "always-multiline"],
"comma-style": ["error", "last"],
"computed-property-spacing": ["error", "never"],
"curly": ["error", "all"],
"eqeqeq": ["error", "always"],
"func-call-spacing": ["error", "never"],
"func-style": ["error", "declaration"],
"indent": ["error", "tab"],
"key-spacing": ["error", {
"afterColon": true,
"mode": "minimum",
}],
"keyword-spacing": ["error", {
"before": true,
"after": true
}],
"linebreak-style": ["error", "unix"],
"object-curly-newline": ["error", {
"minProperties": 1
}],
"no-mixed-spaces-and-tabs": "error",
"no-multi-spaces": "error",
"padded-blocks": ["error", "never"],
"padding-line-between-statements": ["error",
{ "blankLine": "always", "prev": "*", "next": "return" }
],
"quote-props": ["error", "as-needed"],
"quotes": ["error", "single"],
"semi-spacing": ["error", {
"before": false,
"after": true
}]
},
"globals": {
"angular": true,
"gtag": true,
"hljs": true,
"JSZip": true,
"Masonry": true,
"saveAs": true
}
}

View File

@ -22,6 +22,7 @@
"angular-tooltips": "^1.2.2",
"autoprefixer": "^8.6.4",
"bootstrap": "^4.1.1",
"eslint": "^5.9.0",
"highlight.js": "^9.12.0",
"node-sass": "^4.9.0",
"postcss-cli": "^5.0.1"
@ -42,8 +43,11 @@
"autoprefixer": "postcss public/assets/css/app.min.css --use autoprefixer --no-map --replace --verbose",
"test": "start-server-and-test start http://localhost:8080 cypress:run",
"test:debug": "start-server-and-test start http://localhost:8080 cypress:open",
"lint": "eslint public/assets/js/app.js",
"lint:fix": "npm run lint -- --fix",
"test": "npm run lint && start-server-and-test start http://localhost:8080 cypress:run",
"test:debug": "npm run lint && start-server-and-test start http://localhost:8080 cypress:open",
"cypress:run": "cypress run",
"cypress:open": "cypress open"

View File

@ -1,36 +1,18 @@
(function() {
var repeat = function(string, count) {
var repeatedString = '';
for (var i = 0; i < count; i++) {
repeatedString += string;
}
return repeatedString;
};
'use strict';
angular
.module('NginxConfigIoApp', ['ngclipboard', '720kb.tooltips'])
.config(function NginxCongigIoConfig($locationProvider) {
$locationProvider
.html5Mode(true)
.hashPrefix('!');
})
.controller('NginxConfigIoController', function NginxConfigIoController($scope, $window, $location, $timeout) {
///////////////////////
// PRIVATE VARIABLES //
///////////////////////
var masonry;
.config(nginxCongigIoConfig)
.config(tooltipsConfig)
.directive('ngIncludeTabs', ngIncludeTabs)
.controller('NginxConfigIoController', NginxConfigIoController);
/////////////////////
// SCOPE VARIABLES //
/////////////////////
$scope.defaultData = {
var DEFAULTS = {
ipv4: '*',
ipv6: '::',
@ -51,9 +33,9 @@
hsts_preload: true,
email: '',
ssl_certificate: '',
ssl_certificate_key:'',
ssl_certificate_key: '',
resolver_cloudflare:true,
resolver_cloudflare: true,
resolver_google: true,
resolver_opendns: true,
@ -101,6 +83,71 @@
proxy_pass: 'http://127.0.0.1:3000',
};
function repeat(string, count) {
var repeatedString = '';
for (var i = 0; i < count; i++) {
repeatedString += string;
}
return repeatedString;
}
function tooltipsConfig(tooltipsConfProvider) {
tooltipsConfProvider.configure({
side: 'right',
size: 'small',
});
}
function nginxCongigIoConfig($locationProvider) {
$locationProvider
.html5Mode(true)
.hashPrefix('!');
}
function ngIncludeTabs() {
return {
require: 'ngInclude',
restrict: 'A',
link: {
pre: function preLink(scope, iElement, iAttrs, controller) {
var tabs = parseInt(iAttrs.ngIncludeTabs || 0);
var startRegex = new RegExp(repeat('\t', tabs - 1));
controller.template = controller.template
.replace(/^(.*)$/mg, repeat('\t', tabs) + '$1')
.replace(startRegex, '')
.replace(/\s*$/, '');
},
},
};
}
function NginxConfigIoController($scope, $window, $location, $timeout) {
///////////////////////
// PRIVATE VARIABLES //
///////////////////////
var masonry;
/////////////////////
// SCOPE VARIABLES //
/////////////////////
$scope.defaultData = DEFAULTS;
$scope.location = $location;
$scope.data = angular.copy($scope.defaultData);
$scope.dataInit = false;
@ -120,7 +167,7 @@
docs: 'pdf|' +
'docx?|dotx?|docm|dotm|' +
'xlsx?|xltx?|xlsm|xltm|' +
'pptx?|potx?|pptm|potm|ppsx?'
'pptx?|potx?|pptm|potm|ppsx?',
};
$scope.gzipTypes = 'text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml';
@ -271,13 +318,14 @@
zip.file(name, content);
}
zip.generateAsync({ type: 'blob' })
.then(function(content) {
zip.generateAsync({
type: 'blob',
}).then(function(content) {
saveAs(content, 'nginxconfig.io-' + $scope.domain() + '.zip');
});
gtag('event', $scope.domain(), {
event_category: 'download_zip'
event_category: 'download_zip',
});
};
@ -311,7 +359,7 @@
percentPosition: true,
initLayout: false,
stagger: 0,
transitionDuration: '0.6s'
transitionDuration: '0.6s',
});
};
@ -327,7 +375,7 @@
$scope.data.index = $scope.defaultData.index;
$scope.data.fallback_html = $scope.defaultData.fallback_html;
switch(preset) {
switch (preset) {
case 'frontend':
$scope.data.php = false;
$scope.data.index = 'index.html';
@ -568,30 +616,5 @@
//////////
$scope.setDataFromHash();
$scope.initMasonry();
})
.config(['tooltipsConfProvider', function (tooltipsConfProvider) {
tooltipsConfProvider.configure({
side: 'right',
size: 'small',
});
}])
.directive('ngIncludeTabs', function () {
return {
require: 'ngInclude',
restrict: 'A',
link: {
pre: function preLink(scope, iElement, iAttrs, controller) {
var tabs = parseInt(iAttrs.ngIncludeTabs || 0);
var startRegex = new RegExp(repeat('\t', tabs - 1));
controller.template = controller.template
.replace(/^(.*)$/mg, repeat('\t', tabs) + '$1')
.replace(startRegex, '')
.replace(/\s*$/, '');
},
},
};
});
}
})();