下面是一个简单的React组件示例,演示了如何使用TypeScript编写React组件,并且使用Prettier插件格式化代码: importReactfrom'react';interfaceProps{name:string;}constHelloWorld:React.FC<Props>= ({ name }) =>{returnHello,{name}!;}; export default HelloWorld; 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11...
eslint-plugin-import eslint-plugin-node eslint-plugin-flow-vars eslint-plugin-react eslint-config-vue eslint-plugin-vue 1. 2. vue-cli 默认配置 vue create eslint-demo 1. 二、配置vscode 引入eslint发现开发的时候,虽然规范了代码,但是每当保存时,稍不注意控制台就一堆警告⚠️,那么如何可以让...
在vscode软件中,书写react开发的代码,默认的语言是不支持代码的格式化以及不支持标签的快速编写的,所以将语言转换成JavaScript React即可。步骤如下图所示 image.png
点击javascript,出现可选语言,搜索javascript react 选中即可 此时格式化代码就ok了 ^.^
安装Beautify和React beautify扩展程序,并在项目根目录创建配置文件 ,并复制下面代码到此配置文件里: 效果还不错,有其他格式化需求的可以去研究Beautify插件的属性,给个链接好了= "点这里哟" 。
目前已经安装了eslint,并且配置了如下代码: { "workbench.colorTheme": "Solarized Light", "terminal.integrated.rendererType": "dom", "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe", "eslint.autoFixOnSave": true, "eslint.validate": [ "javascript", "javascriptreact", {...
“[javascriptreact]”: { “editor.formatOnSave”: true }, // 可以根据自己使用的语言类型进行配置 “` e. 保存设置文件并关闭。 4. 格式化代码并进行换行。 a. 可以通过右键点击代码编辑区域,选择“Prettier: Format Document”来格式化整个文件。
// 保存时格式化 "editor.formatOnPaste": true }, "[typescriptreact]": { // react ts 相关操作 "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, // 保存时格式化 "editor.formatOnPaste": false// 粘贴时格式化 }, "search.followSymlinks": false, "files.exclude"...
["javascript","javascriptreact","vue-html",{"language":"vue","autoFix":true}],"eslint.run":"onSave","eslint.autoFixOnSave":false,// #让prettier使用eslint的代码格式进行校验// vscode 更新后已经统一使用editor.codeActionsOnsave// #代码结尾加分号为好"prettier.semi":true,// #使用带引号...