Skip to content
This repository was archived by the owner on Jan 9, 2022. It is now read-only.

Commit 83e98a9

Browse files
committed
feat: setup eslint
1 parent 16bb4e1 commit 83e98a9

File tree

17 files changed

+1800
-137
lines changed

17 files changed

+1800
-137
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist
2+
node_modules
3+
public
4+
___

.eslintrc.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
module.exports = {
2+
overrides: [
3+
{
4+
files: ['*.vue'],
5+
parser: 'vue-eslint-parser',
6+
parserOptions: {
7+
parser: '@typescript-eslint/parser',
8+
},
9+
rules: {
10+
'no-unused-vars': 'off',
11+
'no-undef': 'off',
12+
'@typescript-eslint/no-unused-vars': 'off',
13+
},
14+
},
15+
],
16+
17+
extends: [
18+
'plugin:vue/vue3-recommended',
19+
'plugin:vue-scoped-css/vue3-recommended',
20+
'plugin:import/recommended',
21+
'./eslint/typescript.js',
22+
],
23+
24+
rules: {
25+
'vue/html-self-closing': 'warn',
26+
'vue/padding-line-between-blocks': 'error',
27+
28+
'vue/max-attributes-per-line': ['warn', {
29+
singleline: 2,
30+
}],
31+
32+
'vue/component-name-in-template-casing': [
33+
'warn',
34+
'PascalCase',
35+
{
36+
registeredComponentsOnly: false,
37+
},
38+
],
39+
40+
semi: ['warn', 'never'],
41+
'linebreak-style': ['off'],
42+
'import/no-unresolved': ['off'],
43+
'import/prefer-default-export': ['off'],
44+
45+
'no-plusplus': ['error', {
46+
allowForLoopAfterthoughts: true,
47+
}],
48+
49+
'no-multi-spaces': ['error', {
50+
ignoreEOLComments: false,
51+
}],
52+
53+
'object-curly-newline': ['error', {
54+
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
55+
ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
56+
ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
57+
ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
58+
}],
59+
60+
'comma-spacing': ['error', { before: false, after: true }],
61+
62+
'comma-dangle': ['error', {
63+
arrays: 'always-multiline',
64+
objects: 'always-multiline',
65+
imports: 'always-multiline',
66+
exports: 'always-multiline',
67+
functions: 'always-multiline',
68+
}],
69+
70+
'no-trailing-spaces': ['error', {
71+
skipBlankLines: false,
72+
ignoreComments: false,
73+
}],
74+
75+
"import/newline-after-import": ["error", { "count": 1 }],
76+
77+
'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
78+
},
79+
80+
settings: {
81+
'import/resolver': {
82+
node: {
83+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
84+
},
85+
},
86+
},
87+
}

