Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated from jshint -> eslint #1930

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
/src/js/vendor
12 changes: 12 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "airbnb",
"env": {
"browser": true,
"mocha": true,
"es6": true
},
"rules": {
"no-plusplus": "off",
"no-cond-assign": "off"
}
}
68 changes: 0 additions & 68 deletions .jscsrc

This file was deleted.

32 changes: 0 additions & 32 deletions .jshintrc

This file was deleted.

135 changes: 59 additions & 76 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import runSequence from 'run-sequence';
import archiver from 'archiver';
import glob from 'glob';
import del from 'del';
import sri from 'node-sri'
import sri from 'node-sri';

import pkg from './package.json';

Expand All @@ -25,102 +25,97 @@ const dirs = pkg['h5bp-configs'].directories;
// ---------------------------------------------------------------------

gulp.task('archive:create_archive_dir', () => {
fs.mkdirSync(path.resolve(dirs.archive), '0755');
fs.mkdirSync(path.resolve(dirs.archive), '0755');
});

gulp.task('archive:zip', (done) => {
const archiveName = path.resolve(dirs.archive, `${pkg.name}_v${pkg.version}.zip`);
const zip = archiver('zip');
const files = glob.sync('**/*.*', {
cwd: dirs.dist,
dot: true, // include hidden files
});
const output = fs.createWriteStream(archiveName);

const archiveName = path.resolve(dirs.archive, `${pkg.name}_v${pkg.version}.zip`);
const zip = archiver('zip');
const files = glob.sync('**/*.*', {
'cwd': dirs.dist,
'dot': true // include hidden files
});
const output = fs.createWriteStream(archiveName);

zip.on('error', (error) => {
done();
throw error;
});
zip.on('error', (error) => {
done();
throw error;
});

output.on('close', done);
output.on('close', done);

files.forEach( (file) => {

const filePath = path.resolve(dirs.dist, file);
files.forEach((file) => {
const filePath = path.resolve(dirs.dist, file);

// `zip.bulk` does not maintain the file
// permissions, so we need to add files individually
zip.append(fs.createReadStream(filePath), {
'name': file,
'mode': fs.statSync(filePath).mode
});

zip.append(fs.createReadStream(filePath), {
name: file,
mode: fs.statSync(filePath).mode,
});
});

zip.pipe(output);
zip.finalize();

zip.pipe(output);
zip.finalize();
});

gulp.task('clean', (done) => {
del([
dirs.archive,
dirs.dist
]).then( () => {
done();
});
del([
dirs.archive,
dirs.dist,
]).then(() => {
done();
});
});

gulp.task('copy', [
'copy:.htaccess',
'copy:index.html',
'copy:jquery',
'copy:license',
'copy:main.css',
'copy:misc',
'copy:normalize'
'copy:.htaccess',
'copy:index.html',
'copy:jquery',
'copy:license',
'copy:main.css',
'copy:misc',
'copy:normalize',
]);

gulp.task('copy:.htaccess', () =>
gulp.src('node_modules/apache-server-configs/dist/.htaccess')
.pipe(plugins().replace(/# ErrorDocument/g, 'ErrorDocument'))
.pipe(gulp.dest(dirs.dist))
.pipe(gulp.dest(dirs.dist)),
);

gulp.task('copy:index.html', (done) =>
gulp.task('copy:index.html', done =>
sri.hash('node_modules/jquery/dist/jquery.min.js', (err, hash) => {
if (err) throw err
if (err) throw err;

let version = pkg.devDependencies.jquery;
gulp.src(`${dirs.src}/index.html`)
const version = pkg.devDependencies.jquery;
gulp.src(`${dirs.src}/index.html`)
.pipe(plugins().replace(/{{JQUERY_VERSION}}/g, version))
.pipe(plugins().replace(/{{JQUERY_SRI_HASH}}/g, hash))
.pipe(gulp.dest(dirs.dist));
done();
})
done();
}),
);

gulp.task('copy:jquery', () =>
gulp.src(['node_modules/jquery/dist/jquery.min.js'])
.pipe(plugins().rename(`jquery-${pkg.devDependencies.jquery}.min.js`))
.pipe(gulp.dest(`${dirs.dist}/js/vendor`))
.pipe(gulp.dest(`${dirs.dist}/js/vendor`)),
);

gulp.task('copy:license', () =>
gulp.src('LICENSE.txt')
.pipe(gulp.dest(dirs.dist))
.pipe(gulp.dest(dirs.dist)),
);

gulp.task('copy:main.css', () => {
const banner = `/*! HTML5 Boilerplate v${pkg.version} | ${pkg.license} License | ${pkg.homepage} */\n\n`;

const banner = `/*! HTML5 Boilerplate v${pkg.version} | ${pkg.license} License | ${pkg.homepage} */\n\n`;

gulp.src(`${dirs.src}/css/main.css`)
gulp.src(`${dirs.src}/css/main.css`)
.pipe(plugins().header(banner))
.pipe(plugins().autoprefixer({
browsers: ['last 2 versions', 'ie >= 8', '> 1%'],
cascade: false
browsers: ['last 2 versions', 'ie >= 8', '> 1%'],
cascade: false,
}))
.pipe(gulp.dest(`${dirs.dist}/css`));
});
Expand All @@ -129,55 +124,43 @@ gulp.task('copy:misc', () =>
gulp.src([

// Copy all files
`${dirs.src}/**/*`,
`${dirs.src}/**/*`,

// Exclude the following files
// (other tasks will handle the copying of these files)
`!${dirs.src}/css/main.css`,
`!${dirs.src}/index.html`
`!${dirs.src}/css/main.css`,
`!${dirs.src}/index.html`,

], {

// Include hidden files by default
dot: true
dot: true,

}).pipe(gulp.dest(dirs.dist))
}).pipe(gulp.dest(dirs.dist)),
);

gulp.task('copy:normalize', () =>
gulp.src('node_modules/normalize.css/normalize.css')
.pipe(gulp.dest(`${dirs.dist}/css`))
);

gulp.task('lint:js', () =>

This comment was marked as abuse.

gulp.src([
'gulpfile.js',
`${dirs.src}/js/*.js`,
`${dirs.test}/*.js`
]).pipe(plugins().jscs())
.pipe(plugins().jshint())
.pipe(plugins().jshint.reporter('jshint-stylish'))
.pipe(plugins().jshint.reporter('fail'))
.pipe(gulp.dest(`${dirs.dist}/css`)),
);


// ---------------------------------------------------------------------
// | Main tasks |
// ---------------------------------------------------------------------

gulp.task('archive', (done) => {
runSequence(
runSequence(
'build',
'archive:create_archive_dir',
'archive:zip',
done)
done);
});

gulp.task('build', (done) => {
runSequence(
['clean', 'lint:js'],

This comment was marked as abuse.

runSequence(
['clean'],
'copy',
done)
done);
});

gulp.task('default', ['build']);
16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
"babel-preset-es2015": "^6.18.0",
"babel-register": "^6.8.0",
"del": "^2.2.2",
"eslint": "^3.18.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.3",
"glob": "^7.1.1",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^3.1.1",
"gulp-header": "^1.8.8",
"gulp-jscs": "^4.0.0",
"gulp-jshint": "^2.0.4",
"gulp-load-plugins": "^1.4.0",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"jquery": "3.2.0",
"jshint": "^2.9.4",
"jshint-stylish": "^2.2.1",
"mocha": "^3.2.0",
"node-sri": "^1.1.1",
"normalize.css": "5.0.0",
Expand All @@ -33,11 +33,6 @@
"engines": {
"node": ">=0.10.0"
},
"babel": {
"presets": [
"es2015"
]
},
"h5bp-configs": {
"directories": {
"archive": "archive",
Expand All @@ -52,6 +47,7 @@
"private": true,
"scripts": {
"build": "gulp build",
"lint": "eslint .",
"test": "gulp archive && mocha --compilers js:babel-register --reporter spec --timeout 5000"
},
"version": "5.3.0"
Expand Down
Loading