prettier

How to configure Vue CLI 4 with ESLint + Prettier + Airbnb rules + TypeScript + Vetur?

拈花ヽ惹草 提交于 2020-03-17 07:38:21
问题 When creating a new project with Vue CLI v4.0.5 with checking the options for TypeScript and Linter / Formatter , you are given pre-configured options for linting and formatting: ? Pick a linter / formatter config: (Use arrow keys) > ESLint with error prevention only ESLint + Airbnb config ESLint + Standard config ESLint + Prettier TSLint (deprecated) I want to use Airbnb rules for ESLint with Prettier (format-on-save), with TypeScript parser and Vue CLI v4 . These configurations should also

How to configure Vue CLI 4 with ESLint + Prettier + Airbnb rules + TypeScript + Vetur?

二次信任 提交于 2020-03-17 07:38:06
问题 When creating a new project with Vue CLI v4.0.5 with checking the options for TypeScript and Linter / Formatter , you are given pre-configured options for linting and formatting: ? Pick a linter / formatter config: (Use arrow keys) > ESLint with error prevention only ESLint + Airbnb config ESLint + Standard config ESLint + Prettier TSLint (deprecated) I want to use Airbnb rules for ESLint with Prettier (format-on-save), with TypeScript parser and Vue CLI v4 . These configurations should also

Delete `␍`eslint(prettier/prettier) 错误的解决方案

不打扰是莪最后的温柔 提交于 2020-03-11 11:02:11
原因在于git的一个配置属性:core.autocrlf windows下和linux下的文本文件的换行符不一致 Windows在换行的时候,同时使用了回车符CR(carriage-return character)和换行符LF(linefeed character) 而Mac和Linux系统,仅仅使用了换行符LF 老版本的Mac系统使用的是回车符CR 因此,文本文件在不同系统下创建和使用时就会出现不兼容的问题 我的项目仓库中默认是Linux环境下提交的代码,文件默认是以LF结尾的(工程化需要,统一标准)。 当我用windows电脑git clone代码的时候,若我的autocrlf(在windows下安装git,该选项默认为true)为true,那么文件每行会被自动转成以CRLF结尾,若对文件不做任何修改,pre-commit执行eslint的时候就会提示你删除CR。 解决办法: 删除clone文件, windows,文件编码是UTF-8且包含中文,最好全局将autocrlf设置为false 添加配置 git config --global core.autocrlf false 再重新拉取 备注: git core.autocrlf(格式化) Git可以在你提交时自动地把行结束符CRLF转换成LF,而在签出代码时把LF转换成CRLF。用 core.autocrlf

推荐VSCode12个比较实用的插件

泪湿孤枕 提交于 2020-02-27 20:31:11
1、Auto Rename Tag ——自动重命名成对的HTML标记。假如你创建了一个<p>标记。现在你想更改它。有了这个软件,你只需要更改一个就行,另一个会自动修改。从理论上来说,使用这个软件可以把你的工作效率提升一倍。 2、HTML CSS Support ——HTML文档的CSS支持工具。该工具在获得一些简洁的语法高亮显示和代码建议方面非常有用。 3、HTML Snippets ——这一工具在代码分段方面非常有用,可以为你节省大量的时间。它能跟Emmet配对,这样一来你甚至都不用再真正键入HTML了。 4、Babel ES6/ES7 ——JavaScript Babel的辅助工具。如果你用的是Babel,这个工具可以让你更容易区分代码。如果你喜欢JavaScript,那务必也不要错过这款软件。 5、Bracket Pair Colorizer ——色彩可视化工具。如果你没有准确地括号,那这个工具对于发现因此导致的许多常见漏洞十分方便。 6、ESLint ——你在编写代码的时候,利用这个软件可以轻易获取有关漏洞的提示,而且在编码过程中,它还可以帮助你养成良好的编码习惯。 7、Guides ——这一工具可以被用来添加额外的指导行代码。这是另一个视觉提示,以确保你正确地括号了。 8、JavaScript Console Utils ——使控制台日志记录变得更为简单可行

请把 .gitattributes 加到你的 Git 仓库中

