Skip to content

build: properly lint tooling source code #6055

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

Merged
merged 2 commits into from
Jul 27, 2017
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
4 changes: 2 additions & 2 deletions tools/gulp/tasks/validate-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ task('validate-release:check-bundles', () => {
function checkReleasePackage(packageName: string): string[] {
const bundlePath = join(releasesDir, packageName, '@angular', `${packageName}.js`);
const bundleContent = readFileSync(bundlePath, 'utf8');
let failures = [];
let failures: string[] = [];

if (inlineStylesSourcemapRegex.exec(bundleContent) !== null) {
failures.push('Bundles contain sourcemap references in component styles.');
Expand All @@ -61,7 +61,7 @@ function checkMaterialPackage(): string[] {
const packagePath = join(releasesDir, 'material');
const prebuiltThemesPath = join(packagePath, 'prebuilt-themes');
const themingFilePath = join(packagePath, '_theming.scss');
const failures = [];
const failures: string[] = [];

if (glob('*.css', {cwd: prebuiltThemesPath}).length === 0) {
failures.push('Prebuilt themes are not present in the Material release output.');
Expand Down
1 change: 0 additions & 1 deletion tools/package-tools/build-bundles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {join} from 'path';
import {readdirSync, lstatSync} from 'fs';
import {ScriptTarget, ModuleKind, NewLineKind} from 'typescript';
import {uglifyJsFile} from './minify-sources';
import {createRollupBundle} from './rollup-helpers';
Expand Down
3 changes: 2 additions & 1 deletion tools/package-tools/build-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export function composeRelease(packageName: string, options: ComposeReleaseOptio
}

/** Creates files necessary for a secondary entry-point. */
function createFilesForSecondaryEntryPoint(packageName: string, packagePath: string, releasePath: string) {
function createFilesForSecondaryEntryPoint(packageName: string, packagePath: string,
releasePath: string) {
getSecondaryEntryPointsForPackage(packageName).forEach(entryPointName => {
// Create a directory in the root of the package for this entry point that contains
// * A package.json that lists the different bundle locations
Expand Down
5 changes: 3 additions & 2 deletions tools/package-tools/entry-point-package-json.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {join} from 'path';
import {lstatSync, readdirSync, writeFileSync} from 'fs';
import {writeFileSync} from 'fs';

/** Creates a package.json for a secondary entry-point with the different bundle locations. */
export function createEntryPointPackageJson(destDir: string, packageName: string, entryPointName: string) {
export function createEntryPointPackageJson(destDir: string, packageName: string,
entryPointName: string) {
const content = {
name: `@angular/${packageName}/${entryPointName}`,
typings: `../${entryPointName}.d.ts`,
Expand Down
6 changes: 4 additions & 2 deletions tools/package-tools/gulp/build-tasks-gulp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {dest, src, task} from 'gulp';
import {join} from 'path';
import {readFileSync, unlink, writeFileSync} from 'fs';
import {main as tsc} from '@angular/tsc-wrapped';
import {buildConfig} from '../build-config';
import {composeRelease} from '../build-release';
Expand All @@ -27,8 +26,11 @@ const htmlMinifierOptions = {
* Creates a set of gulp tasks that can build the specified package.
* @param packageName Name of the package. Needs to be similar to the directory name in `src/`.
* @param dependencies Required packages that will be built before building the current package.
* @param options Options that can be passed to adjust the gulp package tasks.
*/
export function createPackageBuildTasks(packageName: string, dependencies: string[] = [], options: PackageTaskOptions = {}) {
export function createPackageBuildTasks(packageName: string, dependencies: string[] = [],
options: PackageTaskOptions = {}) {

// To avoid refactoring of the project the package material will map to the source path `lib/`.
const packageRoot = join(packagesDir, packageName === 'material' ? 'lib' : packageName);
const packageOut = join(outputDir, 'packages', packageName);
Expand Down
5 changes: 0 additions & 5 deletions tools/package-tools/secondary-entry-points.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import {join} from 'path';
import {readdirSync, lstatSync} from 'fs';
import {buildConfig} from './build-config';


/**
* List of cdk entry-points in the order that they must be built. This is necessary because
* some of the entry-points depend on each other. This is temporary until we switch to bazel.
Expand Down
8 changes: 5 additions & 3 deletions tools/screenshot-test/functions/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ const authDomain = firebaseFunctions.config().firebase.authDomain;
const toolName = firebaseFunctions.config().tool.name;

export function updateGithubStatus(event: firebaseFunctions.Event<any>) {
if (!event.data.exists() || typeof event.data.val() != 'boolean') {
if (!event.data.exists() || typeof event.data.val() != 'boolean' && event.params) {
return;
}
let result = event.data.val() == true;
let {prNumber, sha} = event.params;

const result = event.data.val() == true;
const {prNumber, sha} = event.params!;

return setGithubStatus(sha, {
result: result,
name: toolName,
Expand Down
5 changes: 3 additions & 2 deletions tools/screenshot-test/functions/jwt-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ const secret = firebaseFunctions.config().secret.key;
* Replace '/' with '.' to get the token.
*/
function getSecureToken(event: firebaseFunctions.Event<any>) {
let {jwtHeader, jwtPayload, jwtSignature} = event.params;
const {jwtHeader, jwtPayload, jwtSignature} = event.params!;
return `${jwtHeader}.${jwtPayload}.${jwtSignature}`;
}


/**
* Verify that the event has a valid JsonWebToken. If the token is *not* valid,
* the data tied to the event will be deleted and the function will return a rejected promise.
*/
export function verifySecureToken(event: firebaseFunctions.Event<any>) {
return new Promise((resolve, reject) => {
const prNumber = event.params['prNumber'];
const prNumber = event.params!['prNumber'];
const secureToken = getSecureToken(event);

return verifyJWT(secureToken, prNumber, secret, repoSlug).then(() => {
Expand Down
13 changes: 7 additions & 6 deletions tools/screenshot-test/functions/test-goldens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ const bucket = gcs.bucket(firebaseFunctions.config().firebase.storageBucket);
export function copyTestImagesToGoldens(prNumber: string) {
return firebaseAdmin.database().ref(`screenshot/reports/${prNumber}/results`).once('value')
.then((snapshot: firebaseAdmin.database.DataSnapshot) => {
let failedFilenames: string[] = [];
const failedFilenames: string[] = [];
let counter = 0;
snapshot.forEach((childSnapshot: firebaseAdmin.database.DataSnapshot) => {
if (childSnapshot.val() === false) {

snapshot.forEach(childSnapshot => {
if (childSnapshot.key && childSnapshot.val() === false) {
failedFilenames.push(childSnapshot.key);
}

counter++;
if (counter == snapshot.numChildren()) {
return true;
}
return counter === snapshot.numChildren();
});

return failedFilenames;
}).then((failedFilenames: string[]) => {
return bucket.getFiles({prefix: `screenshots/${prNumber}/test`}).then((data: any) => {
Expand Down
13 changes: 6 additions & 7 deletions tools/screenshot-test/src/app/firebase.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ export class FirebaseService {
this._readResults(childSnapshot);
break;
}

counter++;
if (counter === snapshot.numChildren()) {
return true;
}
return counter === snapshot.numChildren();
});
});
}
Expand Down Expand Up @@ -123,11 +122,11 @@ export class FirebaseService {
this.screenshotResultSummary.testNames = [];
this.screenshotResultSummary.testResultsByName.clear();
childSnapshot.forEach((resultSnapshot: firebase.database.DataSnapshot) => {
this._addTestResults(resultSnapshot.key, resultSnapshot.val());
childCounter++;
if (childCounter === childSnapshot.numChildren()) {
return true;
if (resultSnapshot.key) {
this._addTestResults(resultSnapshot.key, resultSnapshot.val());
}
childCounter++;
return childCounter === childSnapshot.numChildren();
});
}

Expand Down
11 changes: 7 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
"baseUrl": ".",
"paths": {
"@angular/material": ["./src/lib/public_api.ts"],
"@angular/cdk*": ["./src/cdk/*"],
"@angular/material-examples": ["./src/material-examples"]
"@angular/cdk/*": ["./src/cdk/*"],
"@angular/material-examples": ["./src/material-examples"],
"material2-build-tools": ["./tools/package-tools"]
}
},
"include": [
"src/**/*.ts",
"tools/**.ts"
"tools/**/*.ts"
],
"exclude": [
// Exclude files that depend on Node APIs because those depend on the Node types and therefore
Expand All @@ -31,6 +32,8 @@

// IDEs should not type-check the different node_modules directories of the different packages.
// This would cause the IDEs to be slower and also linters would check the node_modules.
"**/node_modules"
"node_modules/",
"tools/dashboard/node_modules/",
"tools/screenshot-test/node_modules/"
]
}