caliper
caliper copied to clipboard
ESLint `linebreak-style` Configuration Causes Errors on WindowsOS
Which Caliper version are you using?
latest
Which Node.JS version are you using?
v21.7.3
Which operating system are you using?
Windows 10 Pro
Please provide some context for your error. For example, when did the error occur? What were you trying to achieve, and how?
While setting up the project on a Windows machine, I encountered an issue with the ESLint configuration. The project is set up to use Unix-style linebreaks (LF), which works fine on Unix-based systems. However, when the project is set up on a Windows machine, ESLint throws an error because Windows uses a different linebreak style (CRLF).
I've been creating tests for the Project and recently switched to Windows from MacOS. Hence, facing these issues.
What was the observed incorrect behavior?
The project should be set up without any ESLint errors on both Unix and Windows systems. However, this was not observed when testing was performed.
Please provide the error logs and their surroundings.
48:66 error Expected linebreaks to be 'CRLF' but found 'LF' linebreak-style
49:61 error Expected linebreaks to be 'CRLF' but found 'LF' linebreak-style
50:8 error Expected linebreaks to be 'CRLF' but found 'LF' linebreak-style
51:4 error Expected linebreaks to be 'CRLF' but found 'LF' linebreak-style
Please provide your benchmark configuration file content, if possible.
No response
Please provide your network configuration file content, if possible.
No response
Please provide your workload module content, if possible.
No response
Please provide any additional information you deem relevant to the error.
Error originates from .eslintrc.yml configs at following lines :
linebreak-style:
- error
- unix
Locally, I tried changing it to windows but was encountered with yet another error as follow when I ran npm run test:
> @hyperledger/[email protected] nyc
> nyc --reporter=text --reporter=clover mocha --recursive -t 10000
node:internal/modules/cjs/loader:1145
throw err;
^
Error: Cannot find module 'C:\Users\Prayag\Abhinav\Software-Development\caliper\packages\caliper-ethereum\node'
at Module._resolveFilename (node:internal/modules/cjs/loader:1142:15)
at Module._load (node:internal/modules/cjs/loader:983:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
That second error log doesn't look like linting error you just need to do npm i and install all the packages first and about first error log we can change it to something like
linebreak-style: ["error", (process.platform === "win32" ? "windows" : "unix")]
in .eslintrc.yml
I'd like to make changes if needed // @davidkel
We can't proceed with these changes. This is not a valid .yml syntax. First, you'd have to change the .eslintrc.yml to .eslintrc.js to apply these changes. Afterhand, using .yml is much more preferred than using .js template. Notice how the previous developers have favoured the utilization of .yml files THROUGHOUT the project.
That second error log doesn't look like linting error you just need to do npm i and install all the packages first
It's an error that arises EVEN after I changed the configs as you have described.
We can't proceed with these changes. This is not a valid
.ymlsyntax. First, you'd have to change the.eslintrc.ymlto.eslintrc.jsto apply these changes. Afterhand, using.ymlis much more preferred than using.jstemplate. Notice how the previous developers have favoured the utilization of.ymlfiles THROUGHOUT the project.
Ofc that was just an idea 🙂 you can very well change that to yml syntax
Sorry but windows is not a supported platform for caliper development. It can be made to work (and it would not require a change to the eslint rules which should remain as they are) but we don't document how and don't have the bandwidth to maintain a windows development environment. It will be left as an exercise to the contributor to sort out for themselves.
As a windows pro user you have loads of alternatives here
- use WSL2 as your linux environment. This is what I do and use the WSL2 file system for storing git repo's, not the windows file system (as a WSL2 environment can see the windows file system). Then use vscode which can run inside of WSL2 (even if you installed the windows version)
- use HyperV Manager and create a fully fledged Linux VM and work in the VM
- use Multipass to create a fully fledged Linux VM and work in the VM.
There is also the option of using dev containers (there is a extension you can get for vscode to provide that support) directly from windows but then it will try to use the windows file system for the repo which means you need to have made sure you sorted out your git environment to properly clone a repo (see https://hyperledger-fabric.readthedocs.io/en/release-2.5/prereqs.html#git-for-windows-optional) otherwise linting will fail.
For you I think option 1 is by far the best and easiest approach.
Also one further thing, please note that node js 21 is not a supported node runtime as it is not an LTS version. We currently support Node 18 and 20 LTS versions. Node 22 will move to LTS around October/November time this year and at that point we would need to look into being able to support that version.
I final point, you've probably not configured git to handle linefeeds correctly in windows you need to stop git from doing auto conversion to crlf, plus also handle long paths.
git config --global core.autocrlf false
git config --global core.longpaths true
Resolved