From 99a0e0282dc189aefdc3f5c85578d49c709387cc Mon Sep 17 00:00:00 2001 From: Daniel Sogl Date: Mon, 27 Sep 2021 22:09:05 +0200 Subject: [PATCH] refactor(): run prettier --- README.md | 4 +- prettier.config.js | 8 -- scripts/build/helpers.ts | 6 +- scripts/build/ngx.ts | 12 +-- scripts/build/remove-tslib-helpers.js | 2 +- .../build/transformers/extract-injectables.ts | 4 +- scripts/build/transformers/imports.ts | 12 +-- scripts/build/transformers/members.ts | 2 +- scripts/build/transformers/plugin-class.ts | 8 +- scripts/docs-json/index.ts | 8 +- scripts/docs/dgeni/dgeni-config.js | 4 +- scripts/docs/dgeni/dgeni-readmes-config.js | 4 +- scripts/docs/dgeni/filters/capital.js | 2 +- scripts/docs/dgeni/filters/dashify.js | 2 +- scripts/docs/dgeni/filters/dump.js | 2 +- .../docs/dgeni/processors/hide-private-api.js | 2 +- scripts/docs/dgeni/processors/jekyll.js | 8 +- .../docs/dgeni/processors/mark-properties.js | 4 +- scripts/docs/dgeni/processors/npm-id.js | 4 +- .../docs/dgeni/processors/parse-optional.js | 4 +- scripts/docs/dgeni/processors/readmes.js | 6 +- .../processors/remove-private-members.js | 8 +- scripts/docs/gulp-tasks.js | 6 +- scripts/tasks/build-es5.ts | 2 +- scripts/tasks/build-esm.ts | 8 +- .../core/decorators/common.ts | 4 +- .../plugins/email-composer/index.ts | 10 +-- .../plugins/file/index.ts | 84 +++++++++---------- .../plugins/hyper-track/index.ts | 26 +++--- .../plugins/smartlook/index.ts | 2 +- .../plugins/web-socket-server/index.ts | 2 +- 31 files changed, 126 insertions(+), 134 deletions(-) diff --git a/README.md b/README.md index cfa02e9f..dd996add 100644 --- a/README.md +++ b/README.md @@ -135,8 +135,8 @@ import { Camera } from '@awesome-cordova-plugins/camera'; document.addEventListener('deviceready', () => { Camera.getPicture() - .then(data => console.log('Took a picture!', data)) - .catch(e => console.log('Error occurred while taking a picture', e)); + .then((data) => console.log('Took a picture!', data)) + .catch((e) => console.log('Error occurred while taking a picture', e)); }); ``` diff --git a/prettier.config.js b/prettier.config.js index d214571a..7845f3ea 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -5,12 +5,4 @@ module.exports = { semi: true, singleQuote: true, trailingComma: 'es5', - bracketSpacing: true, - jsxBracketSameLine: false, - arrowParens: 'avoid', - rangeStart: 0, - rangeEnd: Infinity, - requirePragma: false, - insertPragma: false, - proseWrap: 'preserve', }; diff --git a/scripts/build/helpers.ts b/scripts/build/helpers.ts index 627aaacc..a4364a9e 100644 --- a/scripts/build/helpers.ts +++ b/scripts/build/helpers.ts @@ -19,7 +19,7 @@ export const ROOT = resolve(__dirname, '../../'); export const TS_CONFIG = clone(require(resolve(ROOT, 'tsconfig.json'))); export const COMPILER_OPTIONS = TS_CONFIG.compilerOptions; export const PLUGINS_ROOT = join(ROOT, 'src/@awesome-cordova-plugins/plugins/'); -export const PLUGIN_PATHS = readdirSync(PLUGINS_ROOT).map(d => join(PLUGINS_ROOT, d, 'index.ts')); +export const PLUGIN_PATHS = readdirSync(PLUGINS_ROOT).map((d) => join(PLUGINS_ROOT, d, 'index.ts')); export function getDecorator(node: Node, index = 0): Decorator { if (node.decorators && node.decorators[index]) { @@ -31,7 +31,7 @@ export function hasDecorator(decoratorName: string, node: Node): boolean { return ( node.decorators && node.decorators.length && - node.decorators.findIndex(d => getDecoratorName(d) === decoratorName) > -1 + node.decorators.findIndex((d) => getDecoratorName(d) === decoratorName) > -1 ); } @@ -48,7 +48,7 @@ export function getDecoratorArgs(decorator: any) { const properties: any[] = getRawDecoratorArgs(decorator); const args = {}; - properties.forEach(prop => { + properties.forEach((prop) => { let val: number | boolean; switch (prop.initializer.kind) { diff --git a/scripts/build/ngx.ts b/scripts/build/ngx.ts index c99ef34a..eaf9829a 100644 --- a/scripts/build/ngx.ts +++ b/scripts/build/ngx.ts @@ -53,14 +53,14 @@ export function transpileNgx() { } export function generateDeclarationFiles() { - generateDeclarations(PLUGIN_PATHS.map(p => p.replace('index.ts', 'ngx/index.ts'))); + generateDeclarations(PLUGIN_PATHS.map((p) => p.replace('index.ts', 'ngx/index.ts'))); } export function generateLegacyBundles() { [ resolve(ROOT, 'dist/@awesome-cordova-plugins/core/index.js'), - ...PLUGIN_PATHS.map(p => p.replace(join(ROOT, 'src'), join(ROOT, 'dist')).replace('index.ts', 'ngx/index.js')), - ].forEach(p => + ...PLUGIN_PATHS.map((p) => p.replace(join(ROOT, 'src'), join(ROOT, 'dist')).replace('index.ts', 'ngx/index.js')), + ].forEach((p) => rollup({ input: p, onwarn(warning, warn) { @@ -68,7 +68,7 @@ export function generateLegacyBundles() { warn(warning); }, external: ['@angular/core', '@awesome-cordova-plugins/core', 'rxjs', 'tslib'], - }).then(bundle => + }).then((bundle) => bundle.write({ file: join(dirname(p), 'bundle.js'), format: 'cjs', @@ -79,9 +79,9 @@ export function generateLegacyBundles() { // remove reference to @awesome-cordova-plugins/core decorators export function modifyMetadata() { - PLUGIN_PATHS.map(p => + PLUGIN_PATHS.map((p) => p.replace(join(ROOT, 'src'), join(ROOT, 'dist')).replace('index.ts', 'ngx/index.metadata.json') - ).forEach(p => { + ).forEach((p) => { const content = readJSONSync(p); let _prop: { members: { [x: string]: any[] } }; for (const prop in content[0].metadata) { diff --git a/scripts/build/remove-tslib-helpers.js b/scripts/build/remove-tslib-helpers.js index 8b0de3c6..4db117d6 100644 --- a/scripts/build/remove-tslib-helpers.js +++ b/scripts/build/remove-tslib-helpers.js @@ -1,2 +1,2 @@ // removes the __extends method that is added automatically by typescript -module.exports = source => source.replace(/var\s__extends\s=\s\(this\s&&[\sa-z\._\(\)\|{}=:\[\]&,;?]+}\)\(\);/i, ''); +module.exports = (source) => source.replace(/var\s__extends\s=\s\(this\s&&[\sa-z\._\(\)\|{}=:\[\]&,;?]+}\)\(\);/i, ''); diff --git a/scripts/build/transformers/extract-injectables.ts b/scripts/build/transformers/extract-injectables.ts index b3f002e7..e15c4a0c 100644 --- a/scripts/build/transformers/extract-injectables.ts +++ b/scripts/build/transformers/extract-injectables.ts @@ -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; } diff --git a/scripts/build/transformers/imports.ts b/scripts/build/transformers/imports.ts index 4e22b0e3..2e534856 100644 --- a/scripts/build/transformers/imports.ts +++ b/scripts/build/transformers/imports.ts @@ -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); }; }; diff --git a/scripts/build/transformers/members.ts b/scripts/build/transformers/members.ts index fafa51de..74e6af07 100644 --- a/scripts/build/transformers/members.ts +++ b/scripts/build/transformers/members.ts @@ -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; } diff --git a/scripts/build/transformers/plugin-class.ts b/scripts/build/transformers/plugin-class.ts index 29e01101..8ba4cc10 100644 --- a/scripts/build/transformers/plugin-class.ts +++ b/scripts/build/transformers/plugin-class.ts @@ -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 { return (ctx: TransformationContext) => { - return tsSourceFile => { + return (tsSourceFile) => { if (tsSourceFile.fileName.indexOf('src/@awesome-cordova-plugins/plugins') > -1) { return transformClasses(tsSourceFile, ctx, ngcBuild); } diff --git a/scripts/docs-json/index.ts b/scripts/docs-json/index.ts index ffa86663..2c1b9c48 100644 --- a/scripts/docs-json/index.ts +++ b/scripts/docs-json/index.ts @@ -45,7 +45,7 @@ async function run(pluginsDir: string) { async function generateTypedoc(root: string, outputPath = typedocTmp, outputDocsPath = typedocDocsTmp) { const pluginDirs = await readdir(root); - const paths = pluginDirs.map(dir => resolve(root, dir, 'index.ts')); + const paths = pluginDirs.map((dir) => resolve(root, dir, 'index.ts')); typedoc.bootstrap({ /* mode: 'modules', @@ -96,7 +96,7 @@ function processPlugin(pluginModule): Plugin { */ const getPluginDecorator = (child: any) => { if (isPlugin(child)) { - const decorator = child.decorators.find(d => d.name === 'Plugin'); + const decorator = child.decorators.find((d) => d.name === 'Plugin'); console.log('Found decorator', decorator.arguments, child); return runInNewContext(`(${decorator.arguments.config})`); @@ -105,7 +105,7 @@ const getPluginDecorator = (child: any) => { const getTag = (child: any, tagName: string): string => { if (hasTags(child)) { - const tag = child.comment.tags.find(t => t.tag === tagName); + const tag = child.comment.tags.find((t) => t.tag === tagName); if (tag) { return tag.text; } @@ -120,7 +120,7 @@ const isPlugin = (child: any): boolean => isClass(child) && hasTags(child) && Array.isArray(child.decorators) && - child.decorators.some(d => d.name === 'Plugin'); + child.decorators.some((d) => d.name === 'Plugin'); const hasPlugin = (child: any): boolean => child.children.some(isPlugin); diff --git a/scripts/docs/dgeni/dgeni-config.js b/scripts/docs/dgeni/dgeni-config.js index f5f8d54a..93803617 100644 --- a/scripts/docs/dgeni/dgeni-config.js +++ b/scripts/docs/dgeni/dgeni-config.js @@ -7,7 +7,7 @@ const Package = require('dgeni').Package, path = require('path'), config = require('../config.json'); -module.exports = currentVersion => { +module.exports = (currentVersion) => { return ( new Package('ionic-native-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage]) @@ -40,7 +40,7 @@ module.exports = currentVersion => { computePathsProcessor.pathTemplates = [ { docTypes: ['class'], - getOutputPath: doc => 'content/' + config.v2DocsDir + '/' + doc.name + '/index.md', + getOutputPath: (doc) => 'content/' + config.v2DocsDir + '/' + doc.name + '/index.md', }, ]; }) diff --git a/scripts/docs/dgeni/dgeni-readmes-config.js b/scripts/docs/dgeni/dgeni-readmes-config.js index 21dffbfd..a14ef45f 100644 --- a/scripts/docs/dgeni/dgeni-readmes-config.js +++ b/scripts/docs/dgeni/dgeni-readmes-config.js @@ -7,7 +7,7 @@ const Package = require('dgeni').Package, path = require('path'), config = require('../config.json'); -module.exports = currentVersion => { +module.exports = (currentVersion) => { return ( new Package('ionic-native-readmes', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage]) @@ -38,7 +38,7 @@ module.exports = currentVersion => { computePathsProcessor.pathTemplates = [ { docTypes: ['class'], - getOutputPath: doc => + getOutputPath: (doc) => doc.originalModule.replace(config.pluginDir + '/', '').replace(/\/index$/, '/README.md'), }, ]; diff --git a/scripts/docs/dgeni/filters/capital.js b/scripts/docs/dgeni/filters/capital.js index 038c2bc2..9d3c2bb5 100644 --- a/scripts/docs/dgeni/filters/capital.js +++ b/scripts/docs/dgeni/filters/capital.js @@ -1,5 +1,5 @@ 'use strict'; module.exports = { name: 'capital', - process: str => (str ? str.charAt(0).toUpperCase() + str.substring(1) : ''), + process: (str) => (str ? str.charAt(0).toUpperCase() + str.substring(1) : ''), }; diff --git a/scripts/docs/dgeni/filters/dashify.js b/scripts/docs/dgeni/filters/dashify.js index 5eff4638..60054c78 100644 --- a/scripts/docs/dgeni/filters/dashify.js +++ b/scripts/docs/dgeni/filters/dashify.js @@ -1,5 +1,5 @@ 'use strict'; module.exports = { name: 'dashify', - process: str => (str ? str.replace(/\s/g, '-') : ''), + process: (str) => (str ? str.replace(/\s/g, '-') : ''), }; diff --git a/scripts/docs/dgeni/filters/dump.js b/scripts/docs/dgeni/filters/dump.js index 539c10bc..ad23b94c 100644 --- a/scripts/docs/dgeni/filters/dump.js +++ b/scripts/docs/dgeni/filters/dump.js @@ -1,5 +1,5 @@ 'use strict'; module.exports = { name: 'dump', - process: obj => console.log(obj), + process: (obj) => console.log(obj), }; diff --git a/scripts/docs/dgeni/processors/hide-private-api.js b/scripts/docs/dgeni/processors/hide-private-api.js index 9b372294..e58c8f71 100644 --- a/scripts/docs/dgeni/processors/hide-private-api.js +++ b/scripts/docs/dgeni/processors/hide-private-api.js @@ -4,6 +4,6 @@ module.exports = function removePrivateApi() { name: 'remove-private-api', description: 'Prevent the private apis from being rendered', $runBefore: ['rendering-docs'], - $process: docs => docs.filter(doc => !doc.private && (!doc.tags || !doc.tags.tagsByName.get('hidden'))), + $process: (docs) => docs.filter((doc) => !doc.private && (!doc.tags || !doc.tags.tagsByName.get('hidden'))), }; }; diff --git a/scripts/docs/dgeni/processors/jekyll.js b/scripts/docs/dgeni/processors/jekyll.js index de29fdb0..6c9d4637 100644 --- a/scripts/docs/dgeni/processors/jekyll.js +++ b/scripts/docs/dgeni/processors/jekyll.js @@ -5,9 +5,9 @@ module.exports = function jekyll(renderDocsProcessor) { description: 'Create jekyll includes', $runAfter: ['paths-computed'], $runBefore: ['rendering-docs'], - $process: docs => { + $process: (docs) => { // pretty up and sort the docs object for menu generation - docs = docs.filter(doc => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page'); + docs = docs.filter((doc) => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page'); docs.push({ docType: 'class', @@ -22,7 +22,7 @@ module.exports = function jekyll(renderDocsProcessor) { return textA < textB ? -1 : textA > textB ? 1 : 0; }); - docs.forEach(doc => { + docs.forEach((doc) => { if (!doc.outputPath) { return; } @@ -39,7 +39,7 @@ module.exports = function jekyll(renderDocsProcessor) { const betaDocs = []; - docs = docs.filter(doc => { + docs = docs.filter((doc) => { if (doc.beta === true) { betaDocs.push(doc); return false; diff --git a/scripts/docs/dgeni/processors/mark-properties.js b/scripts/docs/dgeni/processors/mark-properties.js index 30de1072..2b02528a 100644 --- a/scripts/docs/dgeni/processors/mark-properties.js +++ b/scripts/docs/dgeni/processors/mark-properties.js @@ -3,8 +3,8 @@ module.exports = function markProperties() { return { name: 'mark-properties', $runBefore: ['rendering-docs'], - $process: docs => - docs.map(doc => { + $process: (docs) => + docs.map((doc) => { for (let i in doc.members) { if (doc.members.hasOwnProperty(i) && typeof doc.members[i].parameters === 'undefined') { doc.members[i].isProperty = true; diff --git a/scripts/docs/dgeni/processors/npm-id.js b/scripts/docs/dgeni/processors/npm-id.js index ac6f30a7..31394f27 100644 --- a/scripts/docs/dgeni/processors/npm-id.js +++ b/scripts/docs/dgeni/processors/npm-id.js @@ -4,13 +4,13 @@ module.exports = function npmId(renderDocsProcessor) { name: 'npm-id', $runAfter: ['paths-computed'], $runBefore: ['rendering-docs'], - $process: docs => { + $process: (docs) => { // pretty up and sort the docs object for menu generation docs = docs.filter(function (doc) { return (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page'; }); - docs.forEach(doc => { + docs.forEach((doc) => { doc.npmId = doc.id.match(/plugins\/(.*)\/index/)[1]; }); diff --git a/scripts/docs/dgeni/processors/parse-optional.js b/scripts/docs/dgeni/processors/parse-optional.js index ffd2c7a0..9b38a2f7 100644 --- a/scripts/docs/dgeni/processors/parse-optional.js +++ b/scripts/docs/dgeni/processors/parse-optional.js @@ -2,8 +2,8 @@ module.exports = function parseOptional() { return { $runBefore: ['rendering-docs'], - $process: docs => { - docs.forEach(doc => { + $process: (docs) => { + docs.forEach((doc) => { if (doc.members && doc.members.length) { for (let i in doc.members) { if (doc.members[i].params && doc.members[i].params.length) { diff --git a/scripts/docs/dgeni/processors/readmes.js b/scripts/docs/dgeni/processors/readmes.js index 8c24b0bc..1f3cf38d 100644 --- a/scripts/docs/dgeni/processors/readmes.js +++ b/scripts/docs/dgeni/processors/readmes.js @@ -5,11 +5,11 @@ module.exports = function readmes(renderDocsProcessor) { description: 'Create jekyll includes', $runAfter: ['paths-computed'], $runBefore: ['rendering-docs'], - $process: docs => { + $process: (docs) => { // pretty up and sort the docs object for menu generation - docs = docs.filter(doc => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page'); + docs = docs.filter((doc) => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page'); - docs.forEach(doc => { + docs.forEach((doc) => { doc.outputPath = doc.outputPath.replace('src/@awesome-cordova-plugins/', ''); }); diff --git a/scripts/docs/dgeni/processors/remove-private-members.js b/scripts/docs/dgeni/processors/remove-private-members.js index 703fb29b..2dd0b0a3 100644 --- a/scripts/docs/dgeni/processors/remove-private-members.js +++ b/scripts/docs/dgeni/processors/remove-private-members.js @@ -5,14 +5,14 @@ module.exports = function removePrivateMembers() { description: 'Remove member docs with @private tags', $runAfter: ['tags-parsed'], $runBefore: ['rendering-docs'], - $process: docs => { - docs.forEach(doc => { + $process: (docs) => { + docs.forEach((doc) => { if (doc.members) { - doc.members = doc.members.filter(member => !member.tags.tagsByName.get('hidden')); + doc.members = doc.members.filter((member) => !member.tags.tagsByName.get('hidden')); } if (doc.statics) { - doc.statics = doc.statics.filter(staticMethod => !staticMethod.tags.tagsByName.get('hidden')); + doc.statics = doc.statics.filter((staticMethod) => !staticMethod.tags.tagsByName.get('hidden')); } }); diff --git a/scripts/docs/gulp-tasks.js b/scripts/docs/gulp-tasks.js index 862ecf7d..66fbd8a4 100644 --- a/scripts/docs/gulp-tasks.js +++ b/scripts/docs/gulp-tasks.js @@ -5,13 +5,13 @@ const config = require('./config.json'), fs = require('fs-extra'), Dgeni = require('dgeni'); -module.exports = gulp => { +module.exports = (gulp) => { gulp.task('docs', () => { try { const ionicPackage = require('./dgeni/dgeni-config')(projectPackage.version), dgeni = new Dgeni([ionicPackage]); - return dgeni.generate().then(docs => console.log(docs.length + ' docs generated')); + return dgeni.generate().then((docs) => console.log(docs.length + ' docs generated')); } catch (err) { console.log(err.stack); } @@ -26,7 +26,7 @@ module.exports = gulp => { try { const ionicPackage = require('./dgeni/dgeni-readmes-config')(projectPackage.version), dgeni = new Dgeni([ionicPackage]); - return dgeni.generate().then(docs => console.log(docs.length + ' README files generated')); + return dgeni.generate().then((docs) => console.log(docs.length + ' README files generated')); } catch (err) { console.log(err.stack); } diff --git a/scripts/tasks/build-es5.ts b/scripts/tasks/build-es5.ts index d23c21e6..52fff2f9 100644 --- a/scripts/tasks/build-es5.ts +++ b/scripts/tasks/build-es5.ts @@ -67,7 +67,7 @@ function createIndexFile() { let fileContent = ''; fileContent += INJECTABLE_CLASSES.map(getPluginImport).join('\n'); fileContent += `\nwindow.IonicNative = {\n`; - fileContent += INJECTABLE_CLASSES.map(e => e.className).join(',\n'); + fileContent += INJECTABLE_CLASSES.map((e) => e.className).join(',\n'); fileContent += '\n};\n'; fileContent += `require('./@awesome-cordova-plugins/core/bootstrap').checkReady();\n`; fileContent += `require('./@awesome-cordova-plugins/core/ng1').initAngular1(window.IonicNative);`; diff --git a/scripts/tasks/build-esm.ts b/scripts/tasks/build-esm.ts index 1cc6e194..494667ac 100644 --- a/scripts/tasks/build-esm.ts +++ b/scripts/tasks/build-esm.ts @@ -8,16 +8,16 @@ import { generateDeclarations, transpile } from '../build/transpile'; generateDeclarations(); transpile(); -const outDirs = PLUGIN_PATHS.map(p => p.replace(join(ROOT, 'src'), join(ROOT, 'dist')).replace(/[\\/]index.ts/, '')); +const outDirs = PLUGIN_PATHS.map((p) => p.replace(join(ROOT, 'src'), join(ROOT, 'dist')).replace(/[\\/]index.ts/, '')); const injectableClasses = readJSONSync(EMIT_PATH); -outDirs.forEach(dir => { - const classes = injectableClasses.filter(entry => entry.dirName === dir.split(/[\\/]+/).pop()); +outDirs.forEach((dir) => { + const classes = injectableClasses.filter((entry) => entry.dirName === dir.split(/[\\/]+/).pop()); let jsFile: string = readFileSync(join(dir, 'index.js'), 'utf-8'), dtsFile: string = readFileSync(join(dir, 'index.d.ts'), 'utf-8'); - classes.forEach(entry => { + classes.forEach((entry) => { dtsFile = dtsFile.replace(`class ${entry.className} `, 'class ' + entry.className + 'Original '); dtsFile += `\nexport declare const ${entry.className}: ${entry.className}Original;`; jsFile = jsFile.replace( diff --git a/src/@awesome-cordova-plugins/core/decorators/common.ts b/src/@awesome-cordova-plugins/core/decorators/common.ts index 73f906c1..b2c6ff92 100644 --- a/src/@awesome-cordova-plugins/core/decorators/common.ts +++ b/src/@awesome-cordova-plugins/core/decorators/common.ts @@ -80,7 +80,7 @@ function wrapOtherPromise(pluginObj: any, methodName: string, args: any[], opts: } function wrapObservable(pluginObj: any, methodName: string, args: any[], opts: any = {}) { - return new Observable(observer => { + return new Observable((observer) => { let pluginResult; if (opts.destruct) { @@ -384,7 +384,7 @@ export function wrapInstance(pluginObj: any, methodName: string, opts: any = {}) if (opts.sync) { return callInstance(pluginObj, methodName, args, opts); } else if (opts.observable) { - return new Observable(observer => { + return new Observable((observer) => { let pluginResult; if (opts.destruct) { diff --git a/src/@awesome-cordova-plugins/plugins/email-composer/index.ts b/src/@awesome-cordova-plugins/plugins/email-composer/index.ts index cb9893ce..64164a21 100644 --- a/src/@awesome-cordova-plugins/plugins/email-composer/index.ts +++ b/src/@awesome-cordova-plugins/plugins/email-composer/index.ts @@ -162,7 +162,7 @@ export class EmailComposer extends AwesomeCordovaNativePlugin { */ @CordovaCheck() hasAccount(): Promise { - return getPromise(resolve => { + return getPromise((resolve) => { EmailComposer.getPlugin().hasAccount((result: boolean) => { if (result) { resolve(true); @@ -182,7 +182,7 @@ export class EmailComposer extends AwesomeCordovaNativePlugin { @CordovaCheck() hasClient(app?: string): Promise { - return getPromise(resolve => { + return getPromise((resolve) => { if (app) { EmailComposer.getPlugin().hasClient(app, (result: boolean) => { if (result) { @@ -207,7 +207,7 @@ export class EmailComposer extends AwesomeCordovaNativePlugin { @CordovaCheck() @Cordova({ platforms: ['Android'] }) getClients(): Promise { - return getPromise(resolve => { + return getPromise((resolve) => { EmailComposer.getPlugin().getClients((apps: any) => { if (Object.prototype.toString.call(apps) === '[object String]') { apps = [apps]; @@ -225,8 +225,8 @@ export class EmailComposer extends AwesomeCordovaNativePlugin { */ @CordovaCheck() isAvailable(app?: string): Promise { - return getPromise(resolve => { - Promise.all([this.hasAccount, this.hasClient(app)]).then(results => { + return getPromise((resolve) => { + Promise.all([this.hasAccount, this.hasClient(app)]).then((results) => { return resolve(results.length === 2 && results[0] && results[1]); }); }); diff --git a/src/@awesome-cordova-plugins/plugins/file/index.ts b/src/@awesome-cordova-plugins/plugins/file/index.ts index 58383e04..b33cdd91 100644 --- a/src/@awesome-cordova-plugins/plugins/file/index.ts +++ b/src/@awesome-cordova-plugins/plugins/file/index.ts @@ -819,7 +819,7 @@ export class File extends AwesomeCordovaNativePlugin { options.exclusive = true; } - return this.resolveDirectoryUrl(path).then(fse => { + return this.resolveDirectoryUrl(path).then((fse) => { return this.getDirectory(fse, dirName, options); }); } @@ -840,10 +840,10 @@ export class File extends AwesomeCordovaNativePlugin { } return this.resolveDirectoryUrl(path) - .then(fse => { + .then((fse) => { return this.getDirectory(fse, dirName, { create: false }); }) - .then(de => { + .then((de) => { return this.remove(de); }); } @@ -869,11 +869,11 @@ export class File extends AwesomeCordovaNativePlugin { } return this.resolveDirectoryUrl(path) - .then(fse => { + .then((fse) => { return this.getDirectory(fse, dirName, { create: false }); }) - .then(srcde => { - return this.resolveDirectoryUrl(newPath).then(destenation => { + .then((srcde) => { + return this.resolveDirectoryUrl(newPath).then((destenation) => { return this.move(srcde, destenation, newDirName); }); }); @@ -897,11 +897,11 @@ export class File extends AwesomeCordovaNativePlugin { } return this.resolveDirectoryUrl(path) - .then(fse => { + .then((fse) => { return this.getDirectory(fse, dirName, { create: false }); }) - .then(srcde => { - return this.resolveDirectoryUrl(newPath).then(deste => { + .then((srcde) => { + return this.resolveDirectoryUrl(newPath).then((deste) => { return this.copy(srcde, deste, newDirName); }); }); @@ -923,13 +923,13 @@ export class File extends AwesomeCordovaNativePlugin { } return this.resolveDirectoryUrl(path) - .then(fse => { + .then((fse) => { return this.getDirectory(fse, dirName, { create: false, exclusive: false, }); }) - .then(de => { + .then((de) => { const reader = de.createReader(); return this.readEntries(reader); }); @@ -951,10 +951,10 @@ export class File extends AwesomeCordovaNativePlugin { } return this.resolveDirectoryUrl(path) - .then(fse => { + .then((fse) => { return this.getDirectory(fse, dirName, { create: false }); }) - .then(de => { + .then((de) => { return this.rimraf(de); }); } @@ -974,7 +974,7 @@ export class File extends AwesomeCordovaNativePlugin { return Promise.reject(err); } - return this.resolveLocalFilesystemUrl(path + file).then(fse => { + return this.resolveLocalFilesystemUrl(path + file).then((fse) => { if (fse.isFile) { return true; } else { @@ -1011,7 +1011,7 @@ export class File extends AwesomeCordovaNativePlugin { options.exclusive = true; } - return this.resolveDirectoryUrl(path).then(fse => { + return this.resolveDirectoryUrl(path).then((fse) => { return this.getFile(fse, fileName, options); }); } @@ -1032,10 +1032,10 @@ export class File extends AwesomeCordovaNativePlugin { } return this.resolveDirectoryUrl(path) - .then(fse => { + .then((fse) => { return this.getFile(fse, fileName, { create: false }); }) - .then(fe => { + .then((fe) => { return this.remove(fe); }); } @@ -1086,7 +1086,7 @@ export class File extends AwesomeCordovaNativePlugin { */ private writeFileEntry(fe: FileEntry, text: string | Blob | ArrayBuffer, options: IWriteOptions) { return this.createWriter(fe) - .then(writer => { + .then((writer) => { if (options.append) { writer.seek(writer.length); } @@ -1183,11 +1183,11 @@ export class File extends AwesomeCordovaNativePlugin { } return this.resolveDirectoryUrl(path) - .then(fse => { + .then((fse) => { return this.getFile(fse, fileName, { create: false }); }) - .then(srcfe => { - return this.resolveDirectoryUrl(newPath).then(deste => { + .then((srcfe) => { + return this.resolveDirectoryUrl(newPath).then((deste) => { return this.move(srcfe, deste, newFileName); }); }); @@ -1213,11 +1213,11 @@ export class File extends AwesomeCordovaNativePlugin { } return this.resolveDirectoryUrl(path) - .then(fse => { + .then((fse) => { return this.getFile(fse, fileName, { create: false }); }) - .then(srcfe => { - return this.resolveDirectoryUrl(newPath).then(deste => { + .then((srcfe) => { + return this.resolveDirectoryUrl(newPath).then((deste) => { return this.copy(srcfe, deste, newFileName); }); }); @@ -1246,7 +1246,7 @@ export class File extends AwesomeCordovaNativePlugin { (entry: Entry) => { resolve(entry); }, - err => { + (err) => { this.fillErrorMessage(err); reject(err); } @@ -1265,7 +1265,7 @@ export class File extends AwesomeCordovaNativePlugin { */ @CordovaCheck() resolveDirectoryUrl(directoryUrl: string): Promise { - return this.resolveLocalFilesystemUrl(directoryUrl).then(de => { + return this.resolveLocalFilesystemUrl(directoryUrl).then((de) => { if (de.isDirectory) { return de as DirectoryEntry; } else { @@ -1290,10 +1290,10 @@ export class File extends AwesomeCordovaNativePlugin { directoryEntry.getDirectory( directoryName, flags, - de => { + (de) => { resolve(de); }, - err => { + (err) => { this.fillErrorMessage(err); reject(err); } @@ -1316,7 +1316,7 @@ export class File extends AwesomeCordovaNativePlugin { getFile(directoryEntry: DirectoryEntry, fileName: string, flags: Flags): Promise { return new Promise((resolve, reject) => { try { - directoryEntry.getFile(fileName, flags, resolve, err => { + directoryEntry.getFile(fileName, flags, resolve, (err) => { this.fillErrorMessage(err); reject(err); }); @@ -1356,10 +1356,10 @@ export class File extends AwesomeCordovaNativePlugin { }; fileEntry.file( - file => { + (file) => { reader[`readAs${readAs}`].call(reader, file); }, - error => { + (error) => { reject(error); } ); @@ -1376,7 +1376,7 @@ export class File extends AwesomeCordovaNativePlugin { () => { resolve({ success: true, fileRemoved: fe }); }, - err => { + (err) => { this.fillErrorMessage(err); reject(err); } @@ -1392,10 +1392,10 @@ export class File extends AwesomeCordovaNativePlugin { srce.moveTo( destdir, newName, - deste => { + (deste) => { resolve(deste); }, - err => { + (err) => { this.fillErrorMessage(err); reject(err); } @@ -1411,10 +1411,10 @@ export class File extends AwesomeCordovaNativePlugin { srce.copyTo( destdir, newName, - deste => { + (deste) => { resolve(deste); }, - err => { + (err) => { this.fillErrorMessage(err); reject(err); } @@ -1428,10 +1428,10 @@ export class File extends AwesomeCordovaNativePlugin { private readEntries(dr: DirectoryReader): Promise { return new Promise((resolve, reject) => { dr.readEntries( - entries => { + (entries) => { resolve(entries); }, - err => { + (err) => { this.fillErrorMessage(err); reject(err); } @@ -1448,7 +1448,7 @@ export class File extends AwesomeCordovaNativePlugin { () => { resolve({ success: true, fileRemoved: de }); }, - err => { + (err) => { this.fillErrorMessage(err); reject(err); } @@ -1462,10 +1462,10 @@ export class File extends AwesomeCordovaNativePlugin { private createWriter(fe: FileEntry): Promise { return new Promise((resolve, reject) => { fe.createWriter( - writer => { + (writer) => { resolve(writer); }, - err => { + (err) => { this.fillErrorMessage(err); reject(err); } @@ -1482,7 +1482,7 @@ export class File extends AwesomeCordovaNativePlugin { } return new Promise((resolve, reject) => { - writer.onwriteend = evt => { + writer.onwriteend = (evt) => { if (writer.error) { reject(writer.error); } else { diff --git a/src/@awesome-cordova-plugins/plugins/hyper-track/index.ts b/src/@awesome-cordova-plugins/plugins/hyper-track/index.ts index 92a740f9..5acc0f60 100644 --- a/src/@awesome-cordova-plugins/plugins/hyper-track/index.ts +++ b/src/@awesome-cordova-plugins/plugins/hyper-track/index.ts @@ -165,8 +165,8 @@ export class HyperTrack { getDeviceId(): Promise { return new Promise((resolve, reject) => { this.cordovaInstanceHandle.getDeviceId( - deviceId => resolve(deviceId), - err => reject(err) + (deviceId) => resolve(deviceId), + (err) => reject(err) ); }); } @@ -175,8 +175,8 @@ export class HyperTrack { isRunning(): Promise { return new Promise((resolve, reject) => { this.cordovaInstanceHandle.isRunning( - isRunning => resolve(isRunning), - err => reject(err) + (isRunning) => resolve(isRunning), + (err) => reject(err) ); }); } @@ -187,7 +187,7 @@ export class HyperTrack { this.cordovaInstanceHandle.setDeviceName( name, () => resolve(), - err => reject(err) + (err) => reject(err) ); }); } @@ -201,7 +201,7 @@ export class HyperTrack { this.cordovaInstanceHandle.setDeviceMetadata( metadata, () => resolve(), - err => reject(err) + (err) => reject(err) ); }); } @@ -213,7 +213,7 @@ export class HyperTrack { title, message, () => resolve(), - err => reject(err) + (err) => reject(err) ); }); } @@ -225,7 +225,7 @@ export class HyperTrack { geotagData, expectedLocation, () => resolve(), - err => reject(err) + (err) => reject(err) ); }); } @@ -235,7 +235,7 @@ export class HyperTrack { return new Promise((resolve, reject) => { this.cordovaInstanceHandle.requestPermissionsIfNecessary( () => resolve(), - err => reject(err) + (err) => reject(err) ); }); } @@ -245,7 +245,7 @@ export class HyperTrack { return new Promise((resolve, reject) => { this.cordovaInstanceHandle.allowMockLocations( () => resolve(), - err => reject(err) + (err) => reject(err) ); }); } @@ -258,7 +258,7 @@ export class HyperTrack { return new Promise((resolve, reject) => { this.cordovaInstanceHandle.syncDeviceSettings( () => resolve(), - err => reject(err) + (err) => reject(err) ); }); } @@ -268,7 +268,7 @@ export class HyperTrack { return new Promise((resolve, reject) => { this.cordovaInstanceHandle.start( () => resolve(), - err => reject(err) + (err) => reject(err) ); }); } @@ -278,7 +278,7 @@ export class HyperTrack { return new Promise((resolve, reject) => { this.cordovaInstanceHandle.stop( () => resolve(), - err => reject(err) + (err) => reject(err) ); }); } diff --git a/src/@awesome-cordova-plugins/plugins/smartlook/index.ts b/src/@awesome-cordova-plugins/plugins/smartlook/index.ts index fff20a59..644aceeb 100644 --- a/src/@awesome-cordova-plugins/plugins/smartlook/index.ts +++ b/src/@awesome-cordova-plugins/plugins/smartlook/index.ts @@ -105,7 +105,7 @@ export class SmartlookEventTrackingModes { private eventTrackingModes: string[]; constructor(eventTrackingModes: SmartlookEventTrackingMode[]) { - this.eventTrackingModes = eventTrackingModes.map(eventTrackingMode => + this.eventTrackingModes = eventTrackingModes.map((eventTrackingMode) => eventTrackingMode.getEventTrackingModeString() ); } diff --git a/src/@awesome-cordova-plugins/plugins/web-socket-server/index.ts b/src/@awesome-cordova-plugins/plugins/web-socket-server/index.ts index 3249bac0..1b89ee83 100644 --- a/src/@awesome-cordova-plugins/plugins/web-socket-server/index.ts +++ b/src/@awesome-cordova-plugins/plugins/web-socket-server/index.ts @@ -133,7 +133,7 @@ export class WebSocketServer extends AwesomeCordovaNativePlugin { } private onFunctionToObservable(fnName: string) { - return new Observable(observer => { + return new Observable((observer) => { const id = window.cordova.plugins.wsserver[fnName](observer.next.bind(observer), observer.error.bind(observer)); return () => window.cordova.plugins.wsserver.removeCallback(id);