拈花ヽ惹草 提交于 2020-02-27 08:44:50
什么是 .gitattributes ? 当执行 git 动作时,.gitattributes 文件允许你指定由 git 使用的文件和路径的属性,例如: git commit 等。 换句话说,每当有文件保存或者创建时,git 会根据指定的属性来自动地保存。 其中的一个属性是 eol (end of line),用于配置文件的结尾。本文将会深入了解如何配置文件的结尾行,这样的话,即使在不同的机器、操作系统 上都可以使得每个开发者都可以使用相同的值。 为什么是 .gitattributes(开发者之间的争议 ⚔️ )? 不是所有的开发者都是一样的,不能因为你是在 Windows 上使用 Visual Studio Code 开发的,就期望别的 Pull Request 也是基于相同的开发 环境完成的(在 MacOS 上可能用的是 Sublime Text2)。 正如上面提到的,开发者使用不同的操作系统,默认的文件结尾行就会不同。在 Windows 上默认的是回车换行(Carriage Return Line Feed, CRLF),然而,在 Linux/MacOS 上则是换行(Line Feed, LF)。 从表面看起来,内容都是一样的,那我们为什么还会困扰呢??? 好的,如果你启用了该功能,并设置属性 endOfLine 为 lf 的话。 { "endOfLine" : "lf" }

How can I synchronise eslint or setup similar tslint and prettier with typescript?

让人想犯罪 __ 提交于 2020-02-02 13:01:45
问题 I've an existing React/Redux project and I've started using typescript in my project. I've already setup my eslint configuration for the project which extends the airbnb eslint configurations. My eslint is as follows: module.exports = { "parser": "babel-eslint", "extends": [ "airbnb", "plugin:flowtype/recommended" ], "plugins": [ "react", "jsx-a11y", "flowtype" ], "env": { "browser": true, "node": true, "es6": true }, "globals": { "__DEV__": true, "__SERVER__": true, "__": true, "define":

How to fix 'Static HTML elements with event handlers require a role.'?

笑着哭i 提交于 2019-12-22 05:35:34
问题 My reactjs styledcomponent contains this code: <a styling="link" onClick={() => this.gotoLink()}> <SomeComponent /> </a> This works fine but the eslint is complaining: Static HTML elements with event handlers require a role. How can I fix this error? 回答1: you need to add a role props in your a tag to avoid this warning, for example a button <a role = "button" styling="link" onClick={() => this.gotoLink()}> <SomeComponent /> </a> I guess it is because the HREF props is missing in your anchor

Can't get correct autoformat on save in Visual Studio Code with ESLint and Prettier

China☆狼群 提交于 2019-12-20 08:35:19
问题 in Visual Studio Code with ESLint and Prettier when working on .vue files, it seems I can't get vue/max-attributes-per-line to auto-fix correctly. For example, with vue/max-attributes-per-line set to 'off', and I try to add line breaks manually it corrects it to always have every element on no more than one line, no matter if it is 81, 120, 200, or more characters wide. How can I figure out what is forcing my markup elements onto exactly one line? I am using ESLint version 5.1.0 and Visual

Prettier/VSCode Eslint weird format/syntax breaking bug

纵饮孤独 提交于 2019-12-19 06:28:31
问题 Sometimes when I startup VSCode and I save an JS file, everything gets messed up. example From: To: On save What I found out: When I change a VSCode User setting (something related to the prettier plugin | anything (I normally change the prettier.eslintIntegration but it could be that any change in the setting resolves it)) it stops breaking on save. Possible related environment details // Part of .eslintrc { parser: 'babel-eslint', extends: ['airbnb', 'prettier'], plugins: ['prettier'],

Running into “couldn't infer parser” error using vue-cli

…衆ロ難τιáo~ 提交于 2019-12-18 13:24:35
问题 I'm getting an error repeatedly when trying to build a new webpack project using vue-cli . I'm following along with the docs on the latest build (3.0.0-beta.11), also tried with an earlier version, which wasn't beta. When I run yarn serve it attempts to start the dev server and build the project but fails here: error in ./src/App.vue?vue&type=template&id=7ba5bd90 Module build failed: Error: No parser and no file path given, couldn't infer a parser. at normalize (/Users/cory/Code/chickadee/my