prettier

vscode : rearrange code for js / ts files [closed]

懵懂的女人 提交于 2019-12-13 02:49:23
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 25 days ago . How can I rearrange the code in a .js / .ts file in Vscode? For example inside a Class, I want it to automatically put static variables at the top, then variables, then methods, etc. I tried to google "vscode rearrange code" but it always point to Prettier, which does NOT do that. Now maybe this feature doesn't

How to Edit Auto-Formatting Rules for CSS/SCSS/LESS using Prettier in VSCode?

て烟熏妆下的殇ゞ 提交于 2019-12-12 11:19:33
问题 Background: I'm using Prettier - Code formatter extension for VSCode to auto-format my code on save. Problem: I'm used to writing single-line blocks in my sass files (where there's only a single property) i.e. .some-class { background: #f00; } Problem is the Prettier extension formats it to multi-lines i.e. .some-class { background: #f00; } It seems prettier uses stylelint for css/scss files and I've found these settings can be over-written by enabling this in the settings: "prettier

VScode安装后的插件安装

冷暖自知 提交于 2019-12-11 22:02:34
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Chinese(Simplified) Language Pack for Visual Stidio Code 中文汉化包 对于一些英文不太好的小伙伴,上来第一件事肯定是要切换成中文语言环境,安装汉化包插件之后,按快捷键Ctrl+Shift+P调出命令面板,输入Configure Display Language,选择zh-ch,然后重启vs code即可。 open-in-browser 在浏览器中查看 VS Code没有提供直接在浏览器中运行程序的内置功能,所以我们需要安装此插件,在浏览器中查看我们的程序运行效果。 Live Server 实时预览 安装这个插件之后,我们在编辑器中修改代码,按Ctrl+S保存,修改效果就会实时同步,显示在浏览器中,再不用手动刷新。 Auto Close Tag 自动闭合标签 输入标签名称的时候自动生成闭合标签,特别方便。 Auto Rename Tag 尾部闭合标签同步修改 自动检测配对标签,同步修改。 Bracket Pair Colorizer 用不同颜色高亮显示匹配的括号 对配对的括号进行着色,方便区分,未安装该插件之前括号统一都是白色的。 Highlight Matching Tag 高亮显示匹配标签 这个插件自动帮我们将选中的匹配标签高亮显示,再也不用费劲查找了

WebStorm: configure Prettier to use tabs?

耗尽温柔 提交于 2019-12-11 10:12:17
问题 The Prettier docs say to use --use-tabs to override the default behavior. WebStorm automatically populated the Prettier package: That's a folder. I tried changing it to npm\prettier.cmd and adding the switch, but that doesn't work (It just turns red). How can I set WebStorm to use tabs with Prettier? 回答1: Due to https://github.com/prettier/prettier/pull/2434 fix, Prettier (even global!) uses configuration file nearest to current file (up the directory tree) when formatting. So, you can

Missing return type on function - in react (typescript) code

扶醉桌前 提交于 2019-12-10 15:43:19
问题 In my App.tsx i got this: Missing return type on function.eslint(@typescript-eslint/explicit-function-return-type) And in my main class component i got these: Missing accessibility modifier on method definition render.eslint(@typescript-eslint/explicit-member-accessibility) Missing return type on function.eslint(@typescript-eslint/explicit-function-return-type) I'm using React with TypeScript. For linter I use ESLint and for code formating Prettier. I found this info: https://github.com

实例详解Vue项目使用eslint + prettier规范代码风格

╄→гoц情女王★ 提交于 2019-12-09 10:29:50
团队开发的项目,如果没有对代码风格作要求,有多少团队成员,就当然会出现多少种不同的代码风格。因此,我们需要一种能够统一团队代码风格的工具,作为强制性的规范,统一整个项目的代码风格。 幸好,我们有 eslint 和 prettier 。 eslint VS prettier 应该大多数项目都已经采用eslint来对代码进行质量检查,可能少部分还会采用其进行一定程度上的统一风格。那为什么还需要prettier呢?我们先来对它们作一个简单的了解。 各种linters 总体来说,linters有两种能力: 检查代码质量 ,比如是否有已定义但未使用的变量,或者使用函数式编程的函数是否产生副作用等。 检查代码风格 ,比如每行的最大长度,或者是否使用拖尾逗号等。 其中,eslint文档中,带扳手图标的规则就是eslint能够自动修复的规则。而不带该图标的规则,eslint则只能给出错误或警告,随后由开发者人工修复。 prettier pretter没有对代码的质量进行检查的能力,其只会对代码风格按照指定的规范进行统一,避免一个项目中出现多种不同的代码风格。 项目配置 此处使用vue项目作为例子 一、首先配置eslint 如果大家的项目是使用vue cli生成的,并且选择使用eslint的话,那么默认在项目根目录下就会生成.eslintrc.js。如果没有,也可以在项目根目录下创建该文件以及

我为什么推荐Prettier来统一代码风格

落花浮王杯 提交于 2019-12-07 14:30:07
译者按: 关于代码风格,不同的人有不同的偏好,其实并没有什么绝对的对错。但是,有 2 条原则应该是对的: 少数服从多数;用工具统一风格。 原文: Why robots should format our code for us 译者: Fundebug 为了保证可读性,本文采用意译而非直译。另外,本文版权归原作者所有,翻译仅用于学习。 我曾经以为,程序员有自己独特的代码风格挺好的。因为,一个成熟的程序员应该清楚,好的代码应该是怎样的。 我的大学教授告诉我,他的学生在用我的代码,因为我的代码风格不一样。我想了一下,也许是因为我的代码至少是有风格的,而其他人的代码一团糟。 一些示例 示例 1: 读了 The Programmers’ Stone 之后,我把大括号这样写: if (food === 'pizza') { alert('Pizza ;-)'); } else { alert('Not pizza ;-('); } 但是,我意识到在前端社区里,也许只有我一个人这样写的。而其他人都是这样写的: if (food === 'pizza') { alert('Pizza ;-)'); } else { alert('Not pizza ;-('); } 或者这样: if (food === 'pizza') { alert('Pizza ;-)'); } else { alert(

Prettier in VS Code formatting (new lines before arguments)

99封情书 提交于 2019-12-07 06:12:07
问题 I'm using Angular Essentials by John Papa - in particular, Tslint and Prettier. For some reason, it transforms this code this.rM.hA = this.rM.startHA + 2 * diffX * 360 / size; this.rM.vA = Math.max(Math.min(this.rM.startVA + 2 * diffY * 180 / size, 90), -90); into this this.rM.hA = this.rM.startHA + 2 * diffX * 360 / size; this.rM.vA = Math.max( Math.min( this.rM.startVA + 2 * diffY * 180 / size, 90 ), -90 ); How can i avoid it? I've tried to play with tslint.json settings: "max-line-length":

TSLint not working with CRA and TypeScript

安稳与你 提交于 2019-12-06 23:23:28
问题 I'm banging my head for hours trying to enable linting for a TypeScript project created with create-react-app. The wmonk/create-react-app-typescript repo is now deprecated Therefore, I followed these instructions from the CRA documentation The issue is that the suggested implementation above doesn't add any linting to the newly created project. So far I've tried: Installing TypeScript TSLint Plugin as an extension to my VSCode Creating a tslint.json file on my project with the following

Prettier in VS Code formatting (new lines before arguments)

丶灬走出姿态 提交于 2019-12-05 12:58:19
I'm using Angular Essentials by John Papa - in particular, Tslint and Prettier. For some reason, it transforms this code this.rM.hA = this.rM.startHA + 2 * diffX * 360 / size; this.rM.vA = Math.max(Math.min(this.rM.startVA + 2 * diffY * 180 / size, 90), -90); into this this.rM.hA = this.rM.startHA + 2 * diffX * 360 / size; this.rM.vA = Math.max( Math.min( this.rM.startVA + 2 * diffY * 180 / size, 90 ), -90 ); How can i avoid it? I've tried to play with tslint.json settings: "max-line-length": [true, 165] But that one does not affect in my case. EDIT: as following the similar issue I've tried