Skip to content

Commit ff283cc

Browse files
author
Walker Leite
committed
fix(lint): fix auto-fixable errors
1 parent c9d0f1a commit ff283cc

File tree

20 files changed

+177
-207
lines changed

20 files changed

+177
-207
lines changed

meta.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,46 @@ const fs = require('fs');
22
const path = require('path');
33

44
module.exports = {
5-
"prompts": {
6-
"name": {
7-
"type": "string",
8-
"required": true,
9-
"message": "Project name"
5+
prompts: {
6+
name: {
7+
type: 'string',
8+
required: true,
9+
message: 'Project name',
1010
},
11-
"description": {
12-
"type": "string",
13-
"required": false,
14-
"message": "Project description",
15-
"default": "A Vue.js project"
11+
description: {
12+
type: 'string',
13+
required: false,
14+
message: 'Project description',
15+
default: 'A Vue.js project',
1616
},
17-
"author": {
18-
"type": "string",
19-
"message": "Author"
17+
author: {
18+
type: 'string',
19+
message: 'Author',
2020
},
21-
"extended": {
22-
"type": "confirm",
23-
"message": "Add basic Login and Admin views with Vuex, Vue-router and Bootstrap-vue?"
24-
}
21+
extended: {
22+
type: 'confirm',
23+
message: 'Add basic Login and Admin views with Vuex, Vue-router and Bootstrap-vue?',
24+
},
25+
},
26+
filters: {
27+
'client/router.js': 'extended',
28+
'client/static/main.css': 'extended === false',
29+
'client/static/images/**/*': 'extended',
30+
'client/components/**/*': 'extended',
31+
'client/services/**/*': 'extended',
32+
'client/store/**/*': 'extended',
33+
'client/style/**/*': 'extended',
34+
'client/view/**/*': 'extended',
35+
'server/boot/add-initial-data.js': 'extended',
36+
'server/boot/create-admin.js': 'extended',
37+
'server/initial-data/**/*': 'extended',
38+
'server/models/**/*': 'extended',
39+
'test/client/components/**/*': 'extended',
40+
'test/server/account.spec.js': 'extended',
2541
},
26-
"filters": {
27-
"client/router.js": "extended",
28-
"client/static/main.css": "extended === false",
29-
"client/static/images/**/*": "extended",
30-
"client/components/**/*": "extended",
31-
"client/services/**/*": "extended",
32-
"client/store/**/*": "extended",
33-
"client/style/**/*": "extended",
34-
"client/view/**/*": "extended",
35-
"server/boot/add-initial-data.js": "extended",
36-
"server/boot/create-admin.js": "extended",
37-
"server/initial-data/**/*": "extended",
38-
"server/models/**/*": "extended",
39-
"test/client/components/**/*": "extended",
40-
"test/server/account.spec.js": "extended",
42+
complete(data, {logger}) {
43+
logger.log('To get started:');
44+
logger.log('1. Install dependencies: npm install');
45+
logger.log('2. Build with: npm run build');
4146
},
42-
"complete": function(data, {logger}) {
43-
logger.log("To get started:");
44-
logger.log("1. Install dependencies: npm install");
45-
logger.log("2. Build with: npm run build");
46-
}
4747
};

template/client/services/loopback.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ function addTokenFromLocalStorage(http) {
2727
}
2828

2929
const http = axios.create({
30-
baseURL: 'http://' + host + ':' + port + restApiRoot,
30+
baseURL: `http://${host}:${port}${restApiRoot}`,
3131
});
3232

3333
http.setToken = (token, save = true) => {
3434
http.token = token;
35-
http.defaults.headers.common['Authorization'] = token.id;
35+
http.defaults.headers.common.Authorization = token.id;
3636
if (save) exportTokenToLocalStorage(token);
3737
};
3838

@@ -43,15 +43,15 @@ http.removeToken = () => {
4343

4444
http.find = (endpoint, filter) => http.get(endpoint, {params: {filter}});
4545

46-
const interceptErrors = err => {
46+
const interceptErrors = (err) => {
4747
try {
4848
err = Object.assign(new Error(), err.response.data.error);
4949
} catch (e) {
5050
// Will return err if something goes wrong
5151
}
5252
return Promise.reject(err);
5353
};
54-
const interceptResponse = res => {
54+
const interceptResponse = (res) => {
5555
try {
5656
return res.data;
5757
} catch (e) {

template/client/store/modules/auth/actions.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,23 @@ export function syncRouter({state, dispatch}, router) {
4646
*/
4747
export function signIn({commit, dispatch, state}, {email, password}) {
4848
return loopback
49-
.post('/Accounts/login', {
50-
email,
51-
password,
52-
})
53-
.then(token => {
54-
commit('setAccessToken', token);
49+
.post('/Accounts/login', {
50+
email,
51+
password,
52+
})
53+
.then((token) => {
54+
commit('setAccessToken', token);
5555

56-
// Update Loopback Token
57-
if (state.access_token !== null) {
58-
loopback.setToken(state.access_token);
59-
} else {
60-
loopback.removeToken();
61-
}
56+
// Update Loopback Token
57+
if (state.access_token !== null) {
58+
loopback.setToken(state.access_token);
59+
} else {
60+
loopback.removeToken();
61+
}
6262

63-
router.push({name: 'dashboard'});
64-
return dispatch('loadAccount', state.access_token.userId);
65-
});
63+
router.push({name: 'dashboard'});
64+
return dispatch('loadAccount', state.access_token.userId);
65+
});
6666
}
6767

6868
/**
@@ -89,7 +89,7 @@ export function signOut({commit}) {
8989
*/
9090
export function loadAccount({commit}, userId) {
9191
return loopback
92-
.get('/Accounts/' + userId)
92+
.get(`/Accounts/${userId}`)
9393
.then(acc => commit('setAccount', acc));
9494
}
9595

template/common/models/message.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export default function(Message) {
22
Message.greet = (msg, cb) => {
3-
process.nextTick(function() {
3+
process.nextTick(() => {
44
msg = msg || 'hello';
5-
cb(null, 'Sender says ' + msg + ' to receiver');
5+
cb(null, `Sender says ${msg} to receiver`);
66
});
77
};
8-
};
8+
}

template/gulp-tasks/build.js

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ import buffer from 'vinyl-buffer';
1111
import {dirs} from './config.js';
1212
import {customSass} from './compilers.js';
1313

14-
gulp.task('build:test', () => {
15-
return gulp.src([
16-
path.resolve(dirs.test, '**/*.test.js'),
17-
path.resolve(dirs.test, 'config.js'),
18-
])
14+
gulp.task('build:test', () => gulp.src([
15+
path.resolve(dirs.test, '**/*.test.js'),
16+
path.resolve(dirs.test, 'config.js'),
17+
])
1918
.pipe(sourcemaps.init())
2019
.pipe(babel())
2120
.pipe(sourcemaps.write())
22-
.pipe(gulp.dest(dirs.buildTest));
23-
});
21+
.pipe(gulp.dest(dirs.buildTest)));
2422

2523
gulp.task('build:client', ['copy:client'], () => {
2624
vueify.compiler.applyConfig({
@@ -34,7 +32,7 @@ gulp.task('build:client', ['copy:client'], () => {
3432
},
3533
});
3634

37-
let b = browserify({
35+
const b = browserify({
3836
entries: path.resolve(dirs.srcClient, 'main.js'),
3937
debug: true,
4038
});
@@ -49,43 +47,38 @@ gulp.task('build:client', ['copy:client'], () => {
4947
'bundle.css'
5048
),
5149
global: true,
52-
generateScopedName: function(name, filename) {
53-
var matches = filename.match(/^\/node_modules/);
50+
generateScopedName(name, filename) {
51+
const matches = filename.match(/^\/node_modules/);
5452
if (matches) return name;
5553
if (process.env.NODE_ENV === 'production') {
5654
return modulesify.generateShortName(name, filename);
57-
} else {
58-
return modulesify.generateLongName(name, filename);
5955
}
56+
return modulesify.generateLongName(name, filename);
6057
},
6158
});
6259

6360
return b.bundle()
64-
.pipe(source('bundle.js'))
65-
.pipe(buffer())
66-
.pipe(sourcemaps.init({loadMaps: true}))
67-
.pipe(sourcemaps.write('.'))
68-
.pipe(gulp.dest(dirs.buildClient));
61+
.pipe(source('bundle.js'))
62+
.pipe(buffer())
63+
.pipe(sourcemaps.init({loadMaps: true}))
64+
.pipe(sourcemaps.write('.'))
65+
.pipe(gulp.dest(dirs.buildClient));
6966
});
7067

71-
gulp.task('build:common', () => {
72-
return gulp.src(path.resolve(dirs.srcCommon, '**/*.js'))
68+
gulp.task('build:common', () => gulp.src(path.resolve(dirs.srcCommon, '**/*.js'))
7369
.pipe(sourcemaps.init())
7470
.pipe(babel())
7571
.pipe(sourcemaps.write('.'))
76-
.pipe(gulp.dest(dirs.buildCommon));
77-
});
72+
.pipe(gulp.dest(dirs.buildCommon)));
7873

79-
gulp.task('build:server', ['copy:server'], () => {
80-
return gulp.src([
81-
path.resolve(dirs.srcServer, '**/*.js'),
82-
path.resolve(dirs.root, 'index.js'),
83-
])
74+
gulp.task('build:server', ['copy:server'], () => gulp.src([
75+
path.resolve(dirs.srcServer, '**/*.js'),
76+
path.resolve(dirs.root, 'index.js'),
77+
])
8478
.pipe(sourcemaps.init())
8579
.pipe(babel())
8680
.pipe(sourcemaps.write('.'))
87-
.pipe(gulp.dest(dirs.buildServer));
88-
});
81+
.pipe(gulp.dest(dirs.buildServer)));
8982

9083
gulp.task('build', [
9184
'build:test',

template/gulp-tasks/compilers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {dirs} from './config.js';
44

55
function replaceCuringas(content) {
66
// FIXME: Not working
7-
const replacer = '@import "' + dirs.srcClient + '/$2";';
7+
const replacer = `@import "${dirs.srcClient}/$2";`;
88

99
let replaced = content.replace(/@import.+(\@)(.*?)[\"\']/, replacer);
1010
replaced = content.replace(/@import.+(\~)(.*?)[\"\']/, replacer);
@@ -19,7 +19,7 @@ export function customSass(content, callback, compiler, filePath) {
1919

2020
// Global SCSS
2121
//
22-
content = '@import "' + relativePath + '";' + content;
22+
content = `@import "${relativePath}";${content}`;
2323

2424
content = replaceCuringas(content);
2525

template/gulp-tasks/copy.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,14 @@ import gulp from 'gulp';
22
import path from 'path';
33
import {dirs} from './config.js';
44

5-
gulp.task('copy:client:fa', function() {
6-
return gulp.src(path.resolve(dirs.modules, 'font-awesome/fonts/*'))
7-
.pipe(gulp.dest(path.resolve(dirs.buildClient, 'static/fonts')));
8-
});
5+
gulp.task('copy:client:fa', () => gulp.src(path.resolve(dirs.modules, 'font-awesome/fonts/*'))
6+
.pipe(gulp.dest(path.resolve(dirs.buildClient, 'static/fonts'))));
97

10-
gulp.task('copy:client', ['copy:client:fa'], function() {
11-
return gulp.src(dirs.srcClient + '/**/!(*.vue|*.js)')
12-
.pipe(gulp.dest(path.resolve(dirs.buildClient)));
13-
});
8+
gulp.task('copy:client', ['copy:client:fa'], () => gulp.src(`${dirs.srcClient}/**/!(*.vue|*.js)`)
9+
.pipe(gulp.dest(path.resolve(dirs.buildClient))));
1410

15-
gulp.task('copy:package', function() {
16-
return gulp.src(dirs.root + '/package.json')
17-
.pipe(gulp.dest(path.resolve(dirs.build)));
18-
});
11+
gulp.task('copy:package', () => gulp.src(`${dirs.root}/package.json`)
12+
.pipe(gulp.dest(path.resolve(dirs.build))));
1913

20-
gulp.task('copy:server', function() {
21-
return gulp.src(dirs.srcServer + '/**/*.json')
22-
.pipe(gulp.dest(path.resolve(dirs.buildServer)));
23-
});
14+
gulp.task('copy:server', () => gulp.src(`${dirs.srcServer}/**/*.json`)
15+
.pipe(gulp.dest(path.resolve(dirs.buildServer))));

template/gulp-tasks/serve.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ gulp.task('reload:server', ['build:server'], () => {
1313

1414
gulp.task('watch:server', () => {
1515
gulp.watch([
16-
dirs.srcServer + '/**/*.js',
17-
dirs.srcServer + '/**/*.json',
18-
dirs.srcCommon + '/**/*.js',
16+
`${dirs.srcServer}/**/*.js`,
17+
`${dirs.srcServer}/**/*.json`,
18+
`${dirs.srcCommon}/**/*.js`,
1919
], ['reload:server']);
2020
});
2121

@@ -27,8 +27,8 @@ gulp.task('reload:client', ['build:client'], () => {
2727

2828
gulp.task('watch:client', () => {
2929
gulp.watch([
30-
dirs.srcClient + '/**/*',
31-
dirs.srcCommon + '/**/*.js',
30+
`${dirs.srcClient}/**/*`,
31+
`${dirs.srcCommon}/**/*.js`,
3232
], ['reload:client']);
3333
});
3434

@@ -41,9 +41,7 @@ gulp.task('serve:client', ['build:client', 'watch:client'], () => {
4141
name: 'Client App',
4242
root: dirs.buildClient,
4343
livereload: true,
44-
middleware: (connect, opt) => {
45-
return [historyApiFallback()];
46-
},
44+
middleware: (connect, opt) => [historyApiFallback()],
4745
});
4846
});
4947

template/gulp-tasks/test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import {Server} from 'karma';
44
import path from 'path';
55
import {dirs} from './config.js';
66

7-
gulp.task('test:server', () => {
8-
return gulp.src(path.resolve(dirs.testServer, '**/*.spec.js'))
7+
gulp.task('test:server', () => gulp.src(path.resolve(dirs.testServer, '**/*.spec.js'))
98
.pipe(mocha({
109
compilers: 'js:babel-core/register',
1110
require: path.resolve(dirs.test, 'mocha.conf.js'),
12-
}));
13-
});
11+
})));
1412

1513
gulp.task('test:client', (done) => {
1614
new Server({

template/index.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import app from './server/server'
2-
import express from 'express'
1+
import app from './server/server';
2+
import express from 'express';
33

4-
app.use(express.static('client'))
4+
app.use(express.static('client'));
55
app.on('started', () => {
6-
const baseUrl = app.get('url').replace(/\/$/, '')
7-
console.log('Browse your CLIENT files at %s', baseUrl)
8-
})
6+
const baseUrl = app.get('url').replace(/\/$/, '');
7+
console.log('Browse your CLIENT files at %s', baseUrl);
8+
});
99

10-
if (require.main === module)
11-
app.start();
10+
if (require.main === module) { app.start(); }
1211

13-
export default app
12+
export default app;

0 commit comments

Comments
 (0)