Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Commit

Permalink
Merge branch 'feature/installing-airbnb-standard'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Robinson committed Nov 7, 2018
2 parents b54e798 + e5c7d84 commit adebbbf
Show file tree
Hide file tree
Showing 11 changed files with 742 additions and 186 deletions.
122 changes: 35 additions & 87 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,104 +1,52 @@
module.exports = {
'extends': 'eslint:recommended',

'env': {
'node': true,
'browser': true,
'commonjs': true,
'shared-node-browser': true,
'es6': true,
'worker': true,
'serviceworker': true
},

// 'globals': {
// 'Scenario': true,
// 'actor': true,
// 'Feature': true
// },
'extends': 'airbnb-standard',

'parserOptions': {
'ecmaVersion': 8,
'ecmaVersion': 9,
'ecmaFeatures': {
'impliedStrict': true
}
},

'rules': {
'array-bracket-spacing': 2,
'block-scoped-var': 2,
'brace-style': [1, '1tbs', {'allowSingleLine': true}],
'comma-dangle': 2,
'comma-spacing': 2,
'computed-property-spacing': 2,
'curly': 2,
'eol-last': 2,
'eqeqeq': [2, 'smart'],
'guard-for-in': 2,
'arrow-body-style': 0,
'import/order': 0,
'indent': [1, 4, {'SwitchCase': 1}],
'key-spacing': 1,
'keyword-spacing': [2, {'before': true, 'after': true}],
'linebreak-style': [2, 'unix'],
'lines-around-comment': [2, {'beforeBlockComment': true, 'afterBlockComment': false}],
'new-parens': 2,
'no-array-constructor': 2,
'no-caller': 2,
'no-console': 1,
'no-var': 1,
'no-catch-shadow': 2,
'no-eval': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-extra-parens': [2, 'functions'],
'no-implied-eval': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': 2,
'no-lone-blocks': 2,
'no-unreachable': 1,
'no-loop-func': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-native-reassign': 2,
'no-nested-ternary': 2,
'no-new-func': 2,
'no-new-object': 2,
'no-new-wrappers': 2,
'no-octal-escape': 2,
'no-process-exit': 2,
'no-proto': 2,
'no-return-assign': 2,
'no-script-url': 2,
'no-sequences': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-trailing-spaces': 2,
'no-undef-init': 2,
'no-undefined': 2,
'no-unused-expressions': 2,
'no-unused-vars': [1, {'vars': 'all', 'args': 'none'}],
'no-with': 2,
'object-curly-spacing': [2, 'never'],
'one-var': [2, 'never'],
'quote-props': [2, 'consistent-as-needed'],
'quotes': [1, 'single', 'avoid-escape'],
'semi': [2, 'always'],
'semi-spacing': [2, {'before': false, 'after': true}],
'space-before-blocks': [1, 'always'],
'space-before-function-paren': [1, {'anonymous': 'always', 'named': 'never'}],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [2, { 'words': true, 'nonwords': false }],
'spaced-comment': [2, 'always'],
'strict': 2,
'yoda': [2, 'never'],
'max-nested-callbacks': [1, 3],
'no-continue': 0,

// We need a correct documentation for our scripts.
'valid-jsdoc': [1, {
'matchDescription': '.+',
'prefer': {
'returns': 'return',
'property': 'prop'
},
'requireReturn': false
'requireParamDescription': true,
'requireParamType': true,
'requireReturn': true,
'requireReturnDescription': false,
'requireReturnType': true
}],
"require-jsdoc": [1, {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true,
"ArrowFunctionExpression": true,
"FunctionExpression": true
}
}]
}
},

'overrides': [
{
'files': ['gulp/**/*.js', 'gulpfile.js', 'codecept.conf.js'],
'rules': {
'import/no-extraneous-dependencies': 0,
'global-require': 0,
'import/no-dynamic-require': 0,
'no-param-reassign': 0,
}
}
]
};
4 changes: 2 additions & 2 deletions gulp/libs/error-handler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const gutil = require('./utils');
const notifier = require('node-notifier');
const gutil = require('./utils');

