xxxxxxxxxx
import os
# Specify the file path
file_path = 'path/to/your/file.txt' # Replace with the actual file path
# Read the file content
with open(file_path, 'rb') as file:
content = file.read().decode('utf-8')
# Replace 'crlf' line endings with 'lf'
content = content.replace('\r\n', '\n')
# Write the modified content back to the file
with open(file_path, 'wb') as file:
file.write(content.encode('utf-8'))
xxxxxxxxxx
git config core.autocrlf false
git rm --cached -r .
git reset --hard
Never look this up again
xxxxxxxxxx
Check if you have the linebreak-style rule configure as below either in your .eslintrc or in source code:
/*eslint linebreak-style: ["error", "unix"]*/
Since you're working on Windows, you may want to use this rule instead:
/*eslint linebreak-style: ["error", "windows"]*/
xxxxxxxxxx
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
xxxxxxxxxx
# Assuming the developer is working with a text file
with open('file.txt', 'r', newline='\r\n') as file:
content = file.read()
# Replace 'CRLF' line breaks with 'LF'
content = content.replace('\r\n', '\n')
# Do something with the updated content...