Skip to content

Commit 5aba6a4

Browse files
feat($ESLint): improve ESLint rules
1 parent ba1ee28 commit 5aba6a4

File tree

7 files changed

+133
-71
lines changed

7 files changed

+133
-71
lines changed

.editorconfig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
[*.{js,jsx,ts,tsx,vue}]
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
26
indent_style = space
37
indent_size = 2
4-
trim_trailing_whitespace = true
8+
end_of_line = lf
59
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
insert_final_newline = false
14+
trim_trailing_whitespace = false

.eslintrc.js

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,53 @@
11
module.exports = {
22
root: true,
33
env: {
4+
es6: true,
45
node: true
56
},
67
'extends': [
78
'plugin:vue/essential',
9+
// 'plugin:vue/recommended',
810
'@vue/standard',
9-
'@vue/typescript'
11+
'@vue/typescript',
12+
'plugin:@typescript-eslint/eslint-recommended'
1013
],
14+
plugins: ['vue-libs'],
1115
rules: {
1216
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
13-
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
17+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
18+
19+
'space-before-function-paren': [
20+
2,
21+
'always'
22+
],
23+
24+
'indent': 'off',
25+
'@typescript-eslint/indent': ['error', 2],
26+
27+
'@typescript-eslint/member-delimiter-style': ['error', {
28+
multiline: {
29+
'delimiter': 'none',
30+
'requireLast': false
31+
},
32+
singleline: {
33+
'delimiter': 'semi',
34+
'requireLast': false
35+
}
36+
}],
37+
38+
'semi': 'off',
39+
'@typescript-eslint/semi': ['error', 'never'],
40+
41+
'prefer-const': 2,
42+
'object-curly-spacing': [2, 'always', { objectsInObjects: false }],
43+
'array-bracket-spacing': [2, 'never'],
44+
'vue-libs/jsx-uses-vars': 2,
45+
'vue/require-v-for-key': 0
1446
},
1547
parserOptions: {
16-
parser: '@typescript-eslint/parser'
48+
parser: '@typescript-eslint/parser',
49+
ecmaVersion: 2020,
50+
sourceType: 'module'
1751
},
1852
overrides: [
1953
{

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"serve": "vue-cli-service serve",
77
"build": "vue-cli-service build",
88
"test:unit": "vue-cli-service test:unit",
9-
"lint": "vue-cli-service lint"
9+
"lint": "vue-cli-service lint --ext .ts,.js,.vue src"
1010
},
1111
"dependencies": {
1212
"@mdi/font": "4.7.95",
@@ -21,6 +21,8 @@
2121
},
2222
"devDependencies": {
2323
"@types/jest": "^24.0.19",
24+
"@typescript-eslint/eslint-plugin": "2.13.0",
25+
"@typescript-eslint/parser": "2.13.0",
2426
"@vue/cli-plugin-babel": "^4.1.0",
2527
"@vue/cli-plugin-eslint": "^4.1.0",
2628
"@vue/cli-plugin-router": "^4.1.0",
@@ -31,11 +33,12 @@
3133
"@vue/eslint-config-standard": "^4.0.0",
3234
"@vue/eslint-config-typescript": "^4.0.0",
3335
"@vue/test-utils": "1.0.0-beta.29",
34-
"eslint": "^5.16.0",
35-
"eslint-plugin-vue": "^5.0.0",
36+
"babel-eslint": "10.0.3",
37+
"eslint": "6.8.0",
38+
"eslint-plugin-vue": "6.0.2",
39+
"eslint-plugin-vue-libs": "4.0.0",
3640
"lint-staged": "^9.4.3",
37-
"node-sass": "^4.12.0",
38-
"sass": "^1.19.0",
41+
"sass": "1.24.0",
3942
"sass-loader": "^8.0.0",
4043
"typescript": "~3.5.3",
4144
"vue-cli-plugin-vuetify": "^2.0.2",

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</v-btn>
1616
</v-app-bar>
1717
<v-content>
18-
<HelloWorld/>
18+
<hello-world/>
1919
</v-content>
2020
</v-app>
2121
</template>

src/components/HelloWorld.vue

Lines changed: 67 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -41,63 +41,74 @@
4141
</v-container>
4242
</template>
4343

44+
<!--
4445
<script lang="ts">
45-
import Vue from 'vue'
46+
import { Component, Prop, Vue } from 'vue-property-decorator'
4647
47-
export default Vue.extend({
48-
name: 'HelloWorld',
48+
@Component
49+
export default class HelloWorld extends Vue {
50+
@Prop() private msg!: string;
51+
}
52+
</script>
53+
-->
54+
55+
<script lang="ts">
56+
import { Component, Vue } from 'vue-property-decorator'
57+
58+
@Component
59+
export default class HelloWorld extends Vue {
60+
private ecosystem: object = [
61+
{
62+
text: 'vuetify-loader',
63+
href: 'https://github.com/vuetifyjs/vuetify-loader'
64+
},
65+
{
66+
text: 'github',
67+
href: 'https://github.com/vuetifyjs/vuetify'
68+
},
69+
{
70+
text: 'awesome-vuetify',
71+
href: 'https://github.com/vuetifyjs/awesome-vuetify'
72+
}
73+
]
74+
private importantLinks = [
75+
{
76+
text: 'Documentation',
77+
href: 'https://vuetifyjs.com'
78+
},
79+
{
80+
text: 'Chat',
81+
href: 'https://community.vuetifyjs.com'
82+
},
83+
{
84+
text: 'Made with Vuetify',
85+
href: 'https://madewithvuejs.com/vuetify'
86+
},
87+
{
88+
text: 'Twitter',
89+
href: 'https://twitter.com/vuetifyjs'
90+
},
91+
{
92+
text: 'Articles',
93+
href: 'https://medium.com/vuetify'
94+
}
95+
]
96+
private whatsNext = [
97+
{
98+
text: 'Explore components',
99+
href: 'https://vuetifyjs.com/components/api-explorer'
100+
},
101+
{
102+
text: 'Select a layout',
103+
href: 'https://vuetifyjs.com/layout/pre-defined'
104+
},
105+
{
106+
text: 'Frequently Asked Questions',
107+
href: 'https://vuetifyjs.com/getting-started/frequently-asked-questions'
108+
}
109+
]
49110
50-
data: () => ({
51-
ecosystem: [
52-
{
53-
text: 'vuetify-loader',
54-
href: 'https://github.com/vuetifyjs/vuetify-loader'
55-
},
56-
{
57-
text: 'github',
58-
href: 'https://github.com/vuetifyjs/vuetify'
59-
},
60-
{
61-
text: 'awesome-vuetify',
62-
href: 'https://github.com/vuetifyjs/awesome-vuetify'
63-
}
64-
],
65-
importantLinks: [
66-
{
67-
text: 'Documentation',
68-
href: 'https://vuetifyjs.com'
69-
},
70-
{
71-
text: 'Chat',
72-
href: 'https://community.vuetifyjs.com'
73-
},
74-
{
75-
text: 'Made with Vuetify',
76-
href: 'https://madewithvuejs.com/vuetify'
77-
},
78-
{
79-
text: 'Twitter',
80-
href: 'https://twitter.com/vuetifyjs'
81-
},
82-
{
83-
text: 'Articles',
84-
href: 'https://medium.com/vuetify'
85-
}
86-
],
87-
whatsNext: [
88-
{
89-
text: 'Explore components',
90-
href: 'https://vuetifyjs.com/components/api-explorer'
91-
},
92-
{
93-
text: 'Select a layout',
94-
href: 'https://vuetifyjs.com/layout/pre-defined'
95-
},
96-
{
97-
text: 'Frequently Asked Questions',
98-
href: 'https://vuetifyjs.com/getting-started/frequently-asked-questions'
99-
}
100-
]
101-
})
102-
})
111+
mounted () {
112+
}
113+
}
103114
</script>

src/shims-tsx.d.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
// eslint-disable-next-line no-unused-vars
12
import Vue, { VNode } from 'vue'
23

34
declare global {
45
namespace JSX {
6+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
7+
interface Element extends VNode {
8+
}
9+
510
// tslint:disable no-empty-interface
6-
interface Element extends VNode {}
7-
// tslint:disable no-empty-interface
8-
interface ElementClass extends Vue {}
11+
interface ElementClass extends Vue {
12+
}
13+
914
interface IntrinsicElements {
1015
[elem: string]: any
1116
}

src/views/Home.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="home">
33
<img alt="Vue logo" src="../assets/logo.png">
4-
<HelloWorld msg="Welcome to Your Vue.js App"/>
4+
<hello-world msg="Welcome to Your Vue.js App"/>
55
</div>
66
</template>
77

0 commit comments

Comments
 (0)