Next 11.0.1 forces wrong line-endings on Windows in next-env.d.ts
See original GitHub issueWhat version of Next.js are you using?
@latest v11.0.1
What version of Node.js are you using?
@latest-ish v15.14.0
What browser are you using?
Chrome
What operating system are you using?
Windows 10 x64
How are you deploying your application?
Vercel
Describe the Bug
Next 11 writes next-env.d.ts
all the time, but it uses *nix style line endings:
Expected Behavior
*Don’t manually force line-endings to CR
*Respect .gitattributes
file (explictly specificing CR LF)
*Respect operating-system preference (CR LF on Windows)
To Reproduce
- Throw Prettier errors using this configuration:
prettier.config.js
module.exports = {
// These settings are handled in .editorconfig:
tabWidth: 2, // indent_size = 2
useTabs: false, // indent_style = space
endOfLine: "lf", // end_of_line = lf
semi: false, // default: true
singleQuote: false,
printWidth: 80,
trailingComma: "es5",
bracketSpacing: true,
}
.eslintrc.js
module.exports = {
extends: [
"eslint:recommended",
"plugin:prettier/recommended",
],
rules: {
"prettier/prettier": "error",
},
}
Preferable solution: Ask some of your engineers to switch to Windows full-time
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Detect line endings in next-env.d.ts #27039 - GitHub
If a developer on a Windows machine uses a file committed by a developer on a Mac for instance, this causes an unnecessary...
Read more >Force LF line ending on auto generated file next-env.d.ts on ...
The file is auto generated by Next.js. Webstorm on Windows 10. Line separator in Settings > Editor > Code Style is set to...
Read more >How to force consistent line endings in Git commits with cross ...
Q1 Enforcing consistent lineendings. Q2 Enforcing at commit as well as checkout (comment). I'll divide this into 2 parts: Practice and ...
Read more >jest-runtime | Yarn - Package Manager
Jest will set process.env.NODE_ENV to 'test' if it's not set to something else. You can use that in your configuration to conditionally setup...
Read more >Next.js 12 - Hacker News
I'm building a custom server (which hopefully now can be replaced with middleware?) which I build with tsc: $ tsc --strict --esModuleInterop -- ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, this has been updated in
v11.1.3-canary.25
of Next.js, please update and give it a try!@thadeucity In my projects I use
.editorconfig
,prettier.config.js
, and.gitattributes
to all force LF, because otherwise ESLint will error on CR/LF line ending with the settingprettier/prettier: "error"
.The
.editorconfig
will force LF on file save in VS Code (while the Prettier VS code extension will not), but the files will still get cloned down with CRLF and all have errors (until runningeslint --fix .
orprettier --write .
) without the.gitattributes
file.(For anyone else having this issue, I posted a thorough discussion of it over in @tailwindlabs/tailwindcss#3760.)
For this
.next-env.d.ts
bug on Windows, here’s the relevant code usingos.EOL
.@packages/next/lib/typescript/writeAppTypeDeclarations.ts
: https://github.com/vercel/next.js/blob/26105e285de056ff59ea3597a4b2d1293f82b5cf/packages/next/lib/typescript/writeAppTypeDeclarations.ts#L1-L27To fix this, I guess the system would have to query the Prettier.config.js (or other named files, i.e. by importing prettier if found and using its configuration file as is done here: https://github.com/prettier/prettier-eslint/blob/c62769ef430749fb9650c7e1d05f5cf7442a48a2/src/index.js#L255-L263
This would seem to start becoming quite a difficult problem, though, since line endings can be set in
.editorconfig
,prettier.config.js
,.prettierrc
,.eslintrc
(not recommended due to compatibility issues with VS Code Prettier extension), etc., not to mention.gitattributes
.