Run prettier on code
This commit is contained in:
@@ -13,7 +13,7 @@ export class DirectiveParser implements ParserInterface {
|
||||
let collection: TranslationCollection = new TranslationCollection();
|
||||
|
||||
const nodes: TmplAstNode[] = this.parseTemplate(source, filePath);
|
||||
this.getTranslatableElements(nodes).forEach(element => {
|
||||
this.getTranslatableElements(nodes).forEach((element) => {
|
||||
const key = this.getElementTranslateAttrValue(element) || this.getElementContent(element);
|
||||
collection = collection.add(key);
|
||||
});
|
||||
@@ -23,11 +23,11 @@ export class DirectiveParser implements ParserInterface {
|
||||
|
||||
protected getTranslatableElements(nodes: TmplAstNode[]): TmplAstElement[] {
|
||||
return nodes
|
||||
.filter(element => this.isElement(element))
|
||||
.filter((element) => this.isElement(element))
|
||||
.reduce((result: TmplAstElement[], element: TmplAstElement) => {
|
||||
return result.concat(this.findChildrenElements(element));
|
||||
}, [])
|
||||
.filter(element => this.isTranslatable(element));
|
||||
.filter((element) => this.isTranslatable(element));
|
||||
}
|
||||
|
||||
protected findChildrenElements(node: TmplAstNode): TmplAstElement[] {
|
||||
@@ -62,14 +62,14 @@ export class DirectiveParser implements ParserInterface {
|
||||
}
|
||||
|
||||
protected isTranslatable(node: TmplAstNode): boolean {
|
||||
if (this.isElement(node) && node.attributes.some(attribute => attribute.name === 'translate')) {
|
||||
if (this.isElement(node) && node.attributes.some((attribute) => attribute.name === 'translate')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected getElementTranslateAttrValue(element: TmplAstElement): string {
|
||||
const attr: TmplAstTextAttribute = element.attributes.find(attribute => attribute.name === 'translate');
|
||||
const attr: TmplAstTextAttribute = element.attributes.find((attribute) => attribute.name === 'translate');
|
||||
return attr?.value ?? '';
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export class MarkerParser implements ParserInterface {
|
||||
let collection: TranslationCollection = new TranslationCollection();
|
||||
|
||||
const callExpressions = findFunctionCallExpressions(sourceFile, markerImportName);
|
||||
callExpressions.forEach(callExpression => {
|
||||
callExpressions.forEach((callExpression) => {
|
||||
const [firstArg] = callExpression.arguments;
|
||||
if (!firstArg) {
|
||||
return;
|
||||
|
||||
@@ -14,8 +14,8 @@ export class PipeParser implements ParserInterface {
|
||||
|
||||
let collection: TranslationCollection = new TranslationCollection();
|
||||
const nodes: TmplAstNode[] = this.parseTemplate(source, filePath);
|
||||
const pipes: BindingPipe[] = nodes.map(node => this.findPipesInNode(node)).flat();
|
||||
pipes.forEach(pipe => {
|
||||
const pipes: BindingPipe[] = nodes.map((node) => this.findPipesInNode(node)).flat();
|
||||
pipes.forEach((pipe) => {
|
||||
this.parseTranslationKeysFromPipe(pipe).forEach((key: string) => {
|
||||
collection = collection.add(key);
|
||||
});
|
||||
|
||||
@@ -3,7 +3,15 @@ import { tsquery } from '@phenomnomnominal/tsquery';
|
||||
|
||||
import { ParserInterface } from './parser.interface';
|
||||
import { TranslationCollection } from '../utils/translation.collection';
|
||||
import { findClassDeclarations, findClassPropertyByType, findPropertyCallExpressions, findMethodCallExpressions, getStringsFromExpression, findMethodParameterByType, findConstructorDeclaration } from '../utils/ast-helpers';
|
||||
import {
|
||||
findClassDeclarations,
|
||||
findClassPropertyByType,
|
||||
findPropertyCallExpressions,
|
||||
findMethodCallExpressions,
|
||||
getStringsFromExpression,
|
||||
findMethodParameterByType,
|
||||
findConstructorDeclaration
|
||||
} from '../utils/ast-helpers';
|
||||
|
||||
const TRANSLATE_SERVICE_TYPE_REFERENCE = 'TranslateService';
|
||||
const TRANSLATE_SERVICE_METHOD_NAMES = ['get', 'instant', 'stream'];
|
||||
@@ -19,13 +27,13 @@ export class ServiceParser implements ParserInterface {
|
||||
|
||||
let collection: TranslationCollection = new TranslationCollection();
|
||||
|
||||
classDeclarations.forEach(classDeclaration => {
|
||||
classDeclarations.forEach((classDeclaration) => {
|
||||
const callExpressions = [
|
||||
...this.findConstructorParamCallExpressions(classDeclaration),
|
||||
...this.findPropertyCallExpressions(classDeclaration)
|
||||
];
|
||||
|
||||
callExpressions.forEach(callExpression => {
|
||||
callExpressions.forEach((callExpression) => {
|
||||
const [firstArg] = callExpression.arguments;
|
||||
if (!firstArg) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user