Format/Lint on save with VSCode
This template should help get you started developing with Vue 3 in Vite.
VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).
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) 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 that is more performant. You can enable it by the following steps:
- Disable the built-in TypeScript Extension
- Run
Extensions: Show Built-in Extensionsfrom VSCode's command palette - Find
TypeScript and JavaScript Language Features, right click and selectDisable (Workspace)
- Run
- Reload the VSCode window by running
Developer: Reload Windowfrom the command palette.
See Vite Configuration Reference.
npm installnpm run devnpm run buildRun Unit Tests with Vitest
npm run test:unitRun End-to-End Tests with Cypress
npm run build
npm run test:e2e # or `npm run test:e2e:ci` for headless testingLint with ESLint
npm run lintTo make sure the code adheres to the format of the repository, you can edit the settings in VSCode to use the eslint configuration for formatting the linting the code.
ESLint will use the configuration specified in the .eslintrc file in the root of this project to understand the type of formatting standard and linting rules it should use.
The ESLint extension adds variables to the settings for VSCode, which can be used to tell VSCode how to lint the project.
Update the "Workspace" settings with the following options:
{
"eslint.format.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
}
}
eslint.format.enable: enables ESLint as a formatter for validated files. Although you can also use the formatter on save using the settingeditor.formatOnSaveit is recommended to use theeditor.codeActionsOnSavefeature since it allows for better configurability. - ESLint GitHub Repo, "Settings Options"
Need help finding your VSCode settings, or understanding the difference between the User and Workspace settings? Check out the documentation on User and Workspace Settings.