Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint 根据操作系统决定合理的换行符样式 #189

Closed
Dream4ever opened this issue Apr 21, 2022 · 0 comments
Closed

ESLint 根据操作系统决定合理的换行符样式 #189

Dream4ever opened this issue Apr 21, 2022 · 0 comments

Comments

@Dream4ever
Copy link
Owner

问题描述

目前一直在 Windows 下进行 Web 开发,但是部分项目中用到的 ESLint 默认要求换行符格式为 LF,而 Windows 下创建的文件,换行符格式默认是 CRLF,这样 ESLint 就总会报告说文件的换行符不正确。

解决方案

Google eslint linebreak-style cr crlf 找到了解决方案:How can I write a ESLint rule for "linebreak-style", changing depending on Windows or Unix?,用下面的代码,让 ESLint 根据当前操作系统来决定什么样的换行符是合法的。

"rules": {
  "linebreak-style": ["error", (process.platform === "win32" ? "windows" : "unix")],
}
@Dream4ever Dream4ever changed the title ESLint 随操作系统决定合理的换行符样式 ESLint 根据操作系统决定合理的换行符样式 Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant