VSCode设置eslint自动缩进和自动格式化代码

【VS Code】常用设置 vs code 常用设置 阅读详情
AI摘要

文章介绍了如何在VSCode中设置eslint以实现自动缩进和代码格式化。主要步骤包括修改settings.json文件以开启自动缩进和eslint修复,以及在.eslintrc.js文件中配置缩进规则。此外,还涉及了rules中的其他配置项,如禁用console和debugger,以及缩进空格的数量等。,

VSCode设置eslint自动缩进和自动格式化代码

1、找到VS Code的settings.json文件

(1)点击左下角齿轮图标并选择设置:
(2)在文本编辑器中找到 settings.json
在这里插入图片描述settings.json的初始内容:
在这里插入图片描述

2、修改settings.json文件内容为如下内容

{
    "editor.renderWhitespace": "none",
    //自动缩进的开关,设置为true则打开自动缩进开关
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    },
    "eslint.format.enable": true,
}

在这里插入图片描述

3、打开项目根文件夹下的 .eslintrc.js文件

在这里插入图片描述

4、在rules 下配置“缩进几个空格”

rules: {
        indent: [2, 4, { SwitchCase: 1 }],
        "prettier/prettier": [2, { tabWidth: 4, endOfLine: "auto" }],
        "no-console": "off",
        "no-debugger": "off",
        "vue/multi-word-component-names": 0,

        // 解决let被强转为const问题
        "prefer-const": 0,
        // 保存代码时缩进4个空格
        // indent: ["error", 4],
    },

在这里插入图片描述

5、配置完保存,结束配置。

VS Code 设置代码缩进 通过设置 VS Code 的代码缩进选项,我们可以根据个人的喜好和项目的要求来定制缩进规范。在本文中,我们介绍了如何设置代码缩进,并提供了一些常用的设置选项。在使用 VS Code 进行代码编写时,代码缩进是一项非常重要的设置。正确的代码缩进可以提高代码的可读性和可维护性,使代码结构更清晰。VS Code 是一款功能强大的开发环境,提供了丰富的设置选项来满足不同开发者的需求。完成上述步骤后,你的代码缩进设置就已经生效了。当你在编写代码时,VS Code 将根据你的设置自动缩进代码,提高代码的可读性。 阅读详情

相关推荐

从零开始学嵌入式之STM32——1.什么是STM32

它是ST公司推出的一系列单片机的统称。ST----指的是ST公司----意法半导体。意法半导体,成立于1987年,是由意大利的SGS微电子公司和法国的Thomson半导体公司合并而成。ARM目前主要是ARM架构处理器及外围组件的电路设计方案,知识产权授权的形式收取费用,其他公司根据ARM的方案设计出CPU产品。,它以应用为核心,软硬件可裁剪,旨在实现对设备的控制、监测或辅助功能,区别于通用计算机(如 PC、服务器)的 “一机多用” 属性。在嵌入式领域,目前主流的是cortex-M3内核推出的芯片。

qshdyy的博客 1861

vscode代码自动格式化。

