Skip to content

Commit

Permalink
๐ŸŽ‰ Init Vue app (#2)
Browse files Browse the repository at this point in the history
* ๐ŸŽ‰ Init Vue app

* ๐Ÿ”ง typescript-eslint ใฎ่จญๅฎšใ‚’ๅผทใ‚ใซใ‹ใ‘ใฆๅž‹ๅฎ‰ๅ…จๆ€งใ‚’้ซ˜ใ‚ใ‚‹

* ๐ŸŽจ prettier ใงใƒ•ใ‚ฉใƒผใƒžใƒƒใƒˆใ™ใ‚‹

* ๐Ÿฉน fix vuejs/language-tools#1985

* ๐Ÿง‘โ€๐Ÿ’ป eslint/prettier ใ‚’ cache ใง้ซ˜้€ŸๅŒ–
  • Loading branch information
u-sho committed Oct 18, 2022
1 parent 42f92b5 commit b95592a
Show file tree
Hide file tree
Showing 41 changed files with 7,214 additions and 0 deletions.
53 changes: 53 additions & 0 deletions client/.eslintrc.cjs
@@ -0,0 +1,53 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')

/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
ignorePatterns: ['.git/*', 'node_modules/*', 'dist/*'],
extends: [
'eslint:recommended',
'plugin:vue/vue3-recommended',
'@vue/eslint-config-typescript/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/strict',
'@vue/eslint-config-prettier',
],
rules: {
// use "@/*" instead
'no-restricted-imports': ['error', { patterns: ['src/*', '../*'] }],

'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', disallowTypeAnnotations: true },
],
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
},
overrides: [
{
files: ['cypress/e2e/**.{cy,spec}.ts'],
extends: ['plugin:cypress/recommended'],
},
{
files: ['**/__tests__/**/*.{spec,test}.ts'],
rules: {
'no-restricted-imports': ['error', { patterns: ['src/*', '../../'] }],
},
},
],
parser: 'vue-eslint-parser',
parserOptions: {
ecmaFeatures: { impliedStrict: true, jsx: false },
ecmaVersion: 'latest',
parser: '@typescript-eslint/parser',
project: [
'./tsconfig.config.json',
'./tsconfig.app.json',
'./tsconfig.vitest.json',
'./tsconfig.json',
'./tsconfig.eslint.json',
],
vueFeatures: { filter: false },
},
}
31 changes: 31 additions & 0 deletions client/.gitignore
@@ -0,0 +1,31 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# chache
.eslintcache
Empty file removed client/.gitkeep
Empty file.
7 changes: 7 additions & 0 deletions client/.prettierrc
@@ -0,0 +1,7 @@
{
"arrowParens": "avoid",
"semi": false,
"singleQuote": true,
"htmlWhitespaceSensitivity": "ignore",
"singleAttributePerLine": true
}
8 changes: 8 additions & 0 deletions client/.vscode/extensions.json
@@ -0,0 +1,8 @@
{
"recommendations": [
"vue.volar",
"vue.vscode-typescript-vue-plugin",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
}
59 changes: 59 additions & 0 deletions client/README.md
@@ -0,0 +1,59 @@
# client

This template should help get you started developing with Vue 3 in Vite.

## Recommended IDE Setup

[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).

## Type Support for `.vue` Imports in TS

TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:

1. Disable the built-in TypeScript Extension
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.

## Customize configuration

See [Vite Configuration Reference](https://vitejs.dev/config/).

## Project Setup

```sh
npm install
```

### Compile and Hot-Reload for Development

```sh
npm run dev
```

### Type-Check, Compile and Minify for Production

```sh
npm run build
```

### Run Unit Tests with [Vitest](https://vitest.dev/)

```sh
npm run test:unit
```

### Run End-to-End Tests with [Cypress](https://www.cypress.io/)

```sh
npm run build
npm run test:e2e # or `npm run test:e2e:ci` for headless testing
```

### Lint with [ESLint](https://eslint.org/)

```sh
npm run lint
```
8 changes: 8 additions & 0 deletions client/cypress.config.ts
@@ -0,0 +1,8 @@
import { defineConfig } from 'cypress'

export default defineConfig({
e2e: {
specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}',
baseUrl: 'http://localhost:4173',
},
})
8 changes: 8 additions & 0 deletions client/cypress/e2e/example.cy.ts
@@ -0,0 +1,8 @@
// https://docs.cypress.io/api/introduction/api.html

describe('My First Test', () => {
it('visits the app root url', () => {
cy.visit('/')
cy.contains('h1', 'You did it!')
})
})
10 changes: 10 additions & 0 deletions client/cypress/e2e/tsconfig.json
@@ -0,0 +1,10 @@
{
"extends": "@vue/tsconfig/tsconfig.web.json",
"include": ["./**/*", "../support/**/*"],
"compilerOptions": {
"isolatedModules": false,
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress"]
}
}
5 changes: 5 additions & 0 deletions client/cypress/fixtures/example.json
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
39 changes: 39 additions & 0 deletions client/cypress/support/commands.ts
@@ -0,0 +1,39 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }

export {}
20 changes: 20 additions & 0 deletions client/cypress/support/e2e.ts
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
1 change: 1 addition & 0 deletions client/env.d.ts
@@ -0,0 +1 @@
/// <reference types="vite/client" />
22 changes: 22 additions & 0 deletions client/index.html
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link
rel="icon"
href="/favicon.ico"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script
type="module"
src="/src/main.ts"
></script>
</body>
</html>

0 comments on commit b95592a

Please sign in to comment.