Skip to content

Commit

Permalink
Fix gulp + eslintrc ( inc. PR sparksuite#741 )
Browse files Browse the repository at this point in the history
This commit includes the fixes introduced in Pull Request sparksuite#741 ( sparksuite#741 )
that were added by @roipoussiere

It also includes these extra improvements:

 - Added lines for `no-redeclare` and `no-prototype-builtins` to `.estlintrc` which are set to disable warnings and errors for
   (re-)declaring global variables/functions like `require`, and disabling errors/warnings for prototyping built-ins
   e.g. extending `Object` - This was required for `gulp browserify` to build the scripts without errors

 - Added `yarn.lock` to lock package versions for those of you who use `yarn` instead of `npm` :)
  • Loading branch information
Someguy123 committed Oct 20, 2020
1 parent 6abda7a commit 1dca74b
Show file tree
Hide file tree
Showing 3 changed files with 4,465 additions and 15 deletions.
7 changes: 5 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
"semi": [
2,
"always"
]
],
"no-redeclare": [2, {"builtinGlobals": false}],
"no-prototype-builtins": 0,
"no-useless-escape": "off"
},
"env": {
"browser": true,
"node":true
},
"extends": "eslint:recommended"
}
}
27 changes: 14 additions & 13 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,49 @@ var banner = ["/**",
" */",
""].join("\n");

gulp.task("prettify-js", [], function() {
gulp.task("prettify-js", function(done) {
return gulp.src("./src/js/simplemde.js")
.pipe(prettify({js: {brace_style: "collapse", indent_char: "\t", indent_size: 1, max_preserve_newlines: 3, space_before_conditional: false}}))
.pipe(gulp.dest("./src/js"));
});

gulp.task("prettify-css", [], function() {
gulp.task("prettify-css", function() {
return gulp.src("./src/css/simplemde.css")
.pipe(prettify({css: {indentChar: "\t", indentSize: 1}}))
.pipe(gulp.dest("./src/css"));
});

gulp.task("lint", ["prettify-js"], function() {
gulp.task("lint", gulp.series("prettify-js", function(done) {
gulp.src("./src/js/**/*.js")
.pipe(debug())
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
done();
}));

function taskBrowserify(opts) {
return browserify("./src/js/simplemde.js", opts)
.bundle();
}

gulp.task("browserify:debug", ["lint"], function() {
gulp.task("browserify:debug", gulp.series("lint", function() {
return taskBrowserify({debug:true, standalone:"SimpleMDE"})
.pipe(source("simplemde.debug.js"))
.pipe(buffer())
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest("./debug/"));
});
}));

gulp.task("browserify", ["lint"], function() {
gulp.task("browserify", gulp.series("lint", function() {
return taskBrowserify({standalone:"SimpleMDE"})
.pipe(source("simplemde.js"))
.pipe(buffer())
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest("./debug/"));
});
}));

gulp.task("scripts", ["browserify:debug", "browserify", "lint"], function() {
gulp.task("scripts", gulp.series("browserify:debug", "browserify", "lint", function() {
var js_files = ["./debug/simplemde.js"];

return gulp.src(js_files)
Expand All @@ -72,9 +73,9 @@ gulp.task("scripts", ["browserify:debug", "browserify", "lint"], function() {
.pipe(buffer())
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest("./dist/"));
});
}));

gulp.task("styles", ["prettify-css"], function() {
gulp.task("styles", gulp.series("prettify-css", function() {
var css_files = [
"./node_modules/codemirror/lib/codemirror.css",
"./src/css/*.css",
Expand All @@ -91,6 +92,6 @@ gulp.task("styles", ["prettify-css"], function() {
.pipe(buffer())
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest("./dist/"));
});
}));

gulp.task("default", ["scripts", "styles"]);
gulp.task("default", gulp.series("scripts", "styles"));
Loading

0 comments on commit 1dca74b

Please sign in to comment.