Commit aa02752b authored by Emma's avatar Emma 🦉

set up eslint/fix some files to follow rules

parent 48bc581d
{
"extends": "eslint:recommended",
"env": {
"es6": true,
"commonjs": true
},
"rules": {
"brace-style": ["error", "1tbs"],
"curly": "error",
"comma-dangle": ["error", "always-multiline"],
"guard-for-in": "warn",
"semi": "error",
"semi-style": ["error", "last"]
},
"overrides": [
{
"files": ["assets/js/**.js"],
"env": {
"browser": true
},
"parser": "babel-eslint",
"rules": {
"no-console": 0
}
}
]
}
'use strict';
import $ from 'jquery';
import Translator from 'bazinga-translator';
$(function () {
$('.confirm-comment-delete').click(function () {
......
......@@ -13,7 +13,7 @@ $(function () {
url: Routing.generate('fetch_title'),
method: 'POST',
dataType: 'json',
data: { url: url }
data: { url: url },
}).done(data => {
if ($receiver.val().trim() === '') {
$('.receive-title').val(data.title);
......
......@@ -10,7 +10,7 @@ function createPreview() {
url: Routing.generate('markdown_preview'),
method: 'POST',
dataType: 'html',
data: { markdown: $(this).val() }
data: { markdown: $(this).val() },
}).done(content => {
const html = content.length > 0
? `<div class="markdown-input__preview">${content}</div>`
......
......@@ -4,6 +4,7 @@ import $ from 'jquery';
import distanceInWords from 'date-fns/distance_in_words';
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
import isBefore from 'date-fns/is_before';
import Translator from 'bazinga-translator';
function makeTimesRelative(locale) {
$('.relative-time[datetime]').each(function () {
......
......@@ -6,7 +6,7 @@ $(function () {
$('.select2').each(function () {
Promise.all([
import('select2'),
import('select2/dist/css/select2.css')
import('select2/dist/css/select2.css'),
]).then(() => {
$(this).select2();
}).catch(e => {
......
......@@ -24,11 +24,11 @@ $(() => {
$.ajax({
url: Router.generate(subscribe ? 'subscribe' : 'unsubscribe', {
forum_name: forum,
_format: 'json'
_format: 'json',
}),
method: 'POST',
data: $form.serialize(),
dataType: 'json'
dataType: 'json',
}).done(() => {
const proto = $button.data('toggle-prototype');
......
......@@ -22,7 +22,7 @@ $(function () {
Promise.all([
import('highlight.js/lib/highlight'),
import(`highlight.js/lib/languages/${language}`),
import(`highlight.js/styles/${theme}.css`)
import(`highlight.js/styles/${theme}.css`),
]).then(imports => {
const [hljs, definition] = imports;
......
......@@ -74,7 +74,7 @@ function vote($form, isUp) {
const data = {
choice: choice,
token: $form.find('input[name=token]').val()
token: $form.find('input[name=token]').val(),
};
$.post(url, data).done(() => {
......@@ -88,7 +88,7 @@ function vote($form, isUp) {
// update title attributes
$form.find('.vote-up').attr('title', getUpButtonTitle(choice));
$form.find('.vote-down').attr('title', getDownButtonTitle(choice))
$form.find('.vote-down').attr('title', getDownButtonTitle(choice));
}).fail((xhr, textStatus, err) => {
console && console.log('Failed to vote', textStatus, err);
});
......
This diff is collapsed.
......@@ -2,8 +2,10 @@
"private": true,
"devDependencies": {
"@symfony/webpack-encore": "^0.17.0",
"babel-eslint": "^8.2.3",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-preset-es2015": "^6.24.1",
"eslint": "^4.19.1",
"font-blast": "^0.6.1",
"fontello-cli": "^0.4.0",
"less": "^2.7.3",
......@@ -24,6 +26,8 @@
"scripts": {
"build-dev": "node_modules/.bin/encore dev",
"build-prod": "node_modules/.bin/encore production",
"lint": "npm run lint:js",
"lint:js": "node_modules/.bin/eslint assets/js webpack.config.js",
"watch": "node_modules/.bin/encore dev --watch"
}
}
......@@ -29,6 +29,6 @@ Encore
module.exports = merge(Encore.getWebpackConfig(), {
externals: {
"fosjsrouting": "Routing"
"fosjsrouting": "Routing",
},
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment