Skip to content

Commit

Permalink
Docs: add note about git's linebreak handling to linebreak-style docs (
Browse files Browse the repository at this point in the history
…#8361)

This commit adds a note to the linebreak-style docs about how git handles linebreaks on windows, and suggests using a `.gitattributes` file to control git's behavior.

(refs #7823)
  • Loading branch information
not-an-aardvark committed Mar 30, 2017
1 parent 5878593 commit 8569a90
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/rules/linebreak-style.md
Expand Up @@ -67,9 +67,19 @@ function foo(params) { // \r\n
} // \r\n
```

## Using this rule with version control systems

Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.

For example, the default behavior of [git](https://git-scm.com/) on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the `linebreak-style` rule to report errors if configured with the `"unix"` setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your [`.gitattributes` file](https://git-scm.com/docs/gitattributes) to prevent git from converting linebreaks in `.js` files:

```
*.js text eol=lf
```

## When Not To Use It

If you aren't concerned about having different line endings within you code, then you can safely turn this rule off.
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.

## Compatibility

Expand Down

0 comments on commit 8569a90

Please sign in to comment.