Skip to content

Commit 8c21571

Browse files
authored
chore: add eslint alongside prettier (#1403)
1 parent 7fedff7 commit 8c21571

File tree

6 files changed

+626
-17
lines changed

6 files changed

+626
-17
lines changed

.eslintrc.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module.exports = {
2+
env: {
3+
node: true
4+
},
5+
extends: [
6+
'prettier',
7+
'eslint:recommended',
8+
'plugin:@typescript-eslint/recommended'
9+
],
10+
parser: '@typescript-eslint/parser',
11+
parserOptions: {
12+
ecmaVersion: 'latest',
13+
sourceType: 'module'
14+
},
15+
plugins: ['prettier', '@typescript-eslint'],
16+
rules: {
17+
'prettier/prettier': ['error'],
18+
'@typescript-eslint/no-extra-semi': 'off',
19+
'no-restricted-imports': [
20+
'error',
21+
{
22+
patterns: ['src/*']
23+
}
24+
],
25+
26+
// Currently, disabled to avoid a lot of changes during migration
27+
'@typescript-eslint/no-explicit-any': 'off',
28+
'@typescript-eslint/no-non-null-assertion': 'off',
29+
'@typescript-eslint/no-unused-vars': 'off',
30+
'@typescript-eslint/ban-types': 'off',
31+
'@typescript-eslint/no-empty-function': 'off',
32+
'@typescript-eslint/ban-ts-comment': 'off',
33+
'prefer-const': 'off',
34+
'no-prototype-builtins': 'off'
35+
}
36+
}

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@
2222
"@types/jest": "27.4.1",
2323
"@types/node": "17.0.23",
2424
"@types/pretty": "^2.0.1",
25+
"@typescript-eslint/eslint-plugin": "^5.18.0",
26+
"@typescript-eslint/parser": "^5.18.0",
2527
"@vue/babel-plugin-jsx": "^1.1.1",
2628
"@vue/compat": "3.2.31",
2729
"@vue/compiler-dom": "3.2.31",
2830
"@vue/compiler-sfc": "3.2.31",
2931
"@vue/vue3-jest": "27.0.0-alpha.4",
3032
"babel-jest": "27.5.1",
3133
"babel-preset-jest": "27.5.1",
34+
"eslint": "^8.12.0",
35+
"eslint-config-prettier": "^8.5.0",
36+
"eslint-plugin-prettier": "^4.0.0",
3237
"husky": "^7.0.4",
3338
"jest": "27.5.1",
3439
"jsdom": "^19.0.0",
@@ -62,8 +67,8 @@
6267
"test:build": "yarn jest --runInBand tests/ -use-build",
6368
"tsd": "tsc -p test-dts/tsconfig.tsd.json",
6469
"build": "yarn rollup -c rollup.config.js",
65-
"lint": "prettier -c \"(src|tests)/**/*.(ts?(x)|vue)\"",
66-
"lint:fix": "yarn lint --write",
70+
"lint": "eslint --ext .ts src/ tests/",
71+
"lint:fix": "yarn lint --fix",
6772
"docs:dev": "vitepress dev docs",
6873
"docs:build": "vitepress build docs",
6974
"vue-tsc": "vue-tsc --noEmit -p tsconfig.volar.json",
@@ -76,7 +81,7 @@
7681
},
7782
"lint-staged": {
7883
"*.ts": [
79-
"prettier --parser=typescript --write"
84+
"eslint --fix"
8085
],
8186
"*.md": [
8287
"prettier --write"
@@ -97,5 +102,4 @@
97102
"url": "git+https://github.com/vuejs/test-utils.git"
98103
},
99104
"homepage": "https://github.com/vuejs/test-utils"
100-
101105
}

src/domWrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class DOMWrapper<NodeType extends Node> extends BaseWrapper<NodeType> {
6666
return results.filter((r: WrapperLike) => this.element.contains(r.element))
6767
}
6868

69-
private async setChecked(checked: boolean = true) {
69+
private async setChecked(checked = true) {
7070
// typecast so we get type safety
7171
const element = this.element as unknown as HTMLInputElement
7272
const type = this.attributes().type

src/stubs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ function createStubOnceForType(
141141

142142
export function stubComponents(
143143
stubs: Stubs = {},
144-
shallow: boolean = false,
145-
renderStubDefaultSlot: boolean = false
144+
shallow = false,
145+
renderStubDefaultSlot = false
146146
) {
147147
const createdStubsMap: WeakMap<{} & VNodeTypes, ConcreteComponent> =
148148
new WeakMap()

tests/features/classComponent.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('class component', () => {
5050
})
5151

5252
it('methods', () => {
53-
let msg: string = ''
53+
let msg = ''
5454

5555
class MyComp extends Vue {
5656
hello() {

0 commit comments

Comments
 (0)