Skip to content

Commit

Permalink
chore: add eslint alongside prettier (vuejs#1403)
Browse files Browse the repository at this point in the history
  • Loading branch information
freakzlike authored Apr 8, 2022
1 parent 7fedff7 commit 8c21571
Show file tree
Hide file tree
Showing 6 changed files with 626 additions and 17 deletions.
36 changes: 36 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
env: {
node: true
},
extends: [
'prettier',
'eslint:recommended',
'plugin:@typescript-eslint/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: ['prettier', '@typescript-eslint'],
rules: {
'prettier/prettier': ['error'],
'@typescript-eslint/no-extra-semi': 'off',
'no-restricted-imports': [
'error',
{
patterns: ['src/*']
}
],

// Currently, disabled to avoid a lot of changes during migration
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'prefer-const': 'off',
'no-prototype-builtins': 'off'
}
}
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@
"@types/jest": "27.4.1",
"@types/node": "17.0.23",
"@types/pretty": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.18.0",
"@vue/babel-plugin-jsx": "^1.1.1",
"@vue/compat": "3.2.31",
"@vue/compiler-dom": "3.2.31",
"@vue/compiler-sfc": "3.2.31",
"@vue/vue3-jest": "27.0.0-alpha.4",
"babel-jest": "27.5.1",
"babel-preset-jest": "27.5.1",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"jest": "27.5.1",
"jsdom": "^19.0.0",
Expand Down Expand Up @@ -62,8 +67,8 @@
"test:build": "yarn jest --runInBand tests/ -use-build",
"tsd": "tsc -p test-dts/tsconfig.tsd.json",
"build": "yarn rollup -c rollup.config.js",
"lint": "prettier -c \"(src|tests)/**/*.(ts?(x)|vue)\"",
"lint:fix": "yarn lint --write",
"lint": "eslint --ext .ts src/ tests/",
"lint:fix": "yarn lint --fix",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"vue-tsc": "vue-tsc --noEmit -p tsconfig.volar.json",
Expand All @@ -76,7 +81,7 @@
},
"lint-staged": {
"*.ts": [
"prettier --parser=typescript --write"
"eslint --fix"
],
"*.md": [
"prettier --write"
Expand All @@ -97,5 +102,4 @@
"url": "git+https://github.com/vuejs/test-utils.git"
},
"homepage": "https://github.com/vuejs/test-utils"

}
2 changes: 1 addition & 1 deletion src/domWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class DOMWrapper<NodeType extends Node> extends BaseWrapper<NodeType> {
return results.filter((r: WrapperLike) => this.element.contains(r.element))
}

private async setChecked(checked: boolean = true) {
private async setChecked(checked = true) {
// typecast so we get type safety
const element = this.element as unknown as HTMLInputElement
const type = this.attributes().type
Expand Down
4 changes: 2 additions & 2 deletions src/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ function createStubOnceForType(

export function stubComponents(
stubs: Stubs = {},
shallow: boolean = false,
renderStubDefaultSlot: boolean = false
shallow = false,
renderStubDefaultSlot = false
) {
const createdStubsMap: WeakMap<{} & VNodeTypes, ConcreteComponent> =
new WeakMap()
Expand Down
2 changes: 1 addition & 1 deletion tests/features/classComponent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('class component', () => {
})

it('methods', () => {
let msg: string = ''
let msg = ''

class MyComp extends Vue {
hello() {
Expand Down
Loading

0 comments on commit 8c21571

Please sign in to comment.