IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> vscode代码相关自动格式化配置 -> 正文阅读

[开发工具]vscode代码相关自动格式化配置

vscode:setting.json

{
  "editor.renderIndentGuides": false,
  "editor.codeActionsOnSave": {
    "source.fixAll": true
  },
  "git.confirmSync": false,
  "launch": {
    "configurations": [],
    "compounds": [],
    "search.exclude": {
      "system/": true,
      "!/system/**/*.ps*": true
    }
  },
  "[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  },
  "[json]": {
    "editor.defaultFormatter": "vscode.json-language-features"
  },
  "terminal.integrated.automationShell.osx": "",
  "security.workspace.trust.untrustedFiles": "open",
  "sonarlint.ls.javaHome": "c:\\Users\\满船1167\\.vscode\\extensions\\sonarsource.sonarlint_managed-jre\\jre\\jdk-11.0.11+9-jre",
  "tabnine.experimentalAutoImports": true,
  "sonarlint.rules": {
    "javascript:S4326": {
      "level": "off"
    },
    "javascript:S125": {
      "level": "off"
    },
    "javascript:S4138": {
      "level": "off"
    },
    "javascript:S3776": {
      "level": "off"
    },
    "javascript:S3626": {
      "level": "off"
    },
    "javascript:S2310": {
      "level": "off"
    },
    "javascript:S3358": {
      "level": "off"
    }
  },
  "workbench.iconTheme": "material-icon-theme",
  "[javascriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[vue]": {
    "editor.defaultFormatter": "octref.vetur"
  },
  // 默认使用prettier格式化支持的文件
  "vetur.format.defaultFormatter.js": "prettier",
  "vetur.format.defaultFormatter.html": "prettyhtml",
  "vetur.format.defaultFormatterOptions": {
    "prettier": {
      // 结尾无分号
      "semi": false,
      // 超过140个字符换行
      "printWidth": 140,
      // 使用单引号
      "singleQuote": true,
      // 无尾随逗号
      "trailingComma": "none",
      // 箭头函数单个参数不加分号
      "arrowParens": "avoid"
    },
    "prettyhtml": {
      "printWidth": 140
    }
  },
  "editor.formatOnSave": true,
  "editor.tabSize": 4,
  // false去掉代码结尾的分号
  "prettier.semi": false,
  // 使用带引号替代双引号
  "prettier.singleQuote": true,
  // 去除最后一个对象结尾的逗号
  "prettier.trailingComma": "none",
  // 超过140字符进行换行
  "prettier.printWidth": 140,
  // (x) => {} 是否要有小括号默认avoid不要,always要
  "prettier.arrowParens": "avoid",
}


项目根目录下新建文件.prettierrc.js

module.exports = {
	// 超过最大值换行
	printWidth: 140,
	// 行末是否加分号
	semi: false,
	// 用单引号代替双引号
	singleQuote: true,
	// tab键宽度,默认为4
	tabWidth: 4,
	// 最后一个对象元素加逗号
	trailingComma: 'none',
	// 开启 eslint 支持
	'prettier.eslintIntegration': true,
	// 指定使用哪一种解析器
	parser: 'babel',
	// 对象,数组加空格
	bracketSpacing: true,
	// 使用tab(制表符)缩进而非空格
	useTabs: true,
	// jsx > 是否另起一行
	jsxBracketSameLine: false,
	// (x) => {} 是否要有小括号默认avoid不要,always要
	arrowParens: 'avoid',
	// 是否要注释来决定是否格式化代码
	requirePragma: false,
	// 是否要换行
	proseWrap: 'preserve',
	// 保存时自动fix
	'eslint.autoFixOnSave': true,
	// 添加 vue 支持
	'eslint.validate': [
		'javascript',
		'javascriptreact',
		{
			language: 'vue',
			autoFix: true
		}
	]
}

根目录下新建文件.editorconfig

# http://editorconfig.org
# editorconfig顶级配置文件,停止向上寻找配置文件
root = true

[*]
# 缩进风格tab或者space
indent_style = tab
# 缩进大小2或者4
indent_size = 4
# 换行符
end_of_line = lf
# 字符集
charset = utf-8
# 是否删除行尾的空格
trim_trailing_whitespace = true
# 是否在文件的最后插入一个空行
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab

根目录下新建文件.eslintrc.js

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true,
    es6: true
  },
  // extends: ['plugin:vue/essential', '@vue/standard'],
  extends: ['plugin:vue/recommended', 'eslint:recommended'],
  parserOptions: {
    parser: 'babel-eslint',
    sourceType: 'module'
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    indent: ['off', 2],
    'no-irregular-whitespace': 'off',
    'vue/script-indent': ['error', 4, { baseIndent: 1 }],
    'space-before-function-paren': [0, 'always'],
    // 强制在注释中 // 或 /* 使用一致的空格
    'spaced-comment': 0,
    // always-multiline:多行模式必须带逗号,单行模式不能带逗号
    'comma-dangle': [1, 'never'],
    // 末尾禁止使用分号
    'no-mixed-spaces-and-tabs': [1, 'smart-tabs'],
    // semi: 0,
    'no-tabs': 0,
    'linebreak-style': ['off', 'windows'],
    quotes: ['error', 'single'],
    semi: ['error', 'never']
  }
}

vscode安装插件:

EditorConfig for VS Code
Prettier
  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2021-07-10 11:37:37  更:2021-07-10 11:38:08 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/9 5:04:48-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码