随笔 - 211  文章 - 1  评论 - 108  阅读 - 61万

Prettier + ESLint + TS常用配置项

 

.prettierrc.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module.exports = {
  printWidth: 120,
  // 缩进字节
  tabWidth: 2,
  // 句尾添加分号
  semi: true,
  // 在jsx中把'>' 是否单独放一行
  jsxBracketSameLine: true,
  // 启用单引号
  singleQuote: true,
  bracketSameLine: true,
  // 对象,数组括号与文字之间加空格
  bracketSpacing: false,
  // 箭头函数单一参数省略括号
  arrowParens: 'avoid',
  // 对象或数组末尾加逗号
  trailingComma: 'es5',
};

  

.eslintrc.js 配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{
root: true, // 当前配置为根配置,将不再从上级文件夹查找配置
parserOptions: {
 parser: 'babel-eslint', // 采用 babel-eslint 作为语法解析器
 sourceType: 'module'// 指定来源的类型,有两种script或module
 ecmaVersion: 6, //指定ECMAScript支持的版本,6为ES6
},
env: {
 browser: true, // 设置为所需检查的代码是在浏览器环境运行的
 es6: true // 设置所需检查代码为 es6 语法书写
},
extends: ['plugin:vue/recommended', 'eslint:recommended'],// 扩展使用 vue 检查规则和eslint推荐规则
 rules: {
  'vue/attribute-hyphenation': 0, // 忽略属性连字
  'vue/max-attributes-per-line':[2, { singleline: 10, multiline: { max: 1, allowFirstLine: false } }], // 每行最大属性
  'vue/singleline-html-element-content-newline': 'off', // 单行html元素内容在新的一行
  'vue/multiline-html-element-content-newline': 'off', // 多行html元素内容在新的一行
  'vue/html-closing-bracket-newline': 'off', // html右括号在新的一行
  'vue/no-v-html': 'off', // 不使用v-html
  'vue/html-self-closing': 0, // 忽略html标签自闭合
  'accessor-pairs': 2, // 应同时设置setter和getter
  'arrow-spacing': [2, { before: true, after: true }], // 箭头间距
  'vue/require-default-prop': 0, // 不检查默认属性
  'vue/require-prop-types': 0, // 不检查默认类型
  'block-spacing': [2, 'always'], // 块间距
  'brace-style': [2, '1tbs', { allowSingleLine: true }], // 大括号样式允许单行
  'camelcase': [2, { properties: 'always' }], //为属性强制执行驼峰命名
  'comma-dangle': [2, 'never'], // 逗号不使用悬挂
  'comma-spacing': [2, { before: false, after: true }], // 逗号间距
  'comma-style': [2, 'last'], //(默认)与数组元素,对象属性或变量声明在同一行之后和同一行需要逗号
  'constructor-super': 2,
  'consistent-this': [2, 'that'], //强制this别名为that
  'curly': [2, 'multi-line'], // 当一个块只包含一条语句时,不允许省略花括号。
  'dot-location': [2, 'property'], //成员表达式中的点应与属性部分位于同一行
  'eol-last': 2, // 强制文件以换行符结束(LF)
  'eqeqeq': ['error', 'always', { null: 'ignore' }], // 强制使用全等
  'generator-star-spacing': [2, { before: true, after: true }], // 生成器中'*'两侧都要有间距
  'global-require': 1, // 所有调用require()都位于模块的顶层
  'indent': [2, 2, { SwitchCase: 2 }], //缩进风格
  'key-spacing': [2, { beforeColon: false, afterColon: true }], // 强制在对象字面量属性中的键和值之间保持一致的间距
  'keyword-spacing': [2, { before: true, after: true }], // 关键字如if/function等的间距
  'new-cap': [2, { newIsCap: true, capIsNew: false }],// 允许在没有new操作符的情况下调用大写启动的函数;(默认)要求new使用大写启动函数调用所有操作符
  'new-parens': 2, // JavaScript通过new关键字调用函数时允许省略括号
  'no-array-constructor': 1, // 不允许使用Array构造函数。除非要指定生成数组的长度
  'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', // 只有开发环境可以使用console
  'no-class-assign': 2, // 不允许修改类声明的变量
  'no-const-assign': 2, // 不能修改使用const关键字声明的变量
  'no-control-regex': 0, // 不允许正则表达式中的控制字符
  'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', // 只有开发环境可以使用debugger
  'no-delete-var': 2, // 不允许在变量上使用delete操作符
  'no-dupe-args': 2, // 不允许在函数声明或表达式中使用重复的参数名称
  'no-dupe-class-members': 2, // 不允许在类成员中使用重复的参数名称
  'no-dupe-keys': 2, // 不允许在对象文字中使用重复键
  'no-duplicate-case': 2, // 不允许在switch语句的case子句中使用重复的测试表达式
  'no-empty-character-class': 2, // 不允许在正则表达式中使用空字符类
  'no-empty-pattern': 2, // 不允许空块语句
  'no-eval': 2, // 不允许使用eval
  'no-ex-assign': 2, // 不允许在catch子句中重新分配例外
  'no-extend-native': 2, // 不允许直接修改内建对象的原型
  'no-extra-boolean-cast': 2, // 禁止不必要的布尔转换
  'no-extra-parens': [2, 'functions'], // 仅在函数表达式附近禁止不必要的括号
  'no-fallthrough': 2, //消除一个案件无意中掉到另一个案件
  'no-floating-decimal': 2, //消除浮点小数点,并在数值有小数点但在其之前或之后缺少数字时发出警告
  'no-func-assign': 2, // 允许重新分配function声明
  'no-implied-eval': 2, // 消除隐含eval()
  'no-inner-declarations': [2, 'functions'], // 不允许function嵌套块中的声明
  'no-invalid-regexp': 2, //不允许RegExp构造函数中的无效正则表达式字符串
  'no-irregular-whitespace': 2, //捕获无效的空格
  'no-iterator': 2, //消除阴影变量声明
  'no-label-var': 2, //禁止创建与范围内的变量共享名称的标签
  'no-labels': [2, { allowLoop: false, allowSwitch: false }], // 消除 JavaScript 中使用带标签的语句
  'no-lone-blocks': 2, //消除脚本顶层或其他块中不必要的和可能混淆的块
  'no-mixed-spaces-and-tabs': 2, // 不允许使用混合空格和制表符进行缩进
  'no-multi-spaces': 2, // 禁止在逻辑表达式,条件表达式,声明,数组元素,对象属性,序列和函数参数周围使用多个空格
  'no-multi-str': 2, // 防止使用多行字符串
  'no-multiple-empty-lines': [2, { max: 1 }], // 最多一个空行
  'no-native-reassign': 2, // 不允许修改只读全局变量
  'no-new-object': 2, // 不允许使用Object构造函数
  'no-new-require': 2, // 消除new require表达的使用
  'no-new-symbol': 2, // 防止Symbol与new 同时使用的意外错误
  'no-new-wrappers': 2, // 杜绝使用String,Number以及Boolean与new操作
  'no-obj-calls': 2, // 不允许调用Math,JSON和Reflect对象作为功能
  'no-octal': 2, // 不允许使用八进制文字
  'no-octal-escape': 2, // 不允许字符串文字中的八进制转义序列
  'no-path-concat': 2, // 防止 Node.js 中的目录路径字符串连接无效
  'no-redeclare': 2, // 消除在同一范围内具有多个声明的变量
  'no-regex-spaces': 2, // 在正则表达式文字中不允许有多个空格
  'no-return-assign': [2, 'except-parens'], // 消除return陈述中的任务,除非用括号括起来
  'no-self-assign': 2, // 消除自我分配
  'no-self-compare': 2, // 禁止比较变量与自身
  'no-sequences': 2, // 禁止使用逗号运算符
  'no-sparse-arrays': 2, // 不允许稀疏数组文字
  'no-this-before-super': 2, // 在呼call前标记this/super关键字super()
  'no-throw-literal': 2, // 不允许抛出不可能是Error对象的文字和其他表达式
  'no-trailing-spaces': 2, // 不允许在行尾添加尾随空白
  'no-undef': 2, // 任何对未声明的变量的引用都会导致错误
  'no-undef-init': 2, // 消除初始化为undefined的变量声明
  'no-underscore-dangle': 2, // 标识符不能以_开头或结尾
  'no-unexpected-multiline': 2, // 不允许混淆多行表达式
  'no-unmodified-loop-condition': 2, // 查找循环条件内的引用,然后检查这些引用的变量是否在循环中被修改
  'no-unneeded-ternary': [2, { defaultAssignment: false }], // 不允许将条件表达式作为默认的分配模式
  'no-unreachable': 2, // 不允许可达代码return,throw,continue,和break语句后面还有语句。
  'no-unsafe-finally': 2, // 不允许return,throw,break,和continue里面的语句finally块
  'no-unused-vars': [2, { vars: 'all', args: 'after-used' }],
  // 消除未使用的变量,函数和函数的参数
  // vars: 'all' 检查所有变量的使用情况,包括全局范围内的变量。这是默认设置。 args: 'after-used' 只有最后一个参数必须使用。例如,这允许您为函数使用两个命名参数,并且只要您使用第二个参数,ESLint 就不会警告您第一个参数。这是默认设置。
  'no-useless-call': 2, // 标记使用情况,Function.prototype.call()并且Function.prototype.apply()可以用正常的函数调用来替代
  'no-useless-computed-key': 2, // 禁止不必要地使用计算属性键
  'no-useless-constructor': 2, // 在不改变类的工作方式的情况下安全地移除的类构造函数
  'no-useless-escape': 0, // 禁用不必要的转义字符
  'no-whitespace-before-property': 2, // 如果对象的属性位于同一行上,不允许围绕点或在开头括号之前留出空白
  'no-with': 2, //禁用with
  'no-var': 2, // 禁用var
  'one-var': [2, { initialized: 'never' }], // 强制将变量声明为每个函数(对于var)或块(对于let和const)范围一起声明或单独声明。 initialized: 'never' 每个作用域要求多个变量声明用于初始化变量
  'operator-linebreak': [2, 'after', { overrides: { '?': 'before', ':': 'before' } }], // 实施一致的换行
  'padded-blocks': [2, 'never'], // 在块内强制执行一致的空行填充
  'prefer-destructuring': ['error', { object: false, array: false }], // 此规则强制使用解构而不是通过成员表达式访问属性。
  'quotes': [2, 'single', { avoidEscape: true, allowTemplateLiterals: true }],// avoidEscape: true 允许字符串使用单引号或双引号,只要字符串包含必须以其他方式转义的引号 ;allowTemplateLiterals: true 允许字符串使用反引号
  'radix': 2, //parseInt必须指定第二个参数
  'semi': [2, 'never'], // 不使用分号
  'semi-spacing': [2, { before: false, after: true }], // 强制分号间隔
  'space-before-blocks': [2, 'always'], // 块必须至少有一个先前的空间
  'space-before-function-paren': [2, 'never'], // 在(参数后面不允许任何空格
  'space-in-parens': [2, 'never'], // 禁止或要求(或)左边的一个或多个空格
  'space-infix-ops': 2, // 强制二元运算符左右各有一个空格
  'space-unary-ops': [2, { words: true, nonwords: false }],// words: true 如:new,delete,typeof,void,yield 左右必须有空格 // nonwords: false 一元运算符,如:-,+,--,++,!,!!左右不能有空格
  'spaced-comment': [2, 'always', { markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] }], // 注释开始后,此规则将强制间距的一致性//或/*
  'template-curly-spacing': [2, 'never'], // 不允许大括号内的空格
  'use-isnan': 2, //禁止比较时使用NaN,只能用isNaN()
  'valid-typeof': 2, //必须使用合法的typeof的值
  'wrap-iife': [2, 'any'], //立即执行函数表达式的小括号风格
  'yield-star-spacing': [2, 'both'], // 强制执行*周围 yield*表达式的间距,两侧都必须有空格
  'yoda': [2, 'never'],
  'prefer-const': 2, // 使用let关键字声明的变量,但在初始分配后从未重新分配变量,应改为const声明
  'object-curly-spacing': [2, 'always', { objectsInObjects: false }],// 不允许以对象元素开始和/或以对象元素结尾的对象的大括号内的间距
  'array-bracket-spacing': [2, 'never'] // 不允许数组括号内的空格
 }
}

 

tsconfig.json 是typescript对应的编译配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
  "compilerOptions": {
    "baseUrl": "./",
    "allowJs": true,
    "types": ["react-native"],
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUnusedLocals": true,
    "pretty": true,
    "declaration": true,
    "esModuleInterop": true,
    "isolatedModules": false,
    "jsx": "react-native",
    "noEmit": false,
    "lib": ["es2019"],
    "module": "commonjs",
    "moduleResolution": "node",
    "outDir": "lib",
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "removeComments": true,
    "strict": true,
    "target": "esnext"
  },
  "include": ["src/**/*"],
  "exclude": ["ShareApp", "example", "gifs", "node_modules", "babel.config.js", "metro.config.js", "jest.config.js"],
  "compileOnSave": false
}

 

"compilerOptions",可以被忽略,这时编译器会使用默认值
"files",指定一个包含相对或绝对文件路径的列表。
"references":新的顶级属性,它是一个对象数组,指定要引用的项目
"include"和"exclude",属性指定一个文件glob匹配模式列表。
"extends",可以让tsconfig.json从另一个配置文件里继承配置属性
"compileOnSave",可以让IDE在保存文件的时候根据tsconfig.json重新生成文件。

compilerOptions常用配置

 

选项 类型 默认值 描述
allowJs boolean false 允许编译javascript文件。
allowSyntheticDefaultImports boolean module === "system" 或设置了 --esModuleInterop 且 module 不为 es2015 / esnext 允许从没有设置默认导出的模块中默认导入。这并不影响代码的输出,仅为了类型检查
allowUnreachableCode boolean false 不报告执行不到的代码错误。
allowUnusedLabels boolean false 不报告未使用的标签错误。
alwaysStrict boolean false 以严格模式解析并为每个源文件生成 "use strict"语句
baseUrl string   解析非相对模块名的基准目录
charset string "utf8" 输入文件的字符集。
checkJs boolean false 在 .js文件中报告错误。与 --allowJs配合使用。
declaration boolean false 生成相应的 .d.ts文件。
declarationDir string   生成声明文件的输出路径。
diagnostics boolean false 显示诊断信息
disableSizeLimit boolean false 禁用JavaScript工程体积大小的限制
emitBOM boolean false 在输出文件的开头加入BOM头(UTF-8 Byte Order Mark)
emitDecoratorMetadata boolean false 给源码里的装饰器声明加上设计类型元数据。
experimentalDecorators boolean false 启用实验性的ES装饰器
extendedDiagnostics boolean false 显示详细的诊段信息
forceConsistentCasingInFileNames boolean false 禁止对同一个文件的不一致的引用
help     打印帮助信息
importHelpers string   从 tslib 导入辅助工具函数(比如 __extends, __rest等)
inlineSourceMap boolean false 生成单个sourcemaps文件,而不是将每sourcemaps生成不同的文件。
inlineSources boolean false 将代码与sourcemaps生成到一个文件中,要求同时设置了 --inlineSourceMap或 --sourceMap属性
init     初始化TypeScript项目并创建一个 tsconfig.json文件
isolatedModules boolean false 将每个文件作为单独的模块(与“ts.transpileModule”类似)
jsx string "Preserve" 在 .tsx文件里支持JSX: "React"或 "Preserve"。
jsxFactory string "React.createElement" 指定生成目标为react JSX时,使用的JSX工厂函数,比如 React.createElement或 h。
lib string[]   编译过程中需要引入的库文件的列表。
可能的值为:
► ES5
► ES6
► ES2015
► ES7
► ES2016
► ES2017
► ES2018
► ESNext
► DOM
► DOM.Iterable
► WebWorker
► ScriptHost
► ES2015.Core
► ES2015.Collection
► ES2015.Generator
► ES2015.Iterable
► ES2015.Promise
► ES2015.Proxy
► ES2015.Reflect
► ES2015.Symbol
► ES2015.Symbol.WellKnown
► ES2016.Array.Include
► ES2017.object
► ES2017.Intl
► ES2017.SharedMemory
► ES2017.String
► ES2017.TypedArrays
► ES2018.Intl
► ES2018.Promise
► ES2018.RegExp
► ESNext.AsyncIterable
► ESNext.Array
► ESNext.Intl
► ESNext.Symbol

注意:如果--lib没有指定默认注入的库的列表。默认注入的库为:
► 针对于--target ES5:DOM,ES5,ScriptHost
► 针对于--target ES6:DOM,ES6,DOM.Iterable,ScriptHost
listEmittedFiles boolean false 打印出编译后生成文件的名字
listFiles boolean false 编译过程中打印文件名
locale string (platform specific) 显示错误信息时使用的语言,比如:en-us
mapRoot string   为调试器指定指定sourcemap文件的路径,而不是使用生成时的路径。当 .map文件是在运行时指定的,并不同于 js文件的地址时使用这个标记。指定的路径会嵌入到 sourceMap里告诉调试器到哪里去找它们。
maxNodeModuleJsDepth number 0 node_modules依赖的最大搜索深度并加载JavaScript文件。仅适用于 --allowJs
module string target === "ES6" ? "ES6" : "commonjs" 指定生成哪个模块系统代码: "None", "CommonJS", "AMD", "System", "UMD", "ES6"或 "ES2015"。
► 只有 "AMD"和 "System"能和 --outFile一起使用。
► "ES6"和 "ES2015"可使用在目标输出为 "ES5"或更低的情况下
moduleResolution string module === "AMD" or "System" or "ES6" ? "Classic" : "Node" 决定如何处理模块。或者是"Node"对于Node.js/io.js,或者是"Classic"(默认)。
newLine string (platform specific) 当生成文件时指定行结束符: "crlf"(windows)或 "lf"(unix)。
noEmit boolean false 不生成输出文件
noEmitHelpers boolean false 不在输出文件中生成用户自定义的帮助函数代码,如 __extends
noEmitOnError boolean false 报错时不生成输出文件
noErrorTruncation boolean false 不截短错误消息
noFallthroughCasesInSwitch boolean false 报告switch语句的fallthrough错误。(即,不允许switch的case语句贯穿)
noImplicitAny boolean false 在表达式和声明上有隐含的 any类型时报错
noImplicitReturns boolean false 不是函数的所有返回路径都有返回值时报错
noImplicitThis boolean false 当 this表达式的值为 any类型的时候,生成一个错误
noImplicitUseStrict boolean false 模块输出中不包含 "use strict"指令
noLib boolean false 不包含默认的库文件( lib.d.ts)
noResolve boolean false 不把 /// <reference``>或模块导入的文件加到编译文件列表
noStrictGenericChecks boolean false 禁用在函数类型里对泛型签名进行严格检查
noUnusedLocals boolean false 若有未使用的局部变量则抛错
noUnusedParameters boolean false 若有未使用的参数则抛错
outDir string   重定向输出目录。
outFile string   将输出文件合并为一个文件。合并的顺序是根据传入编译器的文件顺序和 ///<reference``>和 import的文件顺序决定的
paths Object   模块名到基于 baseUrl的路径映射的列表
preserveConstEnums boolean false 保留 const和 enum声明。
preserveSymlinks boolean false 不把符号链接解析为其真实路径;将符号链接文件视为真正的文件
preserveWatchOutput boolean false 保留watch模式下过时的控制台输出
pretty boolean false 给错误和消息设置样式,使用颜色和上下文
project string   编译指定目录下的项目。这个目录应该包含一个 tsconfig.json文件来管理编译
reactNamespace string "React" 当目标为生成 "react" JSX时,指定 createElement和 __spread的调用对象
removeComments boolean false 删除所有注释,除了以 /!*开头的版权信息。
rootDir string   仅用来控制输出的目录结构 --outDir
rootDirs string[]   根(root)文件夹列表,表示运行时组合工程结构的内容。
skipDefaultLibCheck boolean false 忽略 库的默认声明文件的类型检查
skipLibCheck boolean false 忽略所有的声明文件( *.d.ts)的类型检查
sourceMap boolean false 生成相应的 .map文件。
sourceRoot string   指定TypeScript源文件的路径,以便调试器定位。当TypeScript文件的位置是在运行时指定时使用此标记。路径信息会被加到 sourceMap里
strict boolean false 启用所有严格类型检查选项。
启用 --strict相当于启用 --noImplicitAny, --noImplicitThis, --alwaysStrict, --strictNullChecks和 --strictFunctionTypes和--strictPropertyInitialization
strictFunctionTypes boolean false 禁用函数参数双向协变检查
strictPropertyInitialization boolean false 确保类的非undefined属性已经在构造函数里初始化。若要令此选项生效,需要同时启用--strictNullChecks
strictNullChecks boolean false 在严格的 null检查模式下, null和 undefined值不包含在任何类型里,只允许用它们自己和 any来赋值(有个例外, undefined可以赋值到 void)
stripInternal boolean false 不对具有 /** @internal */ JSDoc注解的代码生成代码
suppressExcessPropertyErrors boolean false 阻止对对象字面量的额外属性检查
suppressImplicitAnyIndexErrors boolean false 阻止 --noImplicitAny对缺少索引签名的索引对象报错
target string "ES3" 指定ECMAScript目标版本 "ES3"(默认), "ES5", "ES6"/ "ES2015", "ES2016", "ES2017"或 "ESNext"
traceResolution boolean false 生成模块解析日志信息
types string[]   要包含的类型声明文件名列表
typeRoots string[]   要包含的类型声明文件路径列表。
version     打印编译器版本号
watch     在监视模式下运行编译器。会监视输出文件,在它们改变时重新编译。监视文件和目录的具体实现可以通过环境变量进行配置

 

