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

Features/eslint #2037

Merged
merged 5 commits into from
Apr 6, 2018
Merged
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
Expand Down
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.

1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ git:
language: node_js

node_js:
- 4
- 6
- 8
- 9
Expand Down
2 changes: 1 addition & 1 deletion dist/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ root = true

[*]
charset = utf-8
indent_size = 4
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
Expand Down
32 changes: 16 additions & 16 deletions dist/js/plugins.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// Avoid `console` errors in browsers that lack a console.
(function() {
var method;
var noop = function () {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
];
var length = methods.length;
var console = (window.console = window.console || {});
var method;
var noop = function () {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
];
var length = methods.length;
var console = (window.console = window.console || {});

while (length--) {
method = methods[length];
while (length--) {
method = methods[length];

// Only stub undefined methods.
if (!console[method]) {
console[method] = noop;
}
// Only stub undefined methods.
if (!console[method]) {
console[method] = noop;
}
}
}());

// Place any jQuery/helper plugins in here.
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