Skip to content

Commit

Permalink
refactor: migrate localize to prettier formatting (angular#55423)
Browse files Browse the repository at this point in the history
Migrate formatting to prettier for localize from clang-format

PR Close angular#55423
  • Loading branch information
josephperrott authored and alxhub committed Apr 19, 2024
1 parent a2aca69 commit 488c711
Show file tree
Hide file tree
Showing 90 changed files with 4,572 additions and 3,263 deletions.
2 changes: 2 additions & 0 deletions .ng-dev/format.mts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const format: FormatConfig = {
'packages/examples/**/*.{js,ts}',
'packages/forms/**/*.{js,ts}',
'packages/language-service/**/*.{js,ts}',
'packages/localize/**/*.{js,ts}',
'packages/misc/**/*.{js,ts}',
'packages/private/**/*.{js,ts}',
'packages/router/**/*.{js,ts}',
Expand Down Expand Up @@ -79,6 +80,7 @@ export const format: FormatConfig = {
'!packages/examples/**/*.{js,ts}',
'!packages/forms/**/*.{js,ts}',
'!packages/language-service/**/*.{js,ts}',
'!packages/localize/**/*.{js,ts}',
'!packages/misc/**/*.{js,ts}',
'!packages/private/**/*.{js,ts}',
'!packages/router/**/*.{js,ts}',
Expand Down
5 changes: 1 addition & 4 deletions goldens/public-api/localize/tools/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ export function unwrapExpressionsFromTemplateLiteral(quasi: NodePath<types.Templ
export function unwrapMessagePartsFromLocalizeCall(call: NodePath<types.CallExpression>, fs?: PathManipulation): [TemplateStringsArray, (ɵSourceLocation | undefined)[]];

// @public
export function unwrapMessagePartsFromTemplateLiteral(elements: NodePath<types.TemplateElement>[], fs?: PathManipulation): [
TemplateStringsArray,
SourceLocation | undefined)[]
];
export function unwrapMessagePartsFromTemplateLiteral(elements: NodePath<types.TemplateElement>[], fs?: PathManipulation): [TemplateStringsArray, (ɵSourceLocation | undefined)[]];

// @public
export function unwrapSubstitutionsFromLocalizeCall(call: NodePath<types.CallExpression>, fs?: PathManipulation): [types.Expression[], (ɵSourceLocation | undefined)[]];
Expand Down
6 changes: 5 additions & 1 deletion packages/localize/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {ɵ$localize as $localize, ɵLocalizeFn as LocalizeFn, ɵTranslateFn as TranslateFn} from '@angular/localize';
import {
ɵ$localize as $localize,
ɵLocalizeFn as LocalizeFn,
ɵTranslateFn as TranslateFn,
} from '@angular/localize';

export {$localize, LocalizeFn, TranslateFn};

Expand Down
25 changes: 23 additions & 2 deletions packages/localize/private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,26 @@

// This file exports all the `utils` as private exports so that other parts of `@angular/localize`
// can make use of them.
export {$localize as ɵ$localize, LocalizeFn as ɵLocalizeFn, TranslateFn as ɵTranslateFn} from './src/localize';
export {computeMsgId as ɵcomputeMsgId, findEndOfBlock as ɵfindEndOfBlock, isMissingTranslationError as ɵisMissingTranslationError, makeParsedTranslation as ɵmakeParsedTranslation, makeTemplateObject as ɵmakeTemplateObject, MissingTranslationError as ɵMissingTranslationError, ParsedMessage as ɵParsedMessage, ParsedTranslation as ɵParsedTranslation, ParsedTranslations as ɵParsedTranslations, parseMessage as ɵparseMessage, parseMetadata as ɵparseMetadata, parseTranslation as ɵparseTranslation, SourceLocation as ɵSourceLocation, SourceMessage as ɵSourceMessage, splitBlock as ɵsplitBlock, translate as ɵtranslate} from './src/utils';
export {
$localize as ɵ$localize,
LocalizeFn as ɵLocalizeFn,
TranslateFn as ɵTranslateFn,
} from './src/localize';
export {
computeMsgId as ɵcomputeMsgId,
findEndOfBlock as ɵfindEndOfBlock,
isMissingTranslationError as ɵisMissingTranslationError,
makeParsedTranslation as ɵmakeParsedTranslation,
makeTemplateObject as ɵmakeTemplateObject,
MissingTranslationError as ɵMissingTranslationError,
ParsedMessage as ɵParsedMessage,
ParsedTranslation as ɵParsedTranslation,
ParsedTranslations as ɵParsedTranslations,
parseMessage as ɵparseMessage,
parseMetadata as ɵparseMetadata,
parseTranslation as ɵparseTranslation,
SourceLocation as ɵSourceLocation,
SourceMessage as ɵSourceMessage,
splitBlock as ɵsplitBlock,
translate as ɵtranslate,
} from './src/utils';
27 changes: 20 additions & 7 deletions packages/localize/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@
* @fileoverview Schematics for `ng add @angular/localize` schematic.
*/

import {chain, noop, Rule, SchematicContext, SchematicsException, Tree,} from '@angular-devkit/schematics';
import {
chain,
noop,
Rule,
SchematicContext,
SchematicsException,
Tree,
} from '@angular-devkit/schematics';
import {NodePackageInstallTask} from '@angular-devkit/schematics/tasks';
import {addPackageJsonDependency, NodeDependencyType, removePackageJsonDependency,} from '@schematics/angular/utility/dependencies';
import {
addPackageJsonDependency,
NodeDependencyType,
removePackageJsonDependency,
} from '@schematics/angular/utility/dependencies';
import {JSONFile, JSONPath} from '@schematics/angular/utility/json-file';
import {getWorkspace} from '@schematics/angular/utility/workspace';
import {Builders} from '@schematics/angular/utility/workspace-models';
Expand Down Expand Up @@ -66,12 +77,14 @@ function addTypeScriptConfigTypes(projectName: string): Rule {
const json = new JSONFile(host, path);
const types = json.get(typesJsonPath) ?? [];
if (!Array.isArray(types)) {
throw new SchematicsException(`TypeScript configuration file '${
path}' has an invalid 'types' property. It must be an array.`);
throw new SchematicsException(
`TypeScript configuration file '${path}' has an invalid 'types' property. It must be an array.`,
);
}

const hasLocalizeType =
types.some((t) => t === localizeType || t === '@angular/localize/init');
const hasLocalizeType = types.some(
(t) => t === localizeType || t === '@angular/localize/init',
);
if (hasLocalizeType) {
// Skip has already localize type.
continue;
Expand Down Expand Up @@ -107,7 +120,7 @@ function moveToDependencies(host: Tree, context: SchematicContext): void {
context.addTask(new NodePackageInstallTask());
}

export default function(options: Schema): Rule {
export default function (options: Schema): Rule {
return () => {
// We favor the name option because the project option has a
// smart default which can be populated even when unspecified by the user.
Expand Down
Loading

0 comments on commit 488c711

Please sign in to comment.