module.exports = function (errObj) {
module.exports = (errObj) => {
let message = gutil.colors.red('Error');

if ('plugin' in errObj) {
Expand Down
1 change: 0 additions & 1 deletion gulp/tasks/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

module.exports = (gulp, globalConfig) => {

const taskConfig = {
watch: [
`${globalConfig.srcDir}/*.*` // Only copy top-level files
Expand Down
4 changes: 0 additions & 4 deletions gulp/tasks/images.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
/**
* Compress images.
*
* Install:
* yarn add -D gulp-imagemin gul-newer
*/

const imagemin = require('gulp-imagemin');
const newer = require('gulp-newer');

module.exports = (gulp, globalConfig) => {

const taskConfig = {
watch: [`${globalConfig.srcDir}/images/**/*`]
};
Expand Down
14 changes: 6 additions & 8 deletions gulp/tasks/scripts.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
/**
* Parse and minify JavaScript
*
* Install:
* yarn add -D babel-preset-es2015 babelify gulp-eslint gulp-if vinyl-source-stream browserify vinyl-buffer gulp-uglify gulp-sourcemaps
*/

const eslint = require('gulp-eslint');
const eslintOptions = require('../../.eslintrc.js');
const gulpif = require('gulp-if');
const source = require('vinyl-source-stream');
const browserify = require('browserify');
const uglify = require('gulp-uglify');
const sourcemaps = require('gulp-sourcemaps');
const buffer = require('vinyl-buffer');
const errorHandler = require('../libs/error-handler');
const eslintOptions = require('../../.eslintrc.js');

module.exports = (gulp, globalConfig) => {

const taskConfig = {
watch: [`${globalConfig.srcDir}/js/**/*`]
};

gulp.task('scripts-lint', () => {
taskConfig.watch.push('gulpfile.js');
taskConfig.watch.push('tasks/*.js');
if (globalConfig.dev) {
taskConfig.watch.push('*.js');
taskConfig.watch.push('gulp/**/*.js');
}

return gulp.src(taskConfig.watch)
.pipe(eslint(eslintOptions))
Expand All @@ -44,7 +42,7 @@ module.exports = (gulp, globalConfig) => {
.pipe(source('main.js'))
.pipe(buffer())
.pipe(gulpif(globalConfig.dev, sourcemaps.init({
loadMaps: true // loads map from browserify file
loadMaps: true // Loads map from browserify file
})))
.pipe(uglify(gulpif(globalConfig.dev, {
mangle: false,
Expand Down
22 changes: 14 additions & 8 deletions gulp/tasks/sprites.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
/**
* Create sprites of images.
*
* Install:
* yarn add -D gulp.spritesmith gulp-imagemin vinyl-buffer glob path fs
*/

const spritesmith = require('gulp.spritesmith');
const buffer = require('vinyl-buffer');
const imagemin = require('gulp-imagemin');
const errorHandler = require('../libs/error-handler');
const path = require('path');
const glob = require('glob');
const fs = require('fs');
const errorHandler = require('../libs/error-handler');

module.exports = (gulp, globalConfig) => {

const taskConfig = {
watch: [`${globalConfig.srcDir}/images/sprites/*/*.png`]
};

gulp.task('sprites', (done) => {
glob(`${globalConfig.srcDir}/images/sprites/*`, {}, (err, nodesList) => {
if (err) {
errorHandler(err.stack);
return;
}

const spritesDirs = [];

for (let i = 0, len = nodesList.length; i < len; i++) {
for (let i = 0, len = nodesList.length; i < len; i += 1) {
const nodePath = nodesList[i];
const isDir = fs.statSync(nodePath).isDirectory();

Expand All @@ -38,6 +38,12 @@ module.exports = (gulp, globalConfig) => {
const numSprites = spritesDirs.length;
let workDone = 0;

/**
* Helps to identify when the task is done by counting if
* all the sprites are done.
*
* @return {null}
*/
const checkFinish = () => {
workDone += 0.5;

Expand All @@ -46,7 +52,7 @@ module.exports = (gulp, globalConfig) => {
}
};

for (let i = 0; i < numSprites; i++) {
for (let i = 0; i < numSprites; i += 49) {
const dir = spritesDirs[i];
const name = path.basename(dir);

Expand All @@ -55,7 +61,7 @@ module.exports = (gulp, globalConfig) => {
imgName: `${name}.png`,
cssName: `${name}.scss`,
cssSpritesheetName: name,
cssVarMap: function (sprite) {
cssVarMap: (sprite) => {
sprite.name = `${name}-image-${sprite.name}`;
},
cssOpts: {
Expand Down
5 changes: 0 additions & 5 deletions gulp/tasks/styles.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/**
* Parse and minify JavaScript
*
* Install:
* yarn add -D gulp-sass-lint gulp-sass gulp-if gulp-sourcemaps gulp-postcss cssnano autoprefixer
*/

const sassLint = require('gulp-sass-lint');
Expand All @@ -15,7 +12,6 @@ const autoprefixer = require('autoprefixer');
const errorHandler = require('../libs/error-handler');

module.exports = (gulp, globalConfig) => {

const taskConfig = {
watch: [`${globalConfig.srcDir}/css/**/*`]
};
Expand Down Expand Up @@ -51,7 +47,6 @@ module.exports = (gulp, globalConfig) => {
.pipe(postcss(postcssPlugins))
.pipe(gulpif(globalConfig.dev, sourcemaps.write('./')))
.pipe(gulp.dest(`${globalConfig.destDir}/css/`));

});

return taskConfig;
Expand Down
8 changes: 1 addition & 7 deletions gulp/tasks/views.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
/**
* Compress images.
*
* Install:
* yarn add -D gulp-pug
*/

const pug = require('gulp-pug');
const errorHandler = require('../libs/error-handler');
const htmlmin = require('gulp-htmlmin');
const errorHandler = require('../libs/error-handler');

module.exports = (gulp, globalConfig) => {

const taskConfig = {
watch: [
`${globalConfig.srcDir}/views/**/*`
Expand All @@ -30,5 +26,3 @@ module.exports = (gulp, globalConfig) => {

return taskConfig;
};


18 changes: 6 additions & 12 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
/**
* Install
* yarn add -D gulp gulp-util run-sequence del browser-sync
*/

const gulp = require('gulp');
const gutil = require('./gulp/libs/utils');
const runSequence = require('run-sequence');
const del = require('del');
const browserSync = require('browser-sync').create();
const gutil = require('./gulp/libs/utils');

const config = {
dev: gutil.env.dev === true,
Expand Down Expand Up @@ -39,10 +34,9 @@ gulp.task('clean', () => {

/* istanbul ignore next */
gulp.task('build', ['clean'], (done) => {

tasksSequence.push(done);

runSequence.apply(null, tasksSequence);
runSequence(...tasksSequence);
});

/* istanbul ignore next */
Expand All @@ -58,7 +52,7 @@ gulp.task('serve', ['build'], () => {
notify: false
});

for (let i = 0, len = tasksConfigList.length; i < len; i++) {
for (let i = 0, len = tasksConfigList.length; i < len; i += 1) {
const task = tasksConfigList[i];

gulp.watch(task.watch, [task.name, browserSync.reload]);
Expand All @@ -75,7 +69,7 @@ gulp.task('default', () => {
*/
const tasksConfigList = [];

for (let i = 0, len = tasksSequence.length; i < len; i++) {
for (let i = 0, len = tasksSequence.length; i < len; i += 1) {
const taskName = tasksSequence[i];
const taskConfig = require(`./gulp/tasks/${taskName}`)(gulp, config);

Expand All @@ -85,6 +79,6 @@ for (let i = 0, len = tasksSequence.length; i < len; i++) {
}

module.exports = {
gulp: gulp,
config: config
gulp,
config
};
Loading

0 comments on commit adebbbf

Please sign in to comment.