Skip to content

Commit

Permalink
Interim check-in for eslint migration
Browse files Browse the repository at this point in the history
Will fix #1913
  • Loading branch information
roblarsen committed Mar 31, 2018
1 parent 44f71e7 commit d76cec6
Show file tree
Hide file tree
Showing 8 changed files with 7,351 additions and 282 deletions.
26 changes: 26 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"mocha": true
},
"plugins": ["mocha"],
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": [
"error",
2
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
};
32 changes: 0 additions & 32 deletions .jshintrc

This file was deleted.

193 changes: 96 additions & 97 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,149 +28,148 @@ 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);

zip.on('error', (error) => {
done();
throw error;
});
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);

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

files.forEach( (file) => {
output.on('close', done);

const filePath = path.resolve(dirs.dist, file);
files.forEach((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
});
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.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))
gulp.src('node_modules/apache-server-configs/dist/.htaccess')
.pipe(plugins().replace(/# ErrorDocument/g, 'ErrorDocument'))
.pipe(gulp.dest(dirs.dist))
);

gulp.task('copy:index.html', () => {
const hash = ssri.fromData(
fs.readFileSync('node_modules/jquery/dist/jquery.min.js'),
{ algorithms: ['sha256'] }
);
let version = pkg.devDependencies.jquery;
let modernizrVersion = pkg.devDependencies.modernizr;

gulp.src(`${dirs.src}/index.html`)
.pipe(plugins().replace(/{{JQUERY_VERSION}}/g, version))
.pipe(plugins().replace(/{{MODERNIZR_VERSION}}/g, modernizrVersion))
.pipe(plugins().replace(/{{JQUERY_SRI_HASH}}/g, hash.toString()))
.pipe(gulp.dest(dirs.dist));
const hash = ssri.fromData(
fs.readFileSync('node_modules/jquery/dist/jquery.min.js'),
{algorithms: ['sha256']}
);
let version = pkg.devDependencies.jquery;
let modernizrVersion = pkg.devDependencies.modernizr;

gulp.src(`${dirs.src}/index.html`)
.pipe(plugins().replace(/{{JQUERY_VERSION}}/g, version))
.pipe(plugins().replace(/{{MODERNIZR_VERSION}}/g, modernizrVersion))
.pipe(plugins().replace(/{{JQUERY_SRI_HASH}}/g, hash.toString()))
.pipe(gulp.dest(dirs.dist));
});

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`))
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`))
);

gulp.task('copy:license', () =>
gulp.src('LICENSE.txt')
.pipe(gulp.dest(dirs.dist))
gulp.src('LICENSE.txt')
.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`)
.pipe(plugins().header(banner))
.pipe(plugins().autoprefixer({
browsers: ['last 2 versions', 'ie >= 9', '> 1%'],
cascade: false
}))
.pipe(gulp.dest(`${dirs.dist}/css`));
gulp.src(`${dirs.src}/css/main.css`)
.pipe(plugins().header(banner))
.pipe(plugins().autoprefixer({
browsers: ['last 2 versions', 'ie >= 9', '> 1%'],
cascade: false
}))
.pipe(gulp.dest(`${dirs.dist}/css`));
});

gulp.task('copy:misc', () =>
gulp.src([
gulp.src([

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

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

], {
], {

// Include hidden files by default
dot: true
// Include hidden files by default
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.src('node_modules/normalize.css/normalize.css')
.pipe(gulp.dest(`${dirs.dist}/css`))
);

gulp.task( 'modernizr', (done) =>{
gulp.task('modernizr', (done) =>{

modernizr.build(modernizrConfig, (code) => {
fs.writeFile(`${dirs.dist}/js/vendor/modernizr-${pkg.devDependencies.modernizr}.min.js`, code, done);
});
modernizr.build(modernizrConfig, (code) => {
fs.writeFile(`${dirs.dist}/js/vendor/modernizr-${pkg.devDependencies.modernizr}.min.js`, code, done);
});

});

gulp.task('lint:js', () =>
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'))
gulp.src([
'gulpfile.js',
`${dirs.src}/js/*.js`,
`${dirs.test}/*.js`
]).pipe(plugins().jscs())
.pipe(plugins().eslint())
.pipe(plugins().eslint.failOnError())
);


Expand All @@ -179,17 +178,17 @@ gulp.task('lint:js', () =>
// ---------------------------------------------------------------------

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

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

Expand Down
Loading

0 comments on commit d76cec6

Please sign in to comment.