Skip to content

Commit de5cd9b

Browse files
authored
chore: add eslint (#282)
* chore: add eslint * chore: lint on ci
1 parent d45b38c commit de5cd9b

File tree

19 files changed

+913
-62
lines changed

19 files changed

+913
-62
lines changed

.circleci/config.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ jobs:
3939
at: ~/
4040
- run: yarn example
4141

42+
lint:
43+
<<: *defaults
44+
steps:
45+
- attach_workspace:
46+
at: ~/
47+
- run: yarn lint
48+
4249
test:
4350
<<: *defaults
4451
steps:
@@ -57,6 +64,9 @@ workflows:
5764
- example-build:
5865
requires:
5966
- install
67+
- lint:
68+
requires:
69+
- install
6070
- test:
6171
requires:
6272
- install

.eslintignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/dist/
2+
/lib/
3+
node_modules/
4+
5+
/test/test.build.js
6+
/example/build.js
7+
8+
# TOOD: remove after fixed decorator indent issue
9+
# https://github.com/eslint/typescript-eslint-parser/issues/438
10+
/example
11+
/test

.eslintrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
root: true,
3+
extends: ['plugin:vue-libs/recommended'],
4+
parserOptions: {
5+
parser: 'typescript-eslint-parser'
6+
},
7+
rules: {
8+
'no-unused-vars': 'off',
9+
'no-undef': 'off'
10+
}
11+
}

build/dev-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fs.watch('test/test.build.js', () => {
88
run('mocha --reporter min test/test.build.js')
99
})
1010

11-
function run(command) {
11+
function run (command) {
1212
const [name, ...args] = command.split(' ')
1313
spawn(`node_modules/.bin/${name}`, args, {
1414
shell: true,

example/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default class App extends AppProps {
8282
}
8383
8484
// direct dispatch example
85-
incrementIfOdd() {
85+
incrementIfOdd () {
8686
this.$store.dispatch('incrementIfOdd')
8787
}
8888
}

example/src/components/Hello.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
</template>
44

55
<script lang="ts">
6-
import Vue from 'vue'
7-
import Component from '../../../lib/index'
6+
import Vue from 'vue'
7+
import Component from '../../../lib/index'
88
9-
@Component
10-
export default class Hello extends Vue {
11-
helloTimes: number = 0
9+
@Component
10+
export default class Hello extends Vue {
11+
helloTimes: number = 0
1212
13-
sayHello () {
14-
this.helloTimes++
15-
}
13+
sayHello () {
14+
this.helloTimes++
1615
}
16+
}
1717
</script>
1818

example/src/components/World.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Component from '../../../lib/index'
33

44
@Component
55
export default class World extends Vue {
6-
render(h: CreateElement) {
6+
render (h: CreateElement) {
77
return <p>This is rendered via TSX</p>
88
}
99
}

example/src/shims-tsx.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Vue, { VNode } from "vue"
1+
import Vue, { VNode } from 'vue'
22

33
declare global {
44
namespace JSX {

example/src/store.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from 'vue'
2-
import Vuex from "vuex"
2+
import Vuex from 'vuex'
33

4-
interface CounterState{
4+
interface CounterState {
55
count: number
66
}
77

@@ -20,4 +20,4 @@ const mutations = {
2020
export default new Vuex.Store({
2121
state,
2222
mutations
23-
})
23+
})

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"example": "npm run build && webpack --config example/webpack.config.js",
1717
"dev": "webpack --config example/webpack.config.js --watch",
1818
"dev:test": "node build/dev-test.js",
19+
"lint": "eslint --ext js,jsx,ts,tsx,vue .",
1920
"test": "npm run build && webpack --config test/webpack.config.js && mocha test/test.build.js",
2021
"release": "bash build/release.sh"
2122
},
@@ -48,6 +49,8 @@
4849
"babel-plugin-transform-vue-jsx": "^4.0.1",
4950
"chai": "^4.1.2",
5051
"css-loader": "^1.0.0",
52+
"eslint": "^5.7.0",
53+
"eslint-plugin-vue-libs": "^3.0.0",
5154
"mocha": "^5.0.1",
5255
"reflect-metadata": "^0.1.12",
5356
"rimraf": "^2.6.2",
@@ -56,6 +59,7 @@
5659
"testdouble": "^3.5.0",
5760
"ts-loader": "^5.2.1",
5861
"typescript": "^3.1.1",
62+
"typescript-eslint-parser": "^20.0.0",
5963
"uglify-js": "^3.3.10",
6064
"vue": "^2.5.13",
6165
"vue-loader": "^15.4.2",

0 commit comments

Comments
 (0)