eslint/typescript.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module.exports = {
2+
extends: [
3+
'plugin:@typescript-eslint/recommended',
4+
],
5+
rules: {
6+
// TS
7+
'no-useless-constructor': 'off',
8+
'@typescript-eslint/semi': ['error', 'never'],
9+
'@typescript-eslint/member-delimiter-style': ['error', { multiline: { delimiter: 'none' } }],
10+
'@typescript-eslint/type-annotation-spacing': ['error', {}],
11+
12+
indent: 'off',
13+
'@typescript-eslint/indent': ['error', 2],
14+
'no-unused-vars': 'off',
15+
'@typescript-eslint/no-unused-vars': 'error',
16+
'no-redeclare': 'off',
17+
'@typescript-eslint/no-redeclare': 'error',
18+
19+
// off
20+
'@typescript-eslint/camelcase': 'off',
21+
'@typescript-eslint/explicit-function-return-type': 'off',
22+
'@typescript-eslint/explicit-member-accessibility': 'off',
23+
'@typescript-eslint/no-explicit-any': 'off',
24+
'@typescript-eslint/no-parameter-properties': 'off',
25+
'@typescript-eslint/no-empty-interface': 'off',
26+
'@typescript-eslint/ban-ts-ignore': 'off',
27+
'@typescript-eslint/no-empty-function': 'off',
28+
'@typescript-eslint/no-non-null-assertion': 'off',
29+
'@typescript-eslint/ban-ts-comment': 'off',
30+
'@typescript-eslint/explicit-module-boundary-types': 'off',
31+
'@typescript-eslint/ban-types': 'off',
32+
},
33+
}

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@
2525
"devDependencies": {
2626
"@types/body-scroll-lock": "^2.6.2",
2727
"@types/node": "^16.3.1",
28+
"@typescript-eslint/eslint-plugin": "^4.28.4",
29+
"@typescript-eslint/parser": "^4.28.4",
2830
"@vitejs/plugin-vue": "^1.2.4",
2931
"@vue/compiler-sfc": "^3.0.5",
32+
"eslint": "^7.31.0",
33+
"eslint-plugin-import": "^2.23.4",
34+
"eslint-plugin-vue": "^7.14.0",
35+
"eslint-plugin-vue-scoped-css": "^1.2.2",
3036
"sass": "^1.35.2",
3137
"typescript": "^4.3.2",
3238
"vite": "^2.4.0",

src/App.vue

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
</div>
1818
</GDialog>
1919

20-
<GDialog v-model="dialogState2" max-width="400" scrollable>
20+
<GDialog
21+
v-model="dialogState2"
22+
max-width="400"
23+
scrollable
24+
>
2125
<div class="text-box scrollable">
2226
<div>
2327
Header
@@ -36,11 +40,17 @@
3640
</div>
3741
</GDialog>
3842

39-
<button @click="onClick">Simple</button>
40-
<hr />
41-
<button @click="dialogState2 = true">Scrollable</button>
42-
<hr />
43-
<button @click="onOpenBoth">both</button>
43+
<button @click="onClick">
44+
Simple
45+
</button>
46+
<hr>
47+
<button @click="dialogState2 = true">
48+
Scrollable
49+
</button>
50+
<hr>
51+
<button @click="onOpenBoth">
52+
both
53+
</button>
4454
</div>
4555
</template>
4656

@@ -51,8 +61,8 @@ import QLib from '@/gitart-vue-dialog/index'
5161
5262
export default defineComponent({
5363
name: 'App',
54-
components: {
55-
GDialog: QLib.GDialog
64+
components: {
65+
GDialog: QLib.GDialog,
5666
},
5767
5868
data: () => ({
@@ -62,15 +72,15 @@ export default defineComponent({
6272
6373
methods: {
6474
onClick() {
65-
console.log('set true');
66-
this.dialogState = true;
75+
console.log('set true')
76+
this.dialogState = true
6777
},
6878
onOpenBoth() {
69-
console.log('set true');
70-
this.dialogState = true;
79+
console.log('set true')
80+
this.dialogState = true
7181
setTimeout(() => {
72-
this.dialogState2 = true;
73-
}, 2200);
82+
this.dialogState2 = true
83+
}, 2200)
7484
},
7585
},
7686
})

src/gitart-vue-dialog/components/GDialog.vue

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22
<template v-if="activatedOnce">
33
<Teleport to="body">
44
<GDialogOverlay
5-
@click="onClickOutside"
65
:active="isActive"
76
:deactivating="deactivating"
8-
:activeZIndex="activeZIndex"
7+
:active-z-index="activeZIndex"
8+
@click="onClickOutside"
99
/>
1010

1111
<Transition name="dialog-transition">
12-
<div ref="frame" v-show="isActive" :class="classes" :style="styles">
12+
<div
13+
v-show="isActive"
14+
ref="frame"
15+
:class="classes"
16+
:style="styles"
17+
>
1318
<GDialogContent
1419
:width="width"
15-
:maxWidth="maxWidth"
20+
:max-width="maxWidth"
1621
:scrollable="scrollable"
1722
>
1823
<slot />
@@ -24,13 +29,13 @@
2429
</template>
2530

2631
<script lang="ts">
27-
import { defineComponent, computed, ref } from 'vue';
32+
import { defineComponent, computed, ref } from 'vue'
2833
29-
import { useStackable } from '../composable/stackable';
30-
import { useLazyActivation } from '../composable/lazyActivation';
34+
import { useStackable } from '../composable/stackable'
35+
import { useLazyActivation } from '../composable/lazyActivation'
3136
32-
import GDialogOverlay from './GDialogOverlay.vue';
33-
import GDialogContent from './GDialogContent.vue';
37+
import GDialogOverlay from './GDialogOverlay.vue'
38+
import GDialogContent from './GDialogContent.vue'
3439
3540
export default defineComponent({
3641
name: 'GDialog',
@@ -85,35 +90,37 @@ export default defineComponent({
8590
},
8691
},
8792
93+
emits: ['update:modelValue'],
94+
8895
setup(props, { emit }) {
8996
const onClickOutside = () => {
9097
if (!props.persistent) {
91-
emit('update:modelValue', false);
98+
emit('update:modelValue', false)
9299
}
93-
};
100+
}
94101
95102
const { activatedOnce, active: isActive, deactivating } = useLazyActivation(
96-
computed(() => props.modelValue)
97-
);
103+
computed(() => props.modelValue),
104+
)
98105
99-
const frame = ref(null);
106+
const frame = ref(null)
100107
const { activeZIndex } = useStackable({
101108
activeElSelector: '.q-dialog-frame--active',
102109
stackMinZIndex: 200,
103110
isActive,
104111
content: frame,
105-
});
112+
})
106113
107114
const classes = computed(() => [
108115
'q-dialog-frame',
109116
{
110117
'q-dialog-frame--active': isActive,
111118
},
112-
]);
119+
])
113120
114121
const styles = computed(() => ({
115122
zIndex: activeZIndex.value,
116-
}));
123+
}))
117124
118125
return {
119126
onClickOutside,
@@ -124,9 +131,9 @@ export default defineComponent({
124131
classes,
125132
styles,
126133
frame,
127-
};
134+
}
128135
},
129-
});
136+
})
130137
</script>
131138

132139
<style lang="scss" scoped>

src/gitart-vue-dialog/components/GDialogContent.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</template>
66

77
<script lang="ts">
8-
import { computed, defineComponent } from 'vue';
9-
import { useWidthStyle } from '../composable/widthStyle';
8+
import { computed, defineComponent } from 'vue'
9+
import { useWidthStyle } from '../composable/widthStyle'
1010
1111
export default defineComponent({
1212
name: 'GDialogContent',
@@ -28,20 +28,20 @@ export default defineComponent({
2828
},
2929
3030
setup(props) {
31-
const { widthStyles: styles } = useWidthStyle(props);
31+
const { widthStyles: styles } = useWidthStyle(props)
3232
const classes = computed(() => [
3333
'q-dialog-content',
3434
{
3535
'q-dialog-content--scrollable': props.scrollable,
3636
},
37-
]);
37+
])
3838
3939
return {
4040
styles,
4141
classes,
42-
};
42+
}
4343
},
44-
});
44+
})
4545
</script>
4646

4747
<style lang="scss" scoped>

0 commit comments

Comments
 (0)