Skip to content
4 changes: 2 additions & 2 deletions gulp/hygiene.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ module.exports = (blueprint, gulp, plugins) => {
return del(cleanDirs, { force: true });
});

gulp.task("tslint", () => (
gulp.src(["*.js", "gulp/**/*.js", "packages/*/*.js"])
gulp.task("tslint-gulp", () => (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the motivation behind this -gulp-suffixed tslint task as distinct from the non-suffixed tslint task? Looks like we're tslint-ing all JS files...and then also JS files within gulp/? Is that necessary on non-typescript files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok so: the previous iteration of this task ran tslint on all .js files (hence the package/**/*.js glob).

this new iteration runs tslint on the gulp code only because JS files in packages are now linted by tslint-<package>.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha 👍

gulp.src(["*.js", "gulp/**/*.js"])
.pipe(plugins.tslint({ formatter: "verbose" }))
.pipe(plugins.tslint.report())
.pipe(plugins.count("## javascript files linted"))
Expand Down
40 changes: 25 additions & 15 deletions gulp/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,31 @@ module.exports = (blueprint, gulp, plugins) => {
],
};

blueprint.task("sass", "lint", [], (project, isDevMode) => (
gulp.src(config.srcGlob(project))
.pipe(plugins.stylelint({
failAfterError: !isDevMode,
reporters: [
{ formatter: "string", console: true },
],
syntax: "scss",
}))
.pipe(plugins.count(`${project.id}: ## stylesheets linted`))
));
blueprint.taskGroup({
block: "sass",
name: "stylelint",
}, (project, taskName) => {
gulp.task(taskName, () => (
gulp.src(config.srcGlob(project))
.pipe(plugins.stylelint({
failAfterError: true,
reporters: [
{ formatter: "string", console: true },
],
syntax: "scss",
}))
.pipe(plugins.count(`${project.id}: ## stylesheets linted`))
));
});

blueprint.taskGroup({
block: "sass",
}, (project, taskName, depTaskNames) => {
gulp.task(taskName, ["icons", "sass-variables", ...depTaskNames], () => sassCompile(project, false));
gulp.task(`${taskName}:only`, () => sassCompile(project, true));
});

blueprint.task("sass", "compile", ["icons", "sass-variables"], (project, isDevMode) => {
function sassCompile(project, isDevMode) {
const sassCompiler = plugins.sass({
importer: packageImporter({ cwd: project.cwd }),
});
Expand Down Expand Up @@ -87,7 +99,7 @@ module.exports = (blueprint, gulp, plugins) => {
.pipe(gulp.dest(blueprint.destPath(project)))
// only bundled packages will reload the dev site
.pipe(project.sass === "bundle" ? plugins.connect.reload() : plugins.util.noop());
});
}

// concatenate all sass variables files together into one single exported list of variables
gulp.task("sass-variables", ["icons"], () => {
Expand Down Expand Up @@ -115,6 +127,4 @@ module.exports = (blueprint, gulp, plugins) => {
.pipe(plugins.insert.append(".unit-test { width: @pt-grid-size * 2; }"))
.pipe(plugins.less());
});

gulp.task("sass", ["sass-lint", "sass-compile"]);
};
33 changes: 21 additions & 12 deletions gulp/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,28 @@ module.exports = (blueprint, gulp, plugins) => {
project.typescriptProject = createTypescriptProject(tsconfig);
});

const lintTask = (project, isDevMode) => (
gulp.src(path.join(project.cwd, "!(dist|node_modules|typings)", "**", "*.ts{,x}"))
.pipe(plugins.tslint({ formatter: "verbose" }))
.pipe(plugins.tslint.report({ emitError: !isDevMode }))
.pipe(plugins.count(`${project.id}: ## typescript files linted`))
);
// Lint all source files using TSLint
blueprint.task("typescript", "lint", [], lintTask);
gulp.task("typescript-lint-docs", () => lintTask(blueprint.findProject("docs"), false));
gulp.task("typescript-lint-w-docs", () => lintTask(blueprint.findProject("docs"), true));
blueprint.taskGroup({
block: "all",
name: "tslint",
}, (project, taskName) => {
gulp.task(taskName, () => (
gulp.src(path.join(project.cwd, "!(dist|node_modules|typings)", "**", "*.{js,jsx,ts,tsx}"))
.pipe(plugins.tslint({ formatter: "verbose" }))
.pipe(plugins.tslint.report({ emitError: true }))
.pipe(plugins.count(`${project.id}: ## files tslinted`))
));
});

blueprint.taskGroup({
block: "typescript",
name: "tsc",
}, (project, taskName, depTaskNames) => {
gulp.task(taskName, ["icons", ...depTaskNames], () => typescriptCompile(project, false));
gulp.task(`${taskName}:only`, () => typescriptCompile(project, true));
});

// Compile a TypeScript project using gulp-typescript to individual .js files
blueprint.task("typescript", "compile", ["icons"], (project, isDevMode) => {
function typescriptCompile(project, isDevMode) {
const tsProject = project.typescriptProject;

const tsResult = tsProject.src()
Expand All @@ -52,5 +61,5 @@ module.exports = (blueprint, gulp, plugins) => {
tsResult.js.pipe(plugins.sourcemaps.write(".", { sourceRoot: null })),
tsResult.dts,
]).pipe(gulp.dest(blueprint.destPath(project)));
});
}
};
5 changes: 2 additions & 3 deletions gulp/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ module.exports = (blueprint, gulp) => {
const webpackConfig = require("./util/webpack-config");

const docsProject = blueprint.findProject("docs");

const configuration = webpackConfig.generateWebpackTypescriptConfig(docsProject);

gulp.task("webpack-compile-docs", ["docs"], (callback) => {
gulp.task("webpack-docs", ["docs"], (callback) => {
webpack(configuration, webpackConfig.webpackDone(callback));
});

gulp.task("webpack-compile-w-docs", (callback) => { // eslint-disable-line no-unused-vars
gulp.task("webpack-docs-watch", (callback) => {
// rely on editor for compiler errors during development--this results in _massive_ speed increase
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need the eslint-disable line anymore? Looks like we're still not using the callback argument anywhere. Did we need that comment in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are not using eslint anymore! it's all TSLint

configuration.ts.transpileOnly = true;
// never invoke callback so it runs forever!
Expand Down