The reason for this: under Windows environment, GIT will automatically identify the current system environment when we pull the code. Change the original (Linux/Unix) line feed to the corresponding system. When we submit the code, it will be converted to the remote system environment (Linux/Unix), and then install eslint. LF is used by default, so this error will be reported
Line feed format in various environments
window: CRLF (\R \n or ^m \n)
MAC: Cr (\R or ^m)
linux/Unix: LF (\n)
Solution:
1. Manually cut the CRLF at the bottom of the vscode file code into LF, which can only make eslint not report errors for the time being. But in fact, when we pull down again, GIT will automatically convert all files to CRLF, and there will still be an error message
2. Rule configuration in eslint. Turn off line feed verification in the window environment and let it automatically convert CRLF to LF when submitting (it seems that we haven’t fundamentally solved this problem)
"linkbreak-style":["off","windows"]
3. When git pulls the code, let git pull according to the line feed (LF) of the remote code, and no longer convert the format according to the system. At the same time, configure the line feed character of vscode as LF. My approach is to configure the pull format of GIT, delete the whole local original warehouse, and then pull a code remotely again. This is OK. The command is as follows:
git config –global core. Autocrlf has three configurations (depending on the situation, I chose input)
True: automatically convert CRLF to LF when pushing, and CRLF when pulling (this configuration requires configuring eslint to turn off line break verification in window environment)
git config --global core.autocrlf true
Input: CRLF is automatically converted to LF when pushing, but LF is not automatically converted to CRLF when pulling (this configuration does not need to configure eslint, and the code format is consistent with that of the remote. I use this)
git config --global core.autocrlf input
False: no matter push or pull, the original file is what it is
git config --global core.autocrlf false
Other configurations:
1. Reject submission of files containing mixed line breaks
git config --global core.safecrlf true
2. Allow submission of files containing mixed line breaks
git config --global core.safecrlf true
3. Warn when submitting files containing mixed line breaks
git config --global core.safecrlf warn
vscode deployment:
Read More:
- Vue Project Error: Expected indentation of 2 spaces but found 4,Newline required at end of file but not found
- [Solved] Vue3.0 Error: The component has been registered but not used vue/no-unused-components, Close eslint
- [Solved] Vue Less error: Webpack project report expected indentation of 0 spaces but found 2
- [Solved] Vue eslint Error: Component name “*****“ should always be multi-word
- [Solved] ESLint error: Newline required at end of file but not found (eol-last)
- [Solved] Vue Project startup error: no eslint configuration found
- [Solved] Syntax Error: Error: No ESLint configuration found & TypeError: eslint.CLIEngine is not a constructor
- How to Solve Vscode save Vue file eslint error
- [Solved] 20:1 error Expected indentation of 2 spaces but found 4 indent 21:1 error Expected indent
- Vscode save Vue format eslint check error [How to Solve]
- Vue: How to Solve Eslint error
- [Solved] Vue 3 Script Setup ESLint Error: ‘defineProps‘ is not defined
- [Solved] Vue2.0 Error: Syntax Error: TypeError: eslint.CLIEngine is not a constructor
- vue eslint error ‘process‘ is not defined no-undef [How to Solve]
- [Solved] ESlint Create New File Error: Component name “Home” should always be multi-word.
- [Solved] vue Project Error: react lazy eslint error Parsing error: Unexpected token import
- Vue3.0 error: Failed to resolve component el-form-item (el element to be unable to be displayed)
- eslint Error: Delete `␍` [How to Solve]
- [Solved] Vite Error: Failed to load module script: Expected a JavaScript module script but the server…
- Newline required at end of file but not found eol-last [How to Solve]