Skip to content

Commit fa9bce0

Browse files
committed
test: enable @typescript-eslint/no-unnecessary-type-assertion lint rule
The `@typescript-eslint/no-unnecessary-type-assertion` rule is now enabled and all failures have been addressed within the code.
1 parent 53dd9a2 commit fa9bce0

File tree

19 files changed

+23
-24
lines changed

19 files changed

+23
-24
lines changed

.eslintrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
"@typescript-eslint/no-empty-function": "off",
108108
"@typescript-eslint/no-implied-eval": "off",
109109
"@typescript-eslint/no-var-requires": "off",
110-
"@typescript-eslint/no-unnecessary-type-assertion": "off",
111110
"@typescript-eslint/no-unsafe-argument": "off",
112111
"@typescript-eslint/no-unsafe-assignment": "off",
113112
"@typescript-eslint/no-unsafe-call": "off",

modules/testing/builder/src/builder-harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export class BuilderHarness<T> {
204204
// Harness builder targets currently do not support configurations
205205
return {};
206206
} else {
207-
return (this.builderTargets.get(target)?.options || {}) as json.JsonObject;
207+
return this.builderTargets.get(target)?.options || {};
208208
}
209209
},
210210
hasTarget: async (project, target) => {

packages/angular/build/src/tools/angular/transformers/jit-resource-transformer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function visitDecorator(
9999
return node;
100100
}
101101

102-
const objectExpression = args[0] as ts.ObjectLiteralExpression;
102+
const objectExpression = args[0];
103103
const styleReplacements: ts.Expression[] = [];
104104

105105
// visit all properties

packages/angular/build/src/utils/i18n-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function normalizeTranslationFileOption(
3939
}
4040

4141
if (Array.isArray(option) && option.every((element) => typeof element === 'string')) {
42-
return option as string[];
42+
return option;
4343
}
4444

4545
let errorMessage = `Project i18n locales translation field value for '${locale}' is malformed. `;

packages/angular_devkit/architect/src/jobs/create-job-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ export function createJobHandler<A extends JsonValue, I extends JsonValue, O ext
164164
if (isPromise(result)) {
165165
result = from(result);
166166
} else if (!isObservable(result)) {
167-
result = of(result as O);
167+
result = of(result);
168168
}
169169

170-
subscription = (result as Observable<O>).subscribe(
170+
subscription = result.subscribe(
171171
(value: O) => subject.next({ kind: JobOutboundMessageKind.Output, description, value }),
172172
(error) => subject.error(error),
173173
() => complete(),

packages/angular_devkit/architect/src/jobs/simple-scheduler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ export class SimpleScheduler<
418418

419419
const output = outboundBus.pipe(
420420
filter((x) => x.kind == JobOutboundMessageKind.Output),
421-
map((x) => (x as JobOutboundMessageOutput<O>).value),
421+
map((x) => x.value),
422422
shareReplay(1),
423423
);
424424

packages/angular_devkit/architect/src/jobs/simple-scheduler_spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ describe('SimpleScheduler', () => {
461461

462462
const job = scheduler.schedule('job', 0);
463463
let sideValue = '';
464+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
464465
const c = job.getChannel('any') as Observable<string>;
465466
c.subscribe((x) => (sideValue = x));
466467

@@ -486,6 +487,7 @@ describe('SimpleScheduler', () => {
486487

487488
const job = scheduler.schedule('job', 0);
488489
let sideValue = '';
490+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
489491
const c = job.getChannel('any', { type: 'number' }) as Observable<string>;
490492
expect(c).toBeDefined(null);
491493

packages/angular_devkit/build_angular/src/builders/dev-server/webpack-server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export function serveWebpackBrowser(
9797
logger.warn(`Warning: 'outputHashing' option is disabled when using the dev-server.`);
9898
}
9999

100+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
100101
const browserOptions = (await context.validateOptions(
101102
{
102103
...rawBrowserOptions,

packages/angular_devkit/build_angular/src/tools/babel/webpack-loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default custom<ApplicationPresetOptions>(() => {
114114
}
115115

116116
customOptions.i18n = {
117-
...(i18n as NonNullable<ApplicationPresetOptions['i18n']>),
117+
...i18n,
118118
pluginCreators: i18nPluginCreators,
119119
};
120120

packages/angular_devkit/core/node/host.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,11 @@ export class NodeJsSyncHost implements virtualFs.Host<Stats> {
208208
}
209209

210210
isDirectory(path: Path): Observable<boolean> {
211-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
212-
return this.stat(path)!.pipe(map((stat) => stat.isDirectory()));
211+
return this.stat(path).pipe(map((stat) => stat.isDirectory()));
213212
}
214213

215214
isFile(path: Path): Observable<boolean> {
216-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
217-
return this.stat(path)!.pipe(map((stat) => stat.isFile()));
215+
return this.stat(path).pipe(map((stat) => stat.isFile()));
218216
}
219217

220218
// Some hosts may not support stat.

0 commit comments

Comments
 (0)