Skip to content

Commit

Permalink
chore:2 space indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
avil13 committed Sep 21, 2020
1 parent 5bfe9ad commit b1020dc
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 92 deletions.
92 changes: 46 additions & 46 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
module.exports = {
printWidth: 90,
tabWidth: 4,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'all',
bracketSpacing: false,
arrowParens: 'avoid',
overrides: [
{
files: '*.js',
options: {
parser: 'babel',
},
},
{
files: '*.ts',
options: {
parser: 'typescript',
},
},
{
files: '*.md',
options: {
parser: 'markdown',
},
},
{
files: '*.json',
options: {
parser: 'json',
},
},
{
files: '.prettierrc',
options: {
parser: 'json',
},
},
{
files: '.stylelintrc',
options: {
parser: 'json',
},
},
],
printWidth: 90,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'all',
bracketSpacing: false,
arrowParens: 'avoid',
overrides: [
{
files: '*.js',
options: {
parser: 'babel',
},
},
{
files: '*.ts',
options: {
parser: 'typescript',
},
},
{
files: '*.md',
options: {
parser: 'markdown',
},
},
{
files: '*.json',
options: {
parser: 'json',
},
},
{
files: '.prettierrc',
options: {
parser: 'json',
},
},
{
files: '.stylelintrc',
options: {
parser: 'json',
},
},
],
};
72 changes: 36 additions & 36 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,47 @@ import Swal, {SweetAlertOptions, SweetAlertResult} from 'sweetalert2';
type TVueSwalInstance = typeof Swal & typeof Swal.fire;

declare module 'vue/types/vue' {
interface Vue {
$swal: TVueSwalInstance;
}
interface Vue {
$swal: TVueSwalInstance;
}

interface VueConstructor<V extends Vue = Vue> {
swal: TVueSwalInstance;
}
interface VueConstructor<V extends Vue = Vue> {
swal: TVueSwalInstance;
}
}

class VueSweetalert2 {
static install(vue: Vue | any, options?: SweetAlertOptions): void {
const swalLocalInstance = options ? Swal.mixin(options) : Swal;

const swalFunction = (...args: [SweetAlertOptions]) => {
return swalLocalInstance.fire.call(swalLocalInstance, ...args);
};

let methodName: string | number | symbol;

for (methodName in swalLocalInstance) {
if (
Object.prototype.hasOwnProperty.call(swalLocalInstance, methodName) &&
typeof swalLocalInstance[methodName] === 'function'
) {
swalFunction[methodName] = (method => {
return (...args: any[]) => {
return swalLocalInstance[method].call(swalLocalInstance, ...args);
};
})(methodName);
}
}

vue['swal'] = swalFunction;

// add the instance method
if (!Object.prototype.hasOwnProperty.call(vue, '$swal')) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
vue.prototype.$swal = swalFunction;
}
static install(vue: Vue | any, options?: SweetAlertOptions): void {
const swalLocalInstance = options ? Swal.mixin(options) : Swal;

const swalFunction = (...args: [SweetAlertOptions]) => {
return swalLocalInstance.fire.call(swalLocalInstance, ...args);
};

let methodName: string | number | symbol;

for (methodName in swalLocalInstance) {
if (
Object.prototype.hasOwnProperty.call(swalLocalInstance, methodName) &&
typeof swalLocalInstance[methodName] === 'function'
) {
swalFunction[methodName] = (method => {
return (...args: any[]) => {
return swalLocalInstance[method].call(swalLocalInstance, ...args);
};
})(methodName);
}
}

vue['swal'] = swalFunction;

// add the instance method
if (!Object.prototype.hasOwnProperty.call(vue, '$swal')) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
vue.prototype.$swal = swalFunction;
}
}
}

export default VueSweetalert2;
16 changes: 8 additions & 8 deletions src/shims-tsx.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Vue, {VNode} from 'vue';

declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any;
}
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any;
}
}
}
4 changes: 2 additions & 2 deletions src/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module '*.vue' {
import Vue from 'vue';
export default Vue;
import Vue from 'vue';
export default Vue;
}

0 comments on commit b1020dc

Please sign in to comment.