Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint linebreak-style Configuration Causes Errors on WindowsOS #1580

Open
Sweetdevil144 opened this issue May 21, 2024 · 6 comments
Open

ESLint linebreak-style Configuration Causes Errors on WindowsOS #1580

Sweetdevil144 opened this issue May 21, 2024 · 6 comments
Labels
wontfix This will not be worked on

Comments

@Sweetdevil144
Copy link

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/caliper-ethereum@0.6.1-unstable 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: []
}
@duckling69
Copy link
Contributor

duckling69 commented May 22, 2024

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

@Sweetdevil144
Copy link
Author

Sweetdevil144 commented May 22, 2024

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.

@Sweetdevil144
Copy link
Author

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.

@duckling69
Copy link
Contributor

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.

Ofc that was just an idea 🙂 you can very well change that to yml syntax

@davidkel
Copy link
Contributor

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

  1. 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)
  2. use HyperV Manager and create a fully fledged Linux VM and work in the VM
  3. 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.

@davidkel
Copy link
Contributor

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.

@davidkel davidkel added the wontfix This will not be worked on label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants