Skip to content

Commit

Permalink
Added ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSkierniewski committed Apr 23, 2017
1 parent f4cd2e5 commit 3c3445b
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 155 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
resources/assets/js/vendor/*.js
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ before_script:
- docker exec -i platform_web_server_1 phpenmod xdebug # enabling xdebug for code coverage

script:
- docker-compose run --rm -w /var/www node_server npm -s lint
- docker-compose run --rm -w /var/www node_server npm -s test -- --verbose
- "docker exec -i platform_web_server_1 php /var/www/vendor/bin/codecept run -c /var/www/codeception.yml -o \"settings: lint:false\" --coverage --coverage-xml --env platform,ml_disabled"
- docker exec -i platform_web_server_1 mkdir -p /var/www/build/logs
Expand Down
49 changes: 48 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"test": "ava",
"test:watch": "npm test -- --watch"
"test:watch": "npm test -- --watch",
"lint": "eslint resources/assets/js/"
},
"babel": {
"presets": [
Expand All @@ -32,6 +33,50 @@
"./test-setup.js"
]
},
"eslintConfig": {
"env": {
"es6": true,
"browser": true,
"node": true
},
"globals": {
"$": true,
"jQuery": true,
"axiosMock": true
},
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"plugins": [
"ava"
],
"extends": [
"eslint:recommended",
"plugin:ava/recommended"
],
"rules": {
"ava/prefer-async-await": "off",
"ava/no-cb-test": "error",
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"comma-dangle": "error",
"curly": "error",
"default-case": "error",
"eqeqeq": ["error", "always"],
"guard-for-in": "error",
"linebreak-style": ["error", "unix"],
"no-alert": "error",
"no-confusing-arrow": "error",
"no-else-return": "error",
"no-floating-decimal": "error",
"no-multi-spaces": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"semi": ["error", "never"],
"valid-jsdoc": "error",
"vars-on-top": "error"
}
},
"devDependencies": {
"animate-scss": "^3.2.1",
"ava": "^0.19.1",
Expand All @@ -44,6 +89,8 @@
"bootstrap-sass": "^3.3.7",
"browser-env": "^2.0.30",
"cross-env": "^3.2.3",
"eslint": "^3.19.0",
"eslint-plugin-ava": "^4.2.0",
"font-awesome": "^4.7.0",
"jquery": "^3.1.1",
"jquery-colorbox": "^1.6.4",
Expand Down
25 changes: 13 additions & 12 deletions resources/assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,50 @@
import Translations from './lang/locales.js';
import VueI18n from 'vue-i18n';
import Translations from './lang/locales.js'
import Vue from 'vue'
import VueI18n from 'vue-i18n'

/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/

require('./bootstrap');
require('./common');
require('./cookies');
require('./bootstrap')
require('./common')
require('./cookies')

/**
* Next, we will create a fresh Vue application instance and attach it to
* the body of the page. From here, you may begin adding components to
* the application, or feel free to tweak this setup for your needs.
*/

Vue.use(VueI18n);
Vue.use(VueI18n)

const i18n = new VueI18n({
locale: document.documentElement.lang,
fallbackLocale: 'en',
messages: Translations
});
})

/**
* Laravel Passport
*/
Vue.component(
'passport-clients',
require('./components/passport/Clients.vue')
);
)

Vue.component(
'passport-authorized-clients',
require('./components/passport/AuthorizedClients.vue')
);
)

Vue.component(
'passport-personal-access-tokens',
require('./components/passport/PersonalAccessTokens.vue')
);
)

const app = new Vue({
new Vue({
el: '#app',
i18n: i18n
});
})
29 changes: 10 additions & 19 deletions resources/assets/js/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,37 @@
window._ = require('lodash');
window._ = require('lodash')

/**
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
* for JavaScript based Bootstrap features such as modals and tabs. This
* code may be modified to fit the specific needs of your application.
*/

window.$ = window.jQuery = require('jquery');
window.$ = window.jQuery = require('jquery')

require('bootstrap-sass');
require('./vendor/responsive-paginate');
require('bootstrap-sass')
require('./vendor/responsive-paginate')
/**
* We'll load jQuery Plugins
*/

window.colorbox = require('jquery-colorbox');
window.matchHeight = require('jquery-match-height');

/**
* Vue is a modern JavaScript library for building interactive web interfaces
* using reactive data binding and reusable components. Vue's API is clean
* and simple, leaving you to focus on building your next great project.
*/

window.Vue = require('vue');

window.colorbox = require('jquery-colorbox')
window.matchHeight = require('jquery-match-height')

/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/

window.axios = require('axios');
window.axios = require('axios')

window.axios.defaults.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'

/**
* We need to pass cookie to api subdomain
*/
window.axios.defaults.withCredentials = true;
window.axios.defaults.withCredentials = true