settings.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{
  "editor.fontSize": 12,
  "editor.tabSize": 2,
  "editor.fontFamily": "'FiraCode-Retina', Menlo, Monaco, 'Courier New', monospace",
  // 每次保存的时候将代码按格式进行修复
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "editor.formatOnPaste": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "files.exclude": {
    "**/.DS_Store": true,
    "**/.git": true,
    "**/.hg": true,
    "**/.svn": true,
    "**/bower_components": true,
    "**/CVS": true,
    "**/node_modules": true,
    "**/tmp": true
  },
  "files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/**": true,
    "**/tmp/**": true,
    "**/bower_components/**": true,
    "**/dist/**": true
  },
  "files.associations": {
    ".editorconfig": "javascript",
    "*.cjson": "jsonc",
    "*.wxss": "css",
    "*.wxs": "javascript"
  },
  "git.autofetch": true,
  "gitlens.advanced.messages": {
    "suppressCommitHasNoPreviousCommitWarning": false,
    "suppressCommitNotFoundWarning": false,
    "suppressFileNotUnderSourceControlWarning": false,
    "suppressGitVersionWarning": false,
    "suppressLineUncommittedWarning": false,
    "suppressNoRepositoryWarning": false,
    "suppressResultsExplorerNotice": false,
    "suppressShowKeyBindingsNotice": true
  },
  "search.followSymlinks": false,
  "window.zoomLevel": 1,
  "debug.node.autoAttach": "on",
  "workbench.iconTheme": "material-icon-theme",
  "[html]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[css]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[vue]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  // 禁用vetur的JS格式化,交给eslint处理
  // "vetur.format.defaultFormatter.js": "none",
  // "vetur.format.defaultFormatter.css": "none",
  // "vetur.format.defaultFormatter.scss": "none",
  // 如果要自行配置 ESLint 规则,请关闭 Vetur 的模板校验,
  // "vetur.validation.template": false,
  // prettier格式化代码
  // "prettier.tabWidth": 2,
  // "prettier.useTabs": false,
  // "prettier.semi": true,
  // "prettier.printWidth": 160,
  // "prettier.trailingComma": "es5",
  // "prettier.singleQuote": true,
  // "prettier.arrowParens": "always",
  // "prettier.htmlWhitespaceSensitivity": "ignore",
  // eslint规则
  "eslint.run": "onSave",
  "eslint.validate": ["javascript", "javascriptreact", "html", "vue"],
  "eslint.workingDirectories": [
    ".eslintrc.js",
    {
      "mode": "auto"
    }
  ],
  "vue3snippets.enable-compile-vue-file-on-did-save-code": true
}

  

 

posted on   稻草人.Net  阅读(1779)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2013-01-04 让浏览器跨域
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示