mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-05-20 00:06:24 +08:00
refactor(): run prettier
This commit is contained in:
@@ -23,11 +23,11 @@ export const EMIT_PATH = resolve(ROOT, 'injectable-classes.json');
|
||||
*/
|
||||
export function extractInjectables() {
|
||||
return (ctx: TransformationContext) => {
|
||||
return tsSourceFile => {
|
||||
return (tsSourceFile) => {
|
||||
if (tsSourceFile.fileName.indexOf('src/@awesome-cordova-plugins/plugins') > -1) {
|
||||
visitEachChild(
|
||||
tsSourceFile,
|
||||
node => {
|
||||
(node) => {
|
||||
if (node.kind !== SyntaxKind.ClassDeclaration) {
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -39,22 +39,22 @@ function transformImports(file: SourceFile, ctx: TransformationContext, ngcBuild
|
||||
if (decorators.length) {
|
||||
let methods = [];
|
||||
|
||||
decorators.forEach(d => (methods = getMethodsForDecorator(d).concat(methods)));
|
||||
decorators.forEach((d) => (methods = getMethodsForDecorator(d).concat(methods)));
|
||||
|
||||
const methodElements = methods.map(m => factory.createIdentifier(m));
|
||||
const methodNames = methodElements.map(el => el.escapedText);
|
||||
const methodElements = methods.map((m) => factory.createIdentifier(m));
|
||||
const methodNames = methodElements.map((el) => el.escapedText);
|
||||
|
||||
importStatement.importClause.namedBindings.elements = [
|
||||
factory.createIdentifier('AwesomeCordovaNativePlugin'),
|
||||
...methodElements,
|
||||
...importStatement.importClause.namedBindings.elements.filter(
|
||||
el => keep.indexOf(el.name.text) !== -1 && methodNames.indexOf(el.name.text) === -1
|
||||
(el) => keep.indexOf(el.name.text) !== -1 && methodNames.indexOf(el.name.text) === -1
|
||||
),
|
||||
];
|
||||
|
||||
if (ngcBuild) {
|
||||
importStatement.importClause.namedBindings.elements = importStatement.importClause.namedBindings.elements.map(
|
||||
binding => {
|
||||
(binding) => {
|
||||
if (binding.escapedText) {
|
||||
binding.name = {
|
||||
text: binding.escapedText,
|
||||
@@ -71,7 +71,7 @@ function transformImports(file: SourceFile, ctx: TransformationContext, ngcBuild
|
||||
|
||||
export function importsTransformer(ngcBuild?: boolean) {
|
||||
return (ctx: TransformationContext) => {
|
||||
return tsSourceFile => {
|
||||
return (tsSourceFile) => {
|
||||
return transformImports(tsSourceFile, ctx, ngcBuild);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ export function transformMembers(cls: ClassDeclaration) {
|
||||
members.push(getter, setter);
|
||||
});
|
||||
|
||||
propertyIndices.reverse().forEach(i => members.splice(i, 1));
|
||||
propertyIndices.reverse().forEach((i) => members.splice(i, 1));
|
||||
|
||||
return members;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ function transformClass(cls: any, ngcBuild?: boolean) {
|
||||
|
||||
cls = factory.createClassDeclaration(
|
||||
ngcBuild && cls.decorators && cls.decorators.length
|
||||
? cls.decorators.filter(d => getDecoratorName(d) === 'Injectable')
|
||||
? cls.decorators.filter((d) => getDecoratorName(d) === 'Injectable')
|
||||
: undefined, // remove Plugin and Injectable decorators
|
||||
[factory.createToken(SyntaxKind.ExportKeyword)],
|
||||
cls.name,
|
||||
@@ -55,10 +55,10 @@ function transformClasses(file: SourceFile, ctx: TransformationContext, ngcBuild
|
||||
Logger.silly('Transforming file: ' + file.fileName);
|
||||
return visitEachChild(
|
||||
file,
|
||||
node => {
|
||||
(node) => {
|
||||
if (
|
||||
node.kind !== SyntaxKind.ClassDeclaration ||
|
||||
(node.modifiers && node.modifiers.find(v => v.kind === SyntaxKind.DeclareKeyword))
|
||||
(node.modifiers && node.modifiers.find((v) => v.kind === SyntaxKind.DeclareKeyword))
|
||||
) {
|
||||
return node;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ function transformClasses(file: SourceFile, ctx: TransformationContext, ngcBuild
|
||||
|
||||
export function pluginClassTransformer(ngcBuild?: boolean): TransformerFactory<SourceFile> {
|
||||
return (ctx: TransformationContext) => {
|
||||
return tsSourceFile => {
|
||||
return (tsSourceFile) => {
|
||||
if (tsSourceFile.fileName.indexOf('src/@awesome-cordova-plugins/plugins') > -1) {
|
||||
return transformClasses(tsSourceFile, ctx, ngcBuild);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user