/**
* Echo exposes an expressive API for subscribing to channels and listening
Expand Down
88 changes: 44 additions & 44 deletions resources/assets/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@
* @returns {{}}
*/
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
var o = {}
var a = this.serializeArray()
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
o[this.name] = [o[this.name]]
}
o[this.name].push(this.value || '');
o[this.name].push(this.value || '')
} else {
o[this.name] = this.value || '';
o[this.name] = this.value || ''
}
});
return o;
};
})
return o
}

/*Loading object*/
window.Loading = {
loadingContainer: '.loading',
loadingMinHeight: 200,
start: function(container) {
var me = this;
var destHtml = $(container);
var me = this
var destHtml = $(container)
if (destHtml.length > 0) {
var loading = $(me.loadingContainer);
loading.css('top', destHtml.offset().top + 'px');
loading.css('left', destHtml.offset().left + 'px');
loading.css('width', destHtml.outerWidth() + 'px');
loading.css('height', destHtml.outerHeight() + 'px');
var loading = $(me.loadingContainer)
loading.css('top', destHtml.offset().top + 'px')
loading.css('left', destHtml.offset().left + 'px')
loading.css('width', destHtml.outerWidth() + 'px')
loading.css('height', destHtml.outerHeight() + 'px')
}
},
stop: function() {
var me = this;
$(me.loadingContainer).removeAttr('style');
var me = this
$(me.loadingContainer).removeAttr('style')
}
};
}

/**
* Function sets form validation errors in form
Expand All @@ -47,11 +47,11 @@ window.Loading = {
*
*/
window.setFormValidationErrors = function(fieldName, message) {
var field = $('input[name=' + fieldName + ']').parent('.form-group'); // get the field
var field = $('input[name=' + fieldName + ']').parent('.form-group') // get the field
if (field.hasClass('has-error')) { // if already has error, then set new message
field.find('.help-block').text(message);
field.find('.help-block').text(message)
} else { // append error with html
field.addClass('has-error').append('<p class="help-block">' + message + '</p>');
field.addClass('has-error').append('<p class="help-block">' + message + '</p>')
}
}

Expand All @@ -63,73 +63,73 @@ window.setFormValidationErrors = function(fieldName, message) {
*
*/
window.setGlobalMessage = function(code, message) {
$('#content').prepend('<div class="message-box"><div class="alert alert-' + code + ' alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' + message + '</div></div>');
$('#content').prepend('<div class="message-box"><div class="alert alert-' + code + ' alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times</span></button>' + message + '</div></div>')
}

/**
* Function removes form validation errors
*/
window.clearFormValidationErrors = function() {
var error = $(".form-group.has-error");
error.removeClass('has-error');
error.find('.help-block').remove();
var error = $(".form-group.has-error")
error.removeClass('has-error')
error.find('.help-block').remove()
}

/**
* Function hides global messages after 5 second delay
*
*/
window.hideMessages = function() {
setTimeout(clearMessages, 5000);
setTimeout(clearMessages, 5000)
}

/**
* Function fades outs and removes global messages
*/
window.clearMessages = function() {
var alert = $("div.message-box div.alert");
var alert = $("div.message-box div.alert")
alert.fadeOut("slow", function() {
alert.remove();
});
alert.remove()
})
$("div.message-box").slideToggle("slow", function() {
$(this).remove();
});
$(this).remove()
})
}

$(function() {
var lang = $('html').attr('lang');
var lang = $('html').attr('lang')
// Expand parent of an active element
$(".nav-stacked li.active").parents('li').addClass('active').has('ul').children('ul').addClass('collapse in');
$(".nav-stacked li.active").parents('li').addClass('active').has('ul').children('ul').addClass('collapse in')
// Loading on form submit actions
$('form').submit(function(event) {
Loading.start('#main-container');
});
$('form').submit(function() {
Loading.start('#main-container')
})
// Responsive pagination
$(".pagination").rPage();
$(".pagination").rPage()
// Colorbox
$('img.colorbox').click(function() {
$(this).colorbox({
href: $(this).parent('a').attr('href'),
rel: $(this).parent('a').attr('rel'),
maxWidth: "95%",
maxHeight: "95%"
});
});
})
})
$('a.colorbox').colorbox({
rel: $(this).attr('rel'),
maxWidth: "95%",
maxHeight: "95%"
});
})
$('a.colorbox-iframe').colorbox({
iframe: true,
innerWidth: 640,
innerHeight: 360
}
);
)
// Load translation files
if (lang !== 'en') {
$.getScript('/js/vendor/jquery-colorbox/i18n/jquery.colorbox-' + lang + '.js');
$.getScript('/js/vendor/jquery-colorbox/i18n/jquery.colorbox-' + lang + '.js')
}
// jquery.matchHeight.js
$('.mh-column').matchHeight({property: 'min-height'});
});
$('.mh-column').matchHeight({property: 'min-height'})
})
Loading

0 comments on commit 3c3445b

Please sign in to comment.