(chore) run prettier
This commit is contained in:
@@ -5,7 +5,6 @@ import { isPathAngularComponent, extractComponentInlineTemplate } from '../utils
|
||||
import { parseTemplate, TmplAstNode, TmplAstElement, TmplAstTextAttribute } from '@angular/compiler';
|
||||
|
||||
export class DirectiveParser implements ParserInterface {
|
||||
|
||||
public extract(source: string, filePath: string): TranslationCollection | null {
|
||||
if (filePath && isPathAngularComponent(filePath)) {
|
||||
source = extractComponentInlineTemplate(source);
|
||||
@@ -42,13 +41,16 @@ export class DirectiveParser implements ParserInterface {
|
||||
return [node];
|
||||
}
|
||||
|
||||
return node.children.reduce((result: TmplAstElement[], childNode: TmplAstNode) => {
|
||||
if (this.isElement(childNode)) {
|
||||
const children = this.findChildrenElements(childNode);
|
||||
return result.concat(children);
|
||||
}
|
||||
return result;
|
||||
}, [node]);
|
||||
return node.children.reduce(
|
||||
(result: TmplAstElement[], childNode: TmplAstNode) => {
|
||||
if (this.isElement(childNode)) {
|
||||
const children = this.findChildrenElements(childNode);
|
||||
return result.concat(children);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
[node]
|
||||
);
|
||||
}
|
||||
|
||||
protected parseTemplate(template: string, path: string): TmplAstNode[] {
|
||||
@@ -56,9 +58,7 @@ export class DirectiveParser implements ParserInterface {
|
||||
}
|
||||
|
||||
protected isElement(node: any): node is TmplAstElement {
|
||||
return node
|
||||
&& node.attributes !== undefined
|
||||
&& node.children !== undefined;
|
||||
return node && node.attributes !== undefined && node.children !== undefined;
|
||||
}
|
||||
|
||||
protected isTranslatable(node: TmplAstNode): boolean {
|
||||
@@ -70,7 +70,7 @@ export class DirectiveParser implements ParserInterface {
|
||||
|
||||
protected getElementTranslateAttrValue(element: TmplAstElement): string {
|
||||
const attr: TmplAstTextAttribute = element.attributes.find(attribute => attribute.name === 'translate');
|
||||
return attr && attr.value || '';
|
||||
return (attr && attr.value) || '';
|
||||
}
|
||||
|
||||
protected getElementContents(element: TmplAstElement): string {
|
||||
@@ -79,5 +79,4 @@ export class DirectiveParser implements ParserInterface {
|
||||
const end = element.endSourceSpan.start.offset;
|
||||
return contents.substring(start, end).trim();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ const MARKER_MODULE_NAME = '@biesbjerg/ngx-translate-extract-marker';
|
||||
const MARKER_IMPORT_NAME = 'marker';
|
||||
|
||||
export class MarkerParser implements ParserInterface {
|
||||
|
||||
public extract(source: string, filePath: string): TranslationCollection | null {
|
||||
const sourceFile = tsquery.ast(source, filePath);
|
||||
|
||||
@@ -30,5 +29,4 @@ export class MarkerParser implements ParserInterface {
|
||||
});
|
||||
return collection;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { TranslationCollection } from '../utils/translation.collection';
|
||||
|
||||
export interface ParserInterface {
|
||||
|
||||
extract(source: string, filePath: string): TranslationCollection | null;
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { TranslationCollection } from '../utils/translation.collection';
|
||||
import { isPathAngularComponent, extractComponentInlineTemplate } from '../utils/utils';
|
||||
|
||||
export class PipeParser implements ParserInterface {
|
||||
|
||||
public extract(source: string, filePath: string): TranslationCollection | null {
|
||||
if (filePath && isPathAngularComponent(filePath)) {
|
||||
source = extractComponentInlineTemplate(source);
|
||||
@@ -17,11 +16,10 @@ export class PipeParser implements ParserInterface {
|
||||
|
||||
const regExp: RegExp = /(['"`])((?:(?!\1).|\\\1)+)\1\s*\|\s*translate/g;
|
||||
let matches: RegExpExecArray;
|
||||
while (matches = regExp.exec(template)) {
|
||||
collection = collection.add(matches[2].split('\\\'').join('\''));
|
||||
while ((matches = regExp.exec(template))) {
|
||||
collection = collection.add(matches[2].split("\\'").join("'"));
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ const TRANSLATE_SERVICE_TYPE_REFERENCE = 'TranslateService';
|
||||
const TRANSLATE_SERVICE_METHOD_NAMES = ['get', 'instant', 'stream'];
|
||||
|
||||
export class ServiceParser implements ParserInterface {
|
||||
|
||||
public extract(source: string, filePath: string): TranslationCollection | null {
|
||||
const sourceFile = tsquery.ast(source, filePath);
|
||||
|
||||
@@ -37,5 +36,4 @@ export class ServiceParser implements ParserInterface {
|
||||
});
|
||||
return collection;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user