1.先下载两个插件 prettier和vetur 2.文件-首选项-设置-里面搜索格式化。 选中下面的prettier 3.把设置变成编辑模式。 4.直接把下面的添加进去 { "editor.formatOnType": true, "editor.formatOnSave": true, "prettier.semi": true, "prettier.singleQuote": true, "editor.defaultFormatter": "esbenp.prettier-

weixin_47372236的博客 1万+

HAMi 核心模块与架构设计

HAMi 的架构设计是围绕 Kubernetes 生态系统构建的,通过扩展 Kubernetes 的调度能力和设备管理能力,为用户提供了高效、灵活的异构设备虚拟化和管理解决方案。

北斗云的博客 2552

VS code 自动调整代码格式

Date 20210802 By WJB 使用vscode编写代码时,代码格式调整比较麻烦,多余空格,多余空行等,代码不够美观,可读性差。可以通过vscode 设置(setting)实现代码自动格式化调整。设置过程如下: 点击 vscode 软件 左下角设置按钮 打开设置界面后,右上角有个转为json的按钮,点击该按钮转为json。 在数组中添加 "editor.formatOnType":true, "editor.formatOnSave":tr...

wangjianbo09的博客 1万+

基于Simulink的防空导弹六自由度弹道建模与仿真实战

本文详细介绍了基于Simulink的防空导弹六自由度弹道建模与仿真方法。通过分析导弹动力学原理、Simulink环境配置、气动力建模、推进与控制系统设计等关键环节,提供了一套完整的实战指南。文章特别强调了六自由度模型在防空导弹仿真中的重要性,并分享了常见问题排查与优化建议,为相关领域工程师提供实用参考。

apple5的专栏 870

FDTD材料nk值拟合优化指南:利用材料资源管理器提升光学模型精度

本文详细介绍了如何利用FDTD仿真软件中的材料资源管理器,对材料nk值进行精确拟合与优化,从而提升光学模型的仿真精度。文章通过实战案例,解析了拟合参数调整、报告解读以及针对varFDTD求解器的特殊注意事项,帮助用户从根本上解决仿真结果不准的常见问题。

weixin_29196891的博客 360

解决方案:VSCode中配置自动格式化实现Ctrl+S自动格式化代码

Prettier 是一个 Opinionated 的代码格式化工具,它通过解析代码并使用自己的规则(考虑最大行长)重新打印代码,从而使得代码样式一致,并在必要时包装代码。一致的代码风格不仅仅有助于提高可读性,还可以减少错误和漏洞的产生。在编码中,在VSCode中配置Prettier插件并实现使用Ctrl+S自动格式化代码

白洞,白色的明天在等着我们 1万+

Mamba SSM 实战:IMDb 文本分类 + Mamba-ssm 全流程

Mamba SSM 文本分类链路:IMDb 二分类 → MambaLMHeadModel (d_model=256, n_layer=8, d_state=16, exp2=2) → 末 token 分类头。5 epoch 达 89.2% 准确率 (与 BERT-base 持平), 但显存降低 44% (3.5GB vs 6.2GB)。建议序列长度 ≥ 1024 再选 Mamba, 短序列 (< 512) 用 BERT 更高效。扩展时注意d_state。

m0_71589036的博客 61

vscode Eslint+Prettier自动格式化代码

安装插件列表 ESLint Prettier - Code formatter Prettier ESLint Vetur 配置项 settings.json { // vscode默认启用了根据文件类型自动设置tabsize的选项 "editor.detectIndentation": false, // 重新设定tabsize "editor.tabSize": 2, // #值设置为true时,每次保存的时候自动格式化;值设置为false时,代码格式化请.

qq_38571305的博客 631

《网络安全自学教程》- 802.1x协议

802.1x协议架构,工作原理/认证流程,认证方式,MAB认证,触发认证的三种方式,EAP报文格式,EAPOL报文格式

wangyuxiang946的博客 2万+

uniapp - 微信授权登录报错 errMsg“:“login:fail send“ | “code“:-100 | “innerCode“:-6,解决uni-app调用微信登录时没有响应且返回错误

uni-app,微信登录,微信登录报错,微信小程序,支付宝小程序,安卓app,苹果ios,nvue,H5网页网站,uniapp苹果安卓app,微信授权登录,uniAppAPP端微信登录报错,微信确认登录界面后点击登录报错,"errMsg":"login:failsend","errCode":-100,"code":-100,"innerCode":-6,都配置好了还是报错怎么办,uniapp微信授权登录报错,UniApph5对接微信登录出现错误,appid,应用签名,微信登陆,code:-100

🏆 前端领域优质创作者 1万+

vscode 配合 eslint 自动格式化代码

vscode 配合 eslint 自动格式化代码 1. vscode安装eslint插件 2. 打开 vscode 的配置文件—— settings.json    点击左下角的设置或者输入ctrl+shift+p 找到Open Setting JSON    安装好以后,打开 vscode 的配置文件—— settings.json ,加上下面这几行规则: { "eslint.autoFixOnSave": true, "eslint.packageManager": "yarn", "

atu1111的博客 2009

华为OD机试真题 新系统 2026-07-22 Java&Go&C 实现【最小代价完成论文评审】

某校有 n 篇论文需要分配给教师评审。 每篇论文 i 可由 files[i] 对应的教师列表中任一教师评审。 每篇论文至少需要一名教师评审。 每位教师 t 不论被分配多少篇论文,其评审费用固定为 cost[t]。 请给出参与评审教师数量最少时的总费用。 如果存在多种方案满足教师数量最少,则选择总费用最小的方案。

MISAYAONE的博客 157

vscode中eslint使用自动保存格式

1.在vscode的设置扩展中安装eslint插件 2.找到"文件" -> "首选项" -> "设置"(或者: File->Preferences->Settings ),点击右上角,切换到setting.json配置文件,替换为以下代码 { // vscode默认启用了根据文件类型自动设置tabsize的选项 "editor.detectIndentation": false, // 重新设定tabsize "editor.tabSize": 4, // #...

pengfeng111833的专栏 1629

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

vscode 使用eslint格式化代码

vscode 使用eslint格式化代码

weixin_45289656的博客 546

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

vscode代码格式化

// vscode默认启用了根据文件类型自动设置tabsize的选项 "editor.detectIndentation": false, // 重新设定tabsize "editor.tabSize": 4, // #值设置为true时,每次保存的时候自动格式化;值设置为false时,代码格式化请按shift+alt+F "editor.formatOnSave": false, // #每次保存的时候将代码按eslint格式进行修复 "eslin.

故事与我 1833

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

vscode配置代码自动格式化

{ // vscode默认启用了根据文件类型自动设置tabsize的选项 "editor.detectIndentation": false, // 重新设定tabsize "editor.tabSize": 2, // #值设置为true时,每次保存的时候自动格式化;值设置为false时,代码格式化请按shift+alt+F "editor.formatOnSave": true, // #每次保存的时候将代码按eslint格式进行修复 "eslint.autoFixOnSave": tr

weixin_44969308的博客 963

vscode的格式化问题

vscode的格式化问题一、先下载插件二、在setting.josn配置三、配置.editorconfig文件https://editorconfig.org 一、先下载插件 在插件商店中下载三个插件 Beautify、Eslint、Vetur 二、在setting.josn配置 { // tab 大小为2个空格 "editor.tabSize": 2, // 100 列后换行 "editor.wordWrapColumn": 100, // 保存时格式化 "

weixin_57750091的博客 978

VScode 代码格式化 setting.json文件内容

{ // vscode默认启用了根据文件类型自动设置tabsize的选项 “editor.detectIndentation”: false, // 重新设定tabsize “editor.tabSize”: 4, // #值设置为true时,每次保存的时候自动格式化;值设置为false时,代码格式化请按shift+alt+F “editor.formatOnSave”: false, // #每次保存的时候将代码按eslint格式进行修复 “eslint.autoFixOnSave”: true, //.

qq_33286156的博客 1008

分享一下在vscode中写前端代码的插件和setting.json的配置

这是我下载的插件,大家可以参考一下 接下来是在setting.json中的配置: 首先按cirl+shift+p,输入open setting 点击进入,将下面代码复制代替原代码 { "editor.fontSize": 16, "eslint.autoFixOnSave": true, "fileheader.LastModifiedBy": "xudanfeng", "fileheader.Author": "xudanfeng"..

weixin_53655745的博客 1598

sql格式化 vscode_vs code保存自动格式化配置

{// vscode默认启用了根据文件类型自动设置tabsize的选项"editor.detectIndentation": false,// 重新设定tabsize"editor.tabSize": 2,// #每次保存的时候自动格式化"editor.formatOnSave": true,// #每次保存的时候将代码按eslint格式进行修复// "eslint.autoFixOnSave":...

weixin_33831334的博客 1661

vscode 设置

版本一: { "editor.rulers": [ 100 ], //代码缩进线 "editor.tabSize": 2, "eslint.alwaysShowStatus": true, "eslint.autoFixOnSave": true, "eslint.packageManager": "yarn", "eslint.validate": [ "javascript", // 用eslint的规则检测j.

蓝冰凌的博客 400

VScode+ESlint 自动格式化代码(2021)

本文用 Vue 项目做示范,基于项目已有eslint环境。 利用 Vue CLI 创建项目时要将 ESlint 选上,下载完依赖后,用 VSCode 打开项目。 1、安装插件 ESLint, 2、配置eslint插件 File -> Preference-> Settings(如果装了中文插件包应该是 文件 -> 选项 -> 设置),搜索 eslint,点击 Edit in setting.json 将以下选项添加到配置文件 //配置eslint "eslint.val

Superman_peng的博客 1万+

vscode绿色、护眼色,vue自动格式化配置参考

{ "settings": { "workbench.colorTheme": "Atom One Light", "workbench.colorCustomizations": { "[Atom One Light]": { "editor.background": "#C7EDCC", "sideBar.background": "#C7EDCC", "activityBar.background": "#C7EDCC",

shalDream的博客 6680

vscode配置文件

{ “files.autoSave”: “off”, “window.zoomLevel”: 0, “editor.detectIndentation”: false, “workbench.iconTheme”: “vscode-icons”, “eslint.autoFixOnSave”: true, “eslint.validate”: [ “javascript”, “javascript...

luwenze的博客 1433

vscode setting.json

{ // vscode默认启用了根据文件类型自动设置tabsize的选项 "editor.detectIndentation": false, "workbench.iconTheme": "vscode-great-icons", "typescript.locale": "zh-CN", "editor.quickSuggestions": { "strings": true }, "javascript.format.insertSpaceBeforeFunctionParenthes

yalishandalee的专栏 168
上一篇: 报错 org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body
下一篇: 前端下载文件实现方式及跨域下载方法
JCjunior
博客等级 码龄11年 45粉丝 57原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值