Skip to content

Commit

Permalink
refactor(eslint): fixed all eslint errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mpfeil committed Jun 5, 2018
2 parents 2ebaa57 + d5d8746 commit 82260d5
Show file tree
Hide file tree
Showing 50 changed files with 2,288 additions and 1,507 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Gruntfile.js
node_modules/
26 changes: 26 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
env: {
browser: true
},
globals: {
"angular": 1,
"L": 1,
"moment": 1,
"Tawk_API": 1
},
extends: [
'@sensebox/eslint-config-sensebox',
'plugin:angular/johnpapa'
],
rules: {
"angular/file-name": 0,
"no-var": 0,
"prefer-template": 0,
"func-style": 0,
"angular/function-type": 0,
"wrap-iife": 0,
"strict": ['error', 'function'],
"no-console": 1,
"no-warning-comments": 1
}
};
60 changes: 0 additions & 60 deletions .jshintrc

This file was deleted.

106 changes: 48 additions & 58 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Generated on 2014-05-20 using generator-angular 0.8.0

'use strict';

// # Globbing
Expand Down Expand Up @@ -40,7 +41,7 @@ module.exports = function (grunt) {
]
},
files: [
{expand: true, flatten: true, src: ['<%= yeoman.dist %>/views/explore2.map.html'], dest: '<%= yeoman.dist %>/views/'}
{ expand: true, flatten: true, src: ['<%= yeoman.dist %>/views/explore2.map.html'], dest: '<%= yeoman.dist %>/views/' }
]
},
urls: {
Expand All @@ -65,7 +66,7 @@ module.exports = function (grunt) {
]
},
files: [
{expand: true, flatten: true, src: ['<%= yeoman.dist %>/scripts/*.scripts.js'], dest: '<%= yeoman.dist %>/scripts/'}
{ expand: true, flatten: true, src: ['<%= yeoman.dist %>/scripts/*.scripts.js'], dest: '<%= yeoman.dist %>/scripts/' }
]
},
devapi: {
Expand All @@ -78,8 +79,8 @@ module.exports = function (grunt) {
]
},
files: [
{expand: true, flatten: true, src: ['.tmp/scripts/constants.js'], dest: '.tmp/scripts'},
{expand: true, flatten: true, src: ['.tmp/scripts/services/opensensemapapi.js'], dest: '.tmp/scripts/services'}
{ expand: true, flatten: true, src: ['.tmp/scripts/constants.js'], dest: '.tmp/scripts' },
{ expand: true, flatten: true, src: ['.tmp/scripts/services/opensensemapapi.js'], dest: '.tmp/scripts/services' }
]
},
devmaps: {
Expand All @@ -92,7 +93,7 @@ module.exports = function (grunt) {
]
},
files: [
{expand: true, flatten: true, src: ['.tmp/components/leaflet.directive.js'], dest: '.tmp/components'}
{ expand: true, flatten: true, src: ['.tmp/components/leaflet.directive.js'], dest: '.tmp/components' }
]
},
version: {
Expand All @@ -109,7 +110,7 @@ module.exports = function (grunt) {
]
},
files: [
{expand: true, flatten: true, src: ['.tmp/scripts/constants.js'], dest: '.tmp/scripts'}
{ expand: true, flatten: true, src: ['.tmp/scripts/constants.js'], dest: '.tmp/scripts' }
]
}
},
Expand All @@ -132,7 +133,7 @@ module.exports = function (grunt) {
'<%= yeoman.app %>/scripts/{,*/}*.js',
'<%= yeoman.app %>/components/{,*/}*.js'
],
tasks: ['newer:jshint:all'],
tasks: ['newer:eslint'],
options: {
livereload: true
}
Expand Down Expand Up @@ -204,12 +205,13 @@ module.exports = function (grunt) {
'.tmp',
'<%= yeoman.app %>'
],
middleware: function(connect, options) {
middleware: function (connect, options) {
var middlewares = [];
middlewares.push(modRewrite(['!\\.html|\\.js|\\.css|\\.svg|\\.jp(e?)g|\\.png|\\.woff2|\\.gif|\\.ttf$ /index.html']));
options.base.forEach(function(base) {
options.base.forEach(function (base) {
middlewares.push(serveStatic(base));
});

return middlewares;
}
}
Expand All @@ -232,21 +234,8 @@ module.exports = function (grunt) {
},

// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'Gruntfile.js',
'<%= yeoman.app %>/scripts/{,*/}*.js'
],
test: {
options: {
jshintrc: 'test/.jshintrc'
},
src: ['test/spec/{,*/}*.js']
}
eslint: {
target: ['<%= yeoman.app %>/scripts/{,*/}*.js']
},

// Empties folders to start fresh
Expand Down Expand Up @@ -329,9 +318,10 @@ module.exports = function (grunt) {
options: {
assetsDirs: ['<%= yeoman.dist %>'],
blockReplacements: {
js: function (block){
js: function (block) {
console.log(block.dest);
return '<script defer src="' + block.dest + '"><\/script>';

return `<script defer src="${ block.dest }"><\/script>`;
}
}
}
Expand Down Expand Up @@ -576,16 +566,16 @@ module.exports = function (grunt) {
mode: 'gzip'
},
files: [
{expand: true, src: ['dist/*.html'], dest: './', ext: '.html.gz'},
{expand: true, src: ['dist/views/*.html'], dest: './', extDot: 'last', ext:'.html.gz'},
{expand: true, src: ['dist/scripts/*.vendor.js'], dest: './', extDot: 'last', ext: '.js.gz'},
{expand: true, src: ['dist/scripts/*.scripts.js'], dest: './', extDot: 'last', ext: '.js.gz'},
{expand: true, src: ['dist/styles/*.css'], dest: './', extDot: 'last', ext: '.css.gz'},
{expand: true, src: ['dist/translations/angular/*.js'], dest: './', extDot: 'last', ext: '.js.gz'},
{expand: true, src: ['dist/translations/*.json'], dest: './', extDot: 'last', ext: '.json.gz'},
{expand: true, src: ['dist/images/**/*.png'], dest: './', extDot: 'last', ext: '.png.gz'},
{expand: true, src: ['dist/styles/images/*.png'], dest: './', extDot: 'last', ext: '.png.gz'},
{expand: true, src: ['dist/images/*.svg'], dest: './', extDot: 'last', ext: '.svg.gz'}
{ expand: true, src: ['dist/*.html'], dest: './', ext: '.html.gz' },
{ expand: true, src: ['dist/views/*.html'], dest: './', extDot: 'last', ext: '.html.gz' },
{ expand: true, src: ['dist/scripts/*.vendor.js'], dest: './', extDot: 'last', ext: '.js.gz' },
{ expand: true, src: ['dist/scripts/*.scripts.js'], dest: './', extDot: 'last', ext: '.js.gz' },
{ expand: true, src: ['dist/styles/*.css'], dest: './', extDot: 'last', ext: '.css.gz' },
{ expand: true, src: ['dist/translations/angular/*.js'], dest: './', extDot: 'last', ext: '.js.gz' },
{ expand: true, src: ['dist/translations/*.json'], dest: './', extDot: 'last', ext: '.json.gz' },
{ expand: true, src: ['dist/images/**/*.png'], dest: './', extDot: 'last', ext: '.png.gz' },
{ expand: true, src: ['dist/styles/images/*.png'], dest: './', extDot: 'last', ext: '.png.gz' },
{ expand: true, src: ['dist/images/*.svg'], dest: './', extDot: 'last', ext: '.svg.gz' }

]
},
Expand All @@ -594,16 +584,16 @@ module.exports = function (grunt) {
mode: 'brotli'
},
files: [
{expand: true, src: ['dist/*.html'], dest: './', ext: '.html.br'},
{expand: true, src: ['dist/views/*.html'], dest: './', extDot: 'last', ext:'.html.br'},
{expand: true, src: ['dist/scripts/*.vendor.js'], dest: './', extDot: 'last', ext: '.js.br'},
{expand: true, src: ['dist/scripts/*.scripts.js'], dest: './', extDot: 'last', ext: '.js.br'},
{expand: true, src: ['dist/styles/*.css'], dest: './', extDot: 'last', ext: '.css.br'},
{expand: true, src: ['dist/translations/angular/*.js'], dest: './', extDot: 'last', ext: '.js.br'},
{expand: true, src: ['dist/translations/*.json'], dest: './', extDot: 'last', ext: '.json.br'},
{expand: true, src: ['dist/images/**/*.png'], dest: './', extDot: 'last', ext: '.png.br'},
{expand: true, src: ['dist/styles/images/*.png'], dest: './', extDot: 'last', ext: '.png.br'},
{expand: true, src: ['dist/images/*.svg'], dest: './', extDot: 'last', ext: '.svg.br'}
{ expand: true, src: ['dist/*.html'], dest: './', ext: '.html.br' },
{ expand: true, src: ['dist/views/*.html'], dest: './', extDot: 'last', ext: '.html.br' },
{ expand: true, src: ['dist/scripts/*.vendor.js'], dest: './', extDot: 'last', ext: '.js.br' },
{ expand: true, src: ['dist/scripts/*.scripts.js'], dest: './', extDot: 'last', ext: '.js.br' },
{ expand: true, src: ['dist/styles/*.css'], dest: './', extDot: 'last', ext: '.css.br' },
{ expand: true, src: ['dist/translations/angular/*.js'], dest: './', extDot: 'last', ext: '.js.br' },
{ expand: true, src: ['dist/translations/*.json'], dest: './', extDot: 'last', ext: '.json.br' },
{ expand: true, src: ['dist/images/**/*.png'], dest: './', extDot: 'last', ext: '.png.br' },
{ expand: true, src: ['dist/styles/images/*.png'], dest: './', extDot: 'last', ext: '.png.br' },
{ expand: true, src: ['dist/images/*.svg'], dest: './', extDot: 'last', ext: '.svg.br' }
]
}
},
Expand Down Expand Up @@ -663,11 +653,11 @@ module.exports = function (grunt) {

grunt.registerTask('server', function (target) {
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
grunt.task.run(['serve:' + target]);
grunt.task.run([`serve:${ target}`]);
});

grunt.registerTask('loadconst', 'Load constants', function(target) {
console.log("Load constants: ", process.env.OPENSENSEMAP_API_URL, process.env.OPENSENSEMAP_MAPTILES_URL);
grunt.registerTask('loadconst', 'Load constants', function (target) {
console.log('Load constants: ', process.env.OPENSENSEMAP_API_URL, process.env.OPENSENSEMAP_MAPTILES_URL);
grunt.config('OPENSENSEMAP_API_URL', process.env.OPENSENSEMAP_API_URL);
grunt.config('OPENSENSEMAP_MAPTILES_URL', process.env.OPENSENSEMAP_MAPTILES_URL);
});
Expand Down Expand Up @@ -705,12 +695,12 @@ module.exports = function (grunt) {
]);

grunt.registerTask('default', [
'newer:jshint',
'newer:eslint',
'test',
'build'
]);

grunt.registerTask('languages','',function () {
grunt.registerTask('languages', '', function () {
var target = grunt.option('target');
var translationsFolder = '.tmp/translations/';
var targetFile = '.tmp/index.html';
Expand All @@ -721,27 +711,27 @@ module.exports = function (grunt) {

var fs = require('fs');
var done = this.async();
fs.readFile('app/index.html', 'utf8', function (err,data) {
fs.readFile('app/index.html', 'utf8', function (err, data) {
if (err) {
return console.log(err);
}
var html = '';
grunt.file.recurse(translationsFolder, function(abspath, rootdir, subdir, filename){
grunt.file.recurse(translationsFolder, function (abspath, rootdir, subdir, filename) {
if (subdir !== undefined) { return; }
if (filename.indexOf('disabled') === -1) {
var languageCode = filename.split('.')[0];
var language = languageCode.split('_')[0];
html += '<li><a ng-click="header.changeLang(\''+languageCode+'\')"><span class="lang-sm lang-lbl-full" lang="'+language+'"></span></a></li>';
html = html + ('<li><a ng-click="header.changeLang(\''+languageCode+'\')"><span class="lang-sm lang-lbl-full" lang="'+language+'"></span></a></li>');
}
});
var resultStart = data.split('<!-- languages-start -->');
var resultEnd = data.split('<!-- languages-end -->');
var res = resultStart[0] + '<!-- languages-start -->' + html + '<!-- languages-end -->' + resultEnd[1];
var res = `${resultStart[0] }<!-- languages-start -->${ html }<!-- languages-end -->${ resultEnd[1]}`;

fs.writeFile(targetFile, res, 'utf8', function (err) {
if (err) { return console.log(err); }
// grunt.file.copy('.tmp/index.html','app/index.html');
done();
if (err) { return console.log(err); }
// grunt.file.copy('.tmp/index.html','app/index.html');
done();
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
<script src="bower_components/moment/moment.js"></script>
<script src="bower_components/moment/locale/de.js"></script>
<script src="bower_components/angular-moment/angular-moment.js"></script>
<script src="bower_components/angular-dynamic-locale/src/tmhDynamicLocale.js"></script>
<script src="bower_components/angular-dynamic-locale/dist/tmhDynamicLocale.js"></script>
<script src="bower_components/angularjs-slider/dist/rzslider.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/bootstrap-ui-datetime-picker/dist/datetime-picker.js"></script>
Expand Down
Loading

0 comments on commit 82260d5

Please sign in to comment.