diff --git a/src/lint/linter/ArcanistTextLinter.php b/src/lint/linter/ArcanistTextLinter.php index f7d8206d..e1b9f6c2 100644 --- a/src/lint/linter/ArcanistTextLinter.php +++ b/src/lint/linter/ArcanistTextLinter.php @@ -123,13 +123,17 @@ final class ArcanistTextLinter extends ArcanistLinter { } protected function lintNewlines($path) { - $pos = strpos($this->getData($path), "\r"); + $data = $this->getData($path); + $pos = strpos($this->getData($path), "\r"); + if ($pos !== false) { $this->raiseLintAtOffset( - $pos, + 0, self::LINT_DOS_NEWLINE, pht('You must use ONLY Unix linebreaks ("%s") in source code.', '\n'), - "\r"); + $data, + str_replace("\r\n", "\n", $data)); + if ($this->isMessageEnabled(self::LINT_DOS_NEWLINE)) { $this->stopAllLinters(); } diff --git a/src/lint/linter/__tests__/text/dos-newline.lint-test b/src/lint/linter/__tests__/text/dos-newline.lint-test new file mode 100644 index 00000000..5ff143d0 --- /dev/null +++ b/src/lint/linter/__tests__/text/dos-newline.lint-test @@ -0,0 +1,7 @@ +The quick brown fox +jumps over the lazy dog. +~~~~~~~~~~ +error:1:1 +~~~~~~~~~~ +The quick brown fox +jumps over the lazy dog.