Skip to content
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
5 changes: 1 addition & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@
],

/* TODO: evaluate usage of these rules and fix issues as needed */
"no-case-declarations": "off",
"no-fallthrough": "off",
"no-underscore-dangle": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-implied-eval": "off",
"@typescript-eslint/no-var-requires": "off",
Expand All @@ -112,7 +109,6 @@
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/restrict-template-expressions": "off",
Expand All @@ -127,6 +123,7 @@
"rules": {
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"max-lines-per-function": "off",
"no-case-declarations": "off",
"no-console": "off"
}
}
Expand Down
19 changes: 11 additions & 8 deletions packages/angular/build/src/builders/extract-i18n/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,16 @@ async function createSerializer(
case Format.LegacyMigrate:
return new LegacyMessageIdMigrationSerializer(diagnostics);
case Format.Arb:
const fileSystem = {
relative(from: string, to: string): string {
return path.relative(from, to);
},
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
return new ArbTranslationSerializer(sourceLocale, basePath as any, fileSystem as any);
return new ArbTranslationSerializer(
sourceLocale,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
basePath as any,
{
relative(from: string, to: string): string {
return path.relative(from, to);
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export async function normalizeOptions(
// Normalize xliff format extensions
let format = options.format;
switch (format) {
case undefined:
// Default format is xliff1
case undefined:
case Format.Xlf:
case Format.Xlif:
case Format.Xliff:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,8 @@ export function elideImports(
let symbol: ts.Symbol | undefined;
switch (node.kind) {
case ts.SyntaxKind.Identifier:
const parent = node.parent;
if (parent && ts.isShorthandPropertyAssignment(parent)) {
const shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(parent);
if (node.parent && ts.isShorthandPropertyAssignment(node.parent)) {
const shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(node.parent);
if (shorthandSymbol) {
symbol = shorthandSymbol;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function visitComponentMetadata(

return node;

case 'styleUrls':
case 'styleUrls': {
if (!ts.isArrayLiteralExpression(node.initializer)) {
return node;
}
Expand All @@ -234,6 +234,7 @@ function visitComponentMetadata(

// The external styles will be added afterwards in combination with any inline styles
return undefined;
}
default:
// All other elements are passed through
return node;
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/build/src/utils/index-file/inline-fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class InlineFontsProcessor {
}
break;

case 'link':
case 'link': {
const hrefAttr =
attrs.some(({ name, value }) => name === 'rel' && value === 'stylesheet') &&
attrs.find(({ name, value }) => name === 'href' && hrefsContent.has(value));
Expand All @@ -157,7 +157,7 @@ export class InlineFontsProcessor {
rewriter.emitStartTag(tag);
}
break;

}
default:
rewriter.emitStartTag(tag);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,25 @@ export abstract class SchematicsCommandModule
continue;
}

const choices = definition.items?.map((item) => {
return typeof item == 'string'
? {
name: item,
value: item,
}
: {
name: item.label,
value: item.value,
};
});

answers[definition.id] = await (
definition.multiselect ? prompts.checkbox : prompts.select
)({
message: definition.message,
default: definition.default,
choices,
choices: definition.items?.map((item) =>
typeof item == 'string'
? {
name: item,
value: item,
}
: {
name: item.label,
value: item.value,
},
),
});
break;
case 'input':
case 'input': {
let finalValue: JsonValue | undefined;
answers[definition.id] = await prompts.input({
message: definition.message,
Expand Down Expand Up @@ -258,6 +256,7 @@ export abstract class SchematicsCommandModule
answers[definition.id] = finalValue;
}
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { logging } from '@angular-devkit/core';
import { NodeWorkflow } from '@angular-devkit/schematics/tools';
import { colors } from '../../utilities/color';

function removeLeadingSlash(value: string): string {
return value[0] === '/' ? value.slice(1) : value;
}

export function subscribeToWorkflow(
workflow: NodeWorkflow,
logger: logging.LoggerApi,
Expand All @@ -24,13 +28,14 @@ export function subscribeToWorkflow(

const reporterSubscription = workflow.reporter.subscribe((event) => {
// Strip leading slash to prevent confusion.
const eventPath = event.path.charAt(0) === '/' ? event.path.substring(1) : event.path;
const eventPath = removeLeadingSlash(event.path);

switch (event.kind) {
case 'error':
error = true;
const desc = event.description == 'alreadyExist' ? 'already exists' : 'does not exist';
logger.error(`ERROR! ${eventPath} ${desc}.`);
logger.error(
`ERROR! ${eventPath} ${event.description == 'alreadyExist' ? 'already exists' : 'does not exist'}.`,
);
break;
case 'update':
logs.push(`${colors.cyan('UPDATE')} ${eventPath} (${event.content.length} bytes)`);
Expand All @@ -45,8 +50,7 @@ export function subscribeToWorkflow(
files.add(eventPath);
break;
case 'rename':
const eventToPath = event.to.charAt(0) === '/' ? event.to.substring(1) : event.to;
logs.push(`${colors.blue('RENAME')} ${eventPath} => ${eventToPath}`);
logs.push(`${colors.blue('RENAME')} ${eventPath} => ${removeLeadingSlash(event.to)}`);
files.add(eventPath);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,16 @@ async function createSerializer(
case Format.LegacyMigrate:
return new LegacyMessageIdMigrationSerializer(diagnostics);
case Format.Arb:
const fileSystem = {
relative(from: string, to: string): string {
return path.relative(from, to);
},
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
return new ArbTranslationSerializer(sourceLocale, basePath as any, fileSystem as any);
return new ArbTranslationSerializer(
sourceLocale,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
basePath as any,
{
relative(from: string, to: string): string {
return path.relative(from, to);
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export async function normalizeOptions(
// Normalize xliff format extensions
let format = options.format;
switch (format) {
case undefined:
// Default format is xliff1
case undefined:
case Format.Xlf:
case Format.Xlif:
case Format.Xliff:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ export default custom<ApplicationPresetOptions>(() => {
case 'error':
this.emitError(message);
break;
case 'info':
// Webpack does not currently have an informational diagnostic
case 'info': // Webpack does not currently have an informational diagnostic
case 'warning':
this.emitWarning(message);
break;
Expand Down
3 changes: 2 additions & 1 deletion packages/angular_devkit/core/src/workspace/json/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function parseProject(
for (const [name, value] of Object.entries<JsonValue>(projectNodeValue)) {
switch (name) {
case 'targets':
case 'architect':
case 'architect': {
const nodes = findNodeAtLocation(projectNode, [name]);
if (!isJsonObject(value) || !nodes) {
context.error(`Invalid "${name}" field found; expected an object.`, value);
Expand All @@ -201,6 +201,7 @@ function parseProject(
targets = parseTargetsObject(projectName, nodes, context);
jsonMetadata.hasLegacyTargetsName = name === 'architect';
break;
}
case 'prefix':
case 'root':
case 'sourceRoot':
Expand Down
6 changes: 4 additions & 2 deletions packages/angular_devkit/core/src/workspace/json/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,18 @@ function normalizeValue(
switch (type) {
case 'project':
return convertJsonProject(value as ProjectDefinition);
case 'projectcollection':
case 'projectcollection': {
const projects = convertJsonProjectCollection(value as Iterable<[string, ProjectDefinition]>);

return isEmpty(projects) ? undefined : projects;
}
case 'target':
return convertJsonTarget(value as TargetDefinition);
case 'targetcollection':
case 'targetcollection': {
const targets = convertJsonTargetCollection(value as Iterable<[string, TargetDefinition]>);

return isEmpty(targets) ? undefined : targets;
}
default:
return value as JsonValue;
}
Expand Down
12 changes: 6 additions & 6 deletions packages/angular_devkit/schematics/src/engine/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,14 @@ export class SchematicEngine<CollectionT extends object, SchematicT extends obje
return () => new NullTree();
case 'empty:':
return () => empty();
default:
const hostSource = this._host.createSourceFromUrl(url, context);
if (!hostSource) {
throw new UnknownUrlSourceProtocol(url.toString());
}
}

return hostSource;
const hostSource = this._host.createSourceFromUrl(url, context);
if (!hostSource) {
throw new UnknownUrlSourceProtocol(url.toString());
}

return hostSource;
}

executePostTasks(): Observable<void> {
Expand Down
3 changes: 2 additions & 1 deletion packages/angular_devkit/schematics/src/tree/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class ActionList implements Iterable<Action> {
toDelete.add(action.path);
break;

case 'r':
case 'r': {
const maybeCreate = toCreate.get(action.path);
const maybeOverwrite = toOverwrite.get(action.path);
if (maybeCreate) {
Expand Down Expand Up @@ -100,6 +100,7 @@ export class ActionList implements Iterable<Action> {
toRename.set(action.path, action.to);
}
break;
}
}
}

Expand Down
Loading