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

Fixing the linebreak-style eslint error for Windows #171

Closed
protoEvangelion opened this issue Mar 16, 2017 · 18 comments
Closed

Fixing the linebreak-style eslint error for Windows #171

protoEvangelion opened this issue Mar 16, 2017 · 18 comments

Comments

@protoEvangelion
Copy link
Contributor

On Windows, with the current eslint setup, you get this error: Expected linebreaks to be 'LF' but found 'CRLF'.

The eslint site says this is because Unix and Windows have two different linebreaks.

Is there a better way to fix this besides adding "linebreak-style": 0, to the .eslintrc file?

@diegohaz
Copy link
Owner

diegohaz commented Mar 16, 2017

Adding a .editorconfig plugin for your IDE/editor solves it?

This file configures the editor to add an LF on line endings: https://github.com/diegohaz/arc/blob/master/.editorconfig

You might also be interested on a React UI toolkit library I'm working on.

@protoEvangelion
Copy link
Contributor Author

I'm using atom. Do I have to wire it up somehow to make that take effect?

@ajhool
Copy link

ajhool commented Mar 17, 2017

Atom natively supports this feature (see this issue):
atom/line-ending-selector#5

Summary:
Select File->Settings
Select ‘Packages’
Under Core Packages->line-ending-selector, select ‘Settings’
Under the ‘Default line ending’ setting, choose ‘LF’ in the dropdown
You new files will now use LF as the default line ending setting. You can confirm this in the Atom status bar.

@diegohaz
Copy link
Owner

diegohaz commented Mar 17, 2017

You can also run npm run lint -- --fix to get rid of current CRLF

You might also be interested on a React UI toolkit library I'm working on.

@protoEvangelion
Copy link
Contributor Author

Thanks @ajhool and @diegohaz! Looks like changing the Atom core package setting to LF fixed it :)

@joseph-teb
Copy link

joseph-teb commented Apr 19, 2018

------------------for windows globe in package.son will read all import files---add--
"rules": {
"linebreak-style": 0,
"global-require": 0,
"eslint linebreak-style": [0, "error", "windows"],

@pashute
Copy link

pashute commented May 26, 2018

after npm install -g babel-eslint (had to repeat a few times and after closing windows, finally installed ok...)

change your .eslintrc.js to this:

module.exports = {
//extends: 'airbnb',
parser: 'babel-eslint',
env: {
  browser: true
},
plugins: ['react'],
  extends: ['eslint:recommended', 'plugin:react/recommended'],
rules: {
  // overrides
 }

};

react-native info gives me this:

Environment:
  OS: Windows 10
  Node: 8.11.1
  Yarn: 1.6.0
  npm: 6.0.1
  Watchman: Not Found
  Xcode: N/A
  Android Studio: Version  3.1.0.0 AI-173.4670197

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
 react-native: 0.55.3 => 0.55.3

@bdjunayed
Copy link

In User settings for the Vscode search crlf, and adjust your settings.

@Jaman-dedy
Copy link

I've got the same problem, it was due by the git configuration. when I commited file il the given branch, eof lf was radicaly changed into crlf. look out this link.. https://eslint.org/docs/2.0.0/rules/linebreak-style
you have to add in your .eslintrc.json in rules the following line
"linebreak-style": [2, "windows"]

@ghost
Copy link

ghost commented Feb 9, 2019

I'd the same problem. In the .eslintrc.json file change "line-break-style" to "unix". As CRLF is for Windows and LF is for unix

@RobFosterNYC
Copy link

I was told that CRLF is for Linux and LF is for windows @ghost

@EssenceOfChaos
Copy link

@RobFosterNYC - The LF setting stands for "Line Feed" and represents the \n character. This "backslash n" character represents a newline on Linux and Mac systems.

The CRLF setting stands for "Carriage Return, Line Feed" and represents the combination \r\n, which is used on Windows.

Setting the linebreak-style in .eslintrc.json to the value "unix", then running eslint --fix should automatically fix the issue.

@alejandrorossi
Copy link

------------------for windows globe in package.son will read all import files---add--
"rules": {
"linebreak-style": 0,
"global-require": 0,
"eslint linebreak-style": [0, "error", "windows"],

If problem persists, try this, but with "ESLint" instead "eslint"

@sunny775
Copy link

sunny775 commented Sep 7, 2020

Simply include this rule to your .eslintrc.js
module.exports = { rules: { 'linebreak-style': ["error", "windows"] } }

@DineshKachhot
Copy link

------------------for windows globe in package.son will read all import files---add--
"rules": {
"linebreak-style": 0,
"global-require": 0,
"eslint linebreak-style": [0, "error", "windows"],

What about Mac?

@Emmanuel-Odero
Copy link

You can also run npm run lint -- --fix to get rid of the current CRLF

@just-hope-netizen
Copy link

You can also run npm run lint -- --fix to get rid of current CRLF

You might also be interested on a React UI toolkit library I'm working on.

This solution worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

15 participants