Skip to content

Commit 579f817

Browse files
committed
build: remove tsetse rule exclusions
To remove the tsetse rule exclusions, several usages of `JSON.parse` that did not have type casting where adjusted to add types. This removed the need for the manual configuration within the tsconfig.
1 parent 3e359da commit 579f817

File tree

5 files changed

+11
-16
lines changed

5 files changed

+11
-16
lines changed

packages/angular/cli/src/commands/config/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ function normalizeValue(value: string | undefined | boolean | number): JsonValue
185185
// and convert them into a numberic entities.
186186
// Example: 73b61974-182c-48e4-b4c6-30ddf08c5c98 -> 73.
187187
// These values should never contain comments, therefore using `JSON.parse` is safe.
188-
return JSON.parse(valueString);
188+
return JSON.parse(valueString) as JsonValue;
189189
} catch {
190190
return value;
191191
}

packages/angular/cli/src/commands/update/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
10451045
if (existsSync(packageJsonPath)) {
10461046
const content = await fs.readFile(packageJsonPath, 'utf-8');
10471047
if (content) {
1048-
const { bin = {} } = JSON.parse(content);
1048+
const { bin = {} } = JSON.parse(content) as { bin: Record<string, string> };
10491049
const binKeys = Object.keys(bin);
10501050

10511051
if (binKeys.length) {

packages/angular/cli/src/utilities/package-tree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface PackageTreeNode {
4444

4545
export async function readPackageJson(packageJsonPath: string): Promise<PackageJson | undefined> {
4646
try {
47-
return JSON.parse((await fs.promises.readFile(packageJsonPath)).toString());
47+
return JSON.parse((await fs.promises.readFile(packageJsonPath)).toString()) as PackageJson;
4848
} catch {
4949
return undefined;
5050
}

packages/angular/cli/src/utilities/project.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import * as os from 'os';
1212
import * as path from 'path';
1313
import { findUp } from './find-up';
1414

15+
interface PackageDependencies {
16+
dependencies?: Record<string, string>;
17+
devDependencies?: Record<string, string>;
18+
}
19+
1520
export function findWorkspaceFile(currentDirectory = process.cwd()): string | null {
1621
const possibleConfigFiles = ['angular.json', '.angular.json'];
1722
const configFilePath = findUp(possibleConfigFiles, currentDirectory);
@@ -27,7 +32,7 @@ export function findWorkspaceFile(currentDirectory = process.cwd()): string | nu
2732

2833
try {
2934
const packageJsonText = fs.readFileSync(packageJsonPath, 'utf-8');
30-
const packageJson = JSON.parse(packageJsonText);
35+
const packageJson = JSON.parse(packageJsonText) as PackageDependencies;
3136
if (!containsCliDep(packageJson)) {
3237
// No CLI dependency
3338
return null;
@@ -41,10 +46,7 @@ export function findWorkspaceFile(currentDirectory = process.cwd()): string | nu
4146
return configFilePath;
4247
}
4348

44-
function containsCliDep(obj?: {
45-
dependencies?: Record<string, string>;
46-
devDependencies?: Record<string, string>;
47-
}): boolean {
49+
function containsCliDep(obj?: PackageDependencies): boolean {
4850
const pkgName = '@angular/cli';
4951
if (!obj) {
5052
return false;

tsconfig.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,7 @@
3131
"@angular/build/private": ["./packages/angular/build/src/private"],
3232
"@ngtools/webpack": ["./packages/ngtools/webpack/src"],
3333
"@schematics/angular": ["./packages/schematics/angular"]
34-
},
35-
"plugins": [
36-
{
37-
"name": "@bazel/tsetse",
38-
// must-use-promises is handled by the eslint @typescript-eslint/no-floating-promises rule
39-
"disabledRules": ["must-type-assert-json-parse", "must-use-promises"]
40-
}
41-
]
34+
}
4235
},
4336
"bazelOptions": {
4437
"suppressTsconfigOverrideWarnings": true

0 commit comments

Comments
 (0)