Skip to content

Commit 91293a5

Browse files
author
Matt Gaunt
committed
Adding eslint and npm run test for travis
1 parent 05945f5 commit 91293a5

20 files changed

+842
-50
lines changed

.eslintrc.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module.exports = {
2+
extends: ['eslint:recommended', 'google'],
3+
env: {
4+
node: true,
5+
es6: true,
6+
},
7+
parserOptions: {
8+
ecmaVersion: 2017,
9+
sourceType: 'module',
10+
},
11+
rules: {
12+
'require-jsdoc': 0,
13+
'valid-jsdoc': 0,
14+
'no-console': 0,
15+
},
16+
overrides: [
17+
{
18+
files: ['src/**/*.js'],
19+
env: {
20+
browser: true,
21+
}
22+
},
23+
{
24+
files: [
25+
'src/service-worker.js',
26+
],
27+
env: {
28+
serviceWorker: true,
29+
},
30+
globals: {
31+
workbox: true,
32+
},
33+
},
34+
],
35+
};

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ node_js:
66
- '8'
77
- '6'
88
- '4'
9-
script:
10-
- gulp build
9+

gulp-tasks/build.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ const fse = require('fs-extra');
33

44
const getTaskFilepaths = require('./utils/get-task-filepaths');
55

6-
const cleanDestDir = () => {
6+
function cleanDestDir() {
77
return fse.remove(global.__buildConfig.dest);
8-
};
8+
}
99

10-
const build = (done) => {
10+
function build(done) {
1111
const parallelTasks = [];
1212
const postBuildTasks = [];
1313
const taskFiles = getTaskFilepaths();
@@ -29,7 +29,7 @@ const build = (done) => {
2929
];
3030

3131
return gulp.series(buildTasks)(done);
32-
};
32+
}
3333

3434
module.exports = {
3535
task: build,

gulp-tasks/copy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ const gulp = require('gulp');
22

33
const extensions = [
44
'json',
5-
'ico'
5+
'ico',
66
];
77

8-
const copy = () => {
8+
function copy() {
99
return gulp.src(`${global.__buildConfig.src}/**/*.{${extensions.join(',')}}`)
1010
.pipe(gulp.dest(global.__buildConfig.dest));
1111
}
1212

1313
module.exports = {
1414
build: copy,
15-
watchGlobs: `${global.__buildConfig.src}/**/*.{${extensions.join(',')}}`
15+
watchGlobs: `${global.__buildConfig.src}/**/*.{${extensions.join(',')}}`,
1616
};

gulp-tasks/css.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ const css = () => {
1313

1414
module.exports = {
1515
build: css,
16-
watchGlobs: `${global.__buildConfig.src}/**/*.css`
16+
watchGlobs: `${global.__buildConfig.src}/**/*.css`,
1717
};

gulp-tasks/html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ const html = () => {
1616

1717
module.exports = {
1818
build: html,
19-
watchGlobs: `${global.__buildConfig.src}/**/*.html`
19+
watchGlobs: `${global.__buildConfig.src}/**/*.html`,
2020
};

gulp-tasks/images.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ const images = () => {
1717

1818
module.exports = {
1919
build: images,
20-
watchGlobs: `${global.__buildConfig.src}/**/*.{${extensions.join(',')}}`
20+
watchGlobs: `${global.__buildConfig.src}/**/*.{${extensions.join(',')}}`,
2121
};

gulp-tasks/javascript.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const processScript = (scriptPath, relativePath) => {
2121
},
2222
plugins: [
2323
replacePlugin({
24-
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
24+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
2525
}),
2626
uglifyPlugin({}, esMinify),
2727
],
@@ -67,5 +67,5 @@ const javascript = (done) => {
6767

6868
module.exports = {
6969
build: javascript,
70-
watchGlobs: `${global.__buildConfig.src}/**/*.js`
70+
watchGlobs: `${global.__buildConfig.src}/**/*.js`,
7171
};

gulp-tasks/sass.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ const extensions = [
99
'scss',
1010
];
1111

12-
const sass = () => {
12+
function sass() {
1313
return gulp.src(`${global.__buildConfig.src}/**/*.{${extensions.join(',')}}`)
1414
.pipe(sourcemaps.init())
1515
.pipe(
1616
gulpSass({
17-
precision: 10
17+
precision: 10,
1818
})
1919
.on('error', gulpSass.logError)
2020
)
2121
.pipe(postcssConfig())
2222
.pipe(sourcemaps.write())
2323
.pipe(gulp.dest(global.__buildConfig.dest));
24-
};
24+
}
2525

2626
module.exports = {
2727
build: sass,
28-
watchGlobs: `${global.__buildConfig.src}/**/*.{${extensions.join(',')}}`
29-
}
28+
watchGlobs: `${global.__buildConfig.src}/**/*.{${extensions.join(',')}}`,
29+
};

gulp-tasks/serve.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ const path = require('path');
55

66
const PREFERRED_PORT = 5000;
77

8-
const serveViaStatic = () => {
8+
function serveViaStatic() {
99
const serve = serveStatic(global.__buildConfig.dest);
1010

1111
const httpServer = http.createServer((req, res) => {
1212
serve(req, res, () => {
13-
res.writeHead(404, { 'Content-Type': 'text/plain' });
13+
res.writeHead(404, {'Content-Type': 'text/plain'});
1414
res.end('Not Found.');
1515
});
1616
});
@@ -30,9 +30,9 @@ const serveViaStatic = () => {
3030
const address = httpServer.address();
3131
console.log(`Serving @ http://${address.address}:${address.port}`);
3232
});
33-
};
33+
}
3434

35-
const serveViaBrowserSync = () => {
35+
function serveViaBrowserSync() {
3636
const server = browserSync.create();
3737

3838
server.watch(path.posix.join(global.__buildConfig.dest, '**', '*'))
@@ -49,9 +49,9 @@ const serveViaBrowserSync = () => {
4949
logFileChanges: false,
5050
port: PREFERRED_PORT,
5151
});
52-
};
52+
}
5353

54-
const serve = () => {
54+
function serve() {
5555
if (process.env.NODE_ENV === 'production') {
5656
return serveViaStatic();
5757
} else {

gulp-tasks/serviceWorker.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
const path = require('path');
2-
const gulp = require('gulp');
32
const workboxBuild = require('workbox-build');
43

5-
const serviceWorker = async () => {
4+
async function serviceWorker() {
65
await workboxBuild.injectManifest({
76
swSrc: path.join(global.__buildConfig.src, 'service-worker.js'),
87
swDest: path.join(global.__buildConfig.dest, 'service-worker.js'),
9-
globDirectory: global.__buildConfig.dest
8+
globDirectory: global.__buildConfig.dest,
109
});
11-
};
10+
}
1211

1312
module.exports = {
1413
build: serviceWorker,
15-
watchGlobs: `${global.__buildConfig.dest}/**/*.*`
14+
watchGlobs: `${global.__buildConfig.dest}/**/*.*`,
1615
};
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require('path');
22
const fs = require('fs');
33

4-
module.exports = () => {
4+
module.exports = function() {
55
const tasksDirectory = path.join(__dirname, '..');
66
const taskFileNames = fs.readdirSync(tasksDirectory);
77
const fullPaths = [];
@@ -12,7 +12,7 @@ module.exports = () => {
1212
continue;
1313
}
1414

15-
fullPaths.push(path.join(tasksDirectory, taskFileName))
15+
fullPaths.push(path.join(tasksDirectory, taskFileName));
1616
}
1717
return fullPaths;
18-
}
18+
};

gulp-tasks/utils/postcssConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ module.exports = () => {
1111
customProperties: {
1212
// Allows both fallback and CSS variables to be used
1313
preserve: true,
14-
}
15-
}
14+
},
15+
},
1616
}),
1717
cssnano({
1818
autoprefixer: false,

gulp-tasks/watch.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
const gulp = require('gulp');
2-
const fse = require('fs-extra');
32

43
const getTaskFilepaths = require('./utils/get-task-filepaths');
54

65
const watch = (done) => {
7-
const watchTasks = [];
86
const taskFiles = getTaskFilepaths();
97
for (const taskFilepath of taskFiles) {
108
const {watchGlobs, build} = require(taskFilepath);

gulpfile.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
const gulp = require('gulp');
2020
const path = require('path');
21-
const fse = require('fs-extra');
2221
const getTaskFilepaths = require('./gulp-tasks/utils/get-task-filepaths');
2322

2423
global.__buildConfig = {

0 commit comments

Comments
 (0)