chore: upgrade eslint config

This commit is contained in:
mutoe 2024-08-09 10:11:30 +08:00
parent 46b92e7caf
commit 484c4f7337
No known key found for this signature in database
11 changed files with 794 additions and 396 deletions

View File

@ -49,7 +49,7 @@ describe('auth', () => {
cy.get('[type="password"]').type('123456')
cy.get('[type="submit"]').click()
cy.get('form').then(($el) => {
cy.get('form').then($el => {
cy.wrap($el[0].checkValidity()).should('to.be', false)
})
})

View File

@ -10,8 +10,8 @@ describe('favorite', () => {
cy.intercept('POST', /articles\/\S+\/favorite$/, { statusCode: 401, body: {} }).as('favoriteArticle')
cy.visit(ROUTES.HOME)
Cypress.on('uncaught:exception', (err) => {
expect(err.message).to.contain('Need to login')
Cypress.on('uncaught:exception', error => {
expect(error.message).to.contain('Need to login')
return false
})
cy.get('i.ion-heart:first').click()

View File

@ -5,7 +5,7 @@ describe('follow', () => {
cy.intercept('GET', /articles\?/, { fixture: 'articles.json' }).as('getArticles')
cy.intercept('GET', /tags/, { fixture: 'tags.json' }).as('getTags')
cy.intercept('GET', /profiles\/\S+/, { fixture: 'profile.json' }).as('getProfile')
cy.fixture('article.json').then((article) => {
cy.fixture('article.json').then(article => {
article.article.author.username = 'foo'
cy.intercept('GET', /articles\/\S+/, { statusCode: 200, body: article }).as('getArticle')
})
@ -21,7 +21,7 @@ describe('follow', () => {
})
it('should call follow user api when click follow user button', () => {
cy.fixture('profile.json').then((profile) => {
cy.fixture('profile.json').then(profile => {
profile.profile.following = true
cy.intercept('POST', /profiles\/\S+\/follow/, { statusCode: 200, body: profile }).as('followUser')
})

View File

@ -31,7 +31,7 @@ describe('tag', () => {
.should('have.class', 'router-link-active')
.should('have.class', 'router-link-exact-active')
cy.get('a.tag-pill.tag-default:last').invoke('text').then((tag) => {
cy.get('a.tag-pill.tag-default:last').invoke('text').then(tag => {
const path = `#/tag/${tag}`
cy.url()

View File

@ -29,7 +29,7 @@ declare global {
}
Cypress.Commands.add('login', (username = 'plumrx') => {
cy.fixture('user.json').then((authResponse) => {
cy.fixture('user.json').then(authResponse => {
authResponse.user.username = username
cy.intercept('POST', /users\/login$/, { statusCode: 200, body: authResponse })
})

View File

@ -16,9 +16,15 @@ export default defineConfig({
},
},
test: {
vitest: true,
cypress: true,
},
ignores: [
'src/services/api.ts',
],
}, {
files: ['cypress/support/**/*.ts'],
rules: {
'ts/method-signature-style': 'off',
},
})

View File

@ -18,13 +18,6 @@
"test:unit": "vitest run",
"generate:api": "curl -sL https://raw.githubusercontent.com/gothinkster/realworld/main/api/openapi.yml -o ./src/services/openapi.yml && sta -p ./src/services/openapi.yml -o ./src/services -n api.ts"
},
"simple-git-hooks": {
"pre-commit": "npm exec lint-staged",
"pre-push": "npm run lint && npm run build"
},
"lint-staged": {
"*": "eslint --fix"
},
"dependencies": {
"insane": "^2.6.2",
"marked": "^12.0.0",
@ -33,7 +26,7 @@
"vue-router": "^4.3.0"
},
"devDependencies": {
"@mutoe/eslint-config": "^2.4.5",
"@mutoe/eslint-config": "^2.8.3",
"@pinia/testing": "^0.1.3",
"@testing-library/cypress": "^10.0.1",
"@testing-library/user-event": "^14.5.1",
@ -42,8 +35,10 @@
"@vitest/coverage-v8": "^1.0.4",
"concurrently": "^8.2.2",
"cypress": "^13.6.0",
"eslint": "^8.54.0",
"eslint-plugin-cypress": "^2.15.1",
"eslint": "^8.57.0",
"eslint-plugin-cypress": "^3.4.0",
"eslint-plugin-vitest": "^0.5.4",
"eslint-plugin-vue": "^9.27.0",
"happy-dom": "^12.10.3",
"lint-staged": "^15.2.0",
"msw": "^2.0.11",
@ -55,5 +50,12 @@
"vitest": "^1.0.4",
"vitest-dom": "^0.1.1",
"vue-tsc": "^1.8.25"
},
"simple-git-hooks": {
"pre-commit": "npm exec lint-staged",
"pre-push": "npm run lint && npm run build"
},
"lint-staged": {
"*": "eslint --fix"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -109,7 +109,7 @@ function useArticlesMeta(): UseArticlesMetaReturn {
watch(
() => route.name,
(routeName) => {
routeName => {
const possibleArticlesType = routeNameToArticlesType[routeName as AppRouteNames]
if (!isArticlesType(possibleArticlesType))
return
@ -121,7 +121,7 @@ function useArticlesMeta(): UseArticlesMetaReturn {
watch(
() => route.params.username,
(usernameParam) => {
usernameParam => {
if (usernameParam !== username.value)
username.value = typeof usernameParam === 'string' ? usernameParam : ''
},
@ -130,7 +130,7 @@ function useArticlesMeta(): UseArticlesMetaReturn {
watch(
() => route.params.tag,
(tagParam) => {
tagParam => {
if (tagParam !== tag.value)
tag.value = typeof tagParam === 'string' ? tagParam : ''
},

View File

@ -101,7 +101,7 @@ async function onSubmit() {
errors.value = {}
try {
// eslint-disable-next-line unicorn/no-array-reduce, ts/no-unsafe-assignment
// eslint-disable-next-line unicorn/no-array-reduce
const filteredForm = Object.entries(form).reduce((form, [k, v]) => v === null ? form : Object.assign(form, { [k]: v }), {})
const userData = await api.user.updateCurrentUser({ user: filteredForm }).then(res => res.data.user)
userStore.updateUser(userData)

View File

@ -31,7 +31,7 @@ interface RenderOptionsArgs {
const scheduler = typeof setImmediate === 'function' ? setImmediate : setTimeout
export function flushPromises(): Promise<void> {
return new Promise((resolve) => {
return new Promise(resolve => {
scheduler(resolve, 0)
})
}
@ -65,7 +65,7 @@ export function renderOptions(args: Partial<RenderOptionsArgs> = {}): RenderOpti
if (!initialRoute)
return result
return new Promise((resolve) => {
return new Promise(resolve => {
void router.replace(initialRoute).then(() => resolve(result))
})
}
@ -78,7 +78,6 @@ export function asyncWrapper(component: ReturnType<typeof defineComponent>, prop
{ id: 'root' },
h(Suspense, null, {
default() {
// eslint-disable-next-line ts/no-unsafe-argument
return h(component, props)
},
fallback: h('div', 'Loading...'),
@ -166,7 +165,7 @@ export function setupMockServer(...listeners: Listener[]) {
}
const server = setupServer(
...listeners.map((args) => {
...listeners.map(args => {
let [method, path, status, response] = parseArgs(args)
method = method.toLowerCase()
return http[method as 'all'](`${import.meta.env.VITE_API_HOST}${path}`, () => {
@ -198,7 +197,7 @@ export function setupMockServer(...listeners: Listener[]) {
function use(...listeners: Listener[]) {
originalUse(
...listeners.map((args) => {
...listeners.map(args => {
let [method, path, status, response] = parseArgs(args)
method = method.toLowerCase()
return http[method as 'all'](`${import.meta.env.VITE_API_HOST}${path}`, () => {