diff --git a/dev-infra/BUILD.bazel b/dev-infra/BUILD.bazel index db10ba96d31e5b..6dcb99ee115e87 100644 --- a/dev-infra/BUILD.bazel +++ b/dev-infra/BUILD.bazel @@ -78,6 +78,7 @@ pkg_npm( "//dev-infra/benchmark/driver-utilities", "//dev-infra/commit-message", "//dev-infra/ts-circular-dependencies", + "//dev-infra/tslint-rules", ], ) diff --git a/package.json b/package.json index 3396ed121555d5..bea065d7233f0a 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "test-fixme-ivy-aot": "bazelisk test --config=ivy --build_tag_filters=-no-ivy-aot --test_tag_filters=-no-ivy-aot", "list-fixme-ivy-targets": "bazelisk query --output=label 'attr(\"tags\", \"\\[.*fixme-ivy.*\\]\", //...) except kind(\"sh_binary\", //...) except kind(\"devmode_js_sources\", //...)' | sort", "lint": "yarn -s tslint && yarn -s ng-dev format changed --check", - "tslint": "tsc -p tools/tsconfig.json && tslint -c tslint.json \"+(dev-infra|packages|modules|scripts|tools)/**/*.+(js|ts)\"", + "tslint": "tslint -c tslint.json --project tsconfig-tslint.json", "public-api:check": "node goldens/public-api/manage.js test", "public-api:update": "node goldens/public-api/manage.js accept", "symbol-extractor:check": "node tools/symbol-extractor/run_all_symbols_extractor_tests.js test", diff --git a/tools/contributing-stats/get-data.ts b/tools/contributing-stats/get-data.ts index 69d81c275e6731..7148d2796fe0e5 100644 --- a/tools/contributing-stats/get-data.ts +++ b/tools/contributing-stats/get-data.ts @@ -237,7 +237,8 @@ async function run(date: string) { console.info(['Username', ...buildQueryAndParams('', date).labels].join(',')); for (const username of allOrgMembers) { - const results = await graphql(buildQueryAndParams(username, date).query.toString()); + const results: [{issueCount: number}] = + await graphql(buildQueryAndParams(username, date).query.toString()); const values = Object.values(results).map(result => `${result.issueCount}`); console.info([username, ...values].join(',')); } diff --git a/tools/size-tracking/size_tracker.ts b/tools/size-tracking/size_tracker.ts index fc2e2c25356bff..d5e44acad1e019 100644 --- a/tools/size-tracking/size_tracker.ts +++ b/tools/size-tracking/size_tracker.ts @@ -94,7 +94,7 @@ export class SizeTracker { filePath = filePath.replace(/\\/g, '/'); // Workaround for https://github.com/angular/angular/issues/30060 - if (process.env['BAZEL_TARGET'].includes('test/bundling/core_all:size_test')) { + if (process.env['BAZEL_TARGET']!.includes('test/bundling/core_all:size_test')) { return filePath.replace(/^(\.\.\/)+external/, 'external') .replace(/^(\.\.\/)+packages\/core\//, '@angular/core/') .replace(/^(\.\.\/){3}/, '@angular/core/'); diff --git a/tools/tsconfig.json b/tools/tsconfig.json index 086b31659960e8..fd556c35e4e4f2 100644 --- a/tools/tsconfig.json +++ b/tools/tsconfig.json @@ -6,6 +6,7 @@ "experimentalDecorators": true, "module": "commonjs", "moduleResolution": "node", + "strict": true, "outDir": "../dist/tools/", "noImplicitAny": true, "noFallthroughCasesInSwitch": true, diff --git a/tools/tslint/requireInternalWithUnderscoreRule.ts b/tools/tslint/requireInternalWithUnderscoreRule.ts index 9f73e5f434bc39..33a1865024b4fb 100644 --- a/tools/tslint/requireInternalWithUnderscoreRule.ts +++ b/tools/tslint/requireInternalWithUnderscoreRule.ts @@ -47,6 +47,6 @@ class TypedefWalker extends RuleWalker { } this.addFailure(this.createFailure( node.getStart(), node.getWidth(), - `module-private member ${node.name.getText()} must be annotated @internal`)); + `module-private member ${node.name?.getText()} must be annotated @internal`)); } } diff --git a/tsconfig-tslint.json b/tsconfig-tslint.json new file mode 100644 index 00000000000000..e5a235c7c904f4 --- /dev/null +++ b/tsconfig-tslint.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "allowJs": true + }, + "include": [ + "dev-infra/**/*", + "packages/**/*", + "modules/**/*", + "tools/**/*", + "scripts/**/*" + ] +} diff --git a/tslint.json b/tslint.json index 9c0ccf7fc31a30..a08ecf0e5d58d2 100644 --- a/tslint.json +++ b/tslint.json @@ -1,11 +1,19 @@ { "rulesDirectory": [ - "dist/tools/tslint", + "tools/tslint", + "dev-infra/tslint-rules", "node_modules/vrsource-tslint-rules/rules", "node_modules/tslint-eslint-rules/dist/rules", "node_modules/tslint-no-toplevel-property-access/rules" ], "rules": { + // The first rule needs to be `ts-node-loader` which sets up `ts-node` within TSLint so + // that rules written in TypeScript can be loaded without needing to be transpiled. + "ts-node-loader": true, + // Custom rules written in TypeScript. + "require-internal-with-underscore": true, + "no-implicit-override-abstract": true, + "eofline": true, "file-header": [ true, @@ -26,7 +34,6 @@ true, "object" ], - "require-internal-with-underscore": true, "no-toplevel-property-access": [ true, "packages/animations/src/", @@ -57,6 +64,12 @@ ] }, "jsRules": { + // The first rule needs to be `ts-node-loader` which sets up `ts-node` within TSLint so + // that rules written in TypeScript can be loaded without needing to be transpiled. + "ts-node-loader": true, + // Custom rules written in TypeScript. + "require-internal-with-underscore": true, + "eofline": true, "file-header": [ true, @@ -71,7 +84,6 @@ ], "no-duplicate-imports": true, "no-duplicate-variable": true, - "require-internal-with-underscore": true, "semicolon": [ true ],