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

tools: yaml lint command in vcbuild script #48422

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

lutaok
Copy link
Contributor

@lutaok lutaok commented Jun 11, 2023

Hello everyone,
I'm opening this PR hoping it could be an enhancement for Windows contributors.

To give this a little context, when I was working on #48184 , I noticed that lint-yaml was run by a Github Action, but it was not present in the vcbuild.bat script that I used for building and linting files.

Following things were changed:

  • lint-yaml was added as a command in vcbuild script and it is executed through the Makefile corresponding command.
  • lint-yaml step was also added and enabled for execution on test and lint commands.
  • Made wsl make preferred for executing Makefile command on lint-cpp and lint-yaml because of Square brackets not being recognizable by Windows as a command.
  • Added lint-yaml reference to the help command.
  • Deleted an eslint text file in order to make lint-js command work again. lint-js execution would look at that file, throw a Syntax Error that onFatalError in eslint.js would catch and make the linter execution stop.
  • Disabled new-lines type checking from .yamllint.yaml in order to make linter work on Windows even though the execution was started on a Unix system (such as WSL). I think this could be re-enabled if we are able to use GNU Make instead of WSL to lint those files.

I also have two questions:

  • I noticed that lint command would skip the build process if it's already built, is this a behaviour that could be replicated for each lint-X command?
  • Regarding change no. 3, what's the best path to follow here? Makefile command accounting for Windows systems that can call it or just stick with WSL make and get rid of the GNU Make option?

Thanks for your attention!

@nodejs/build

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. tools Issues and PRs related to the tools directory. windows Issues and PRs related to the Windows platform. labels Jun 11, 2023
@marco-ippolito marco-ippolito changed the title Add Yaml Lint command in vcbuild script tools: yaml Lint command in vcbuild script Jun 11, 2023
@marco-ippolito marco-ippolito changed the title tools: yaml Lint command in vcbuild script tools: yaml lint command in vcbuild script Jun 11, 2023
@Trott
Copy link
Member

Trott commented Jun 18, 2023

  • Deleted an eslint text file in order to make lint-js command work again. lint-js execution would look at that file, throw a Syntax Error that onFatalError in eslint.js would catch and make the linter execution stop.

I might be misunderstanding what's going on here, but I think that file will likely be re-added the next time eslint is updated. Regardless, lint-js should not be linting files that do not have a .*js suffix, so I'm not sure why it was causing a problem. (Like I said, I might just be not understanding what's going on here.)

@lutaok
Copy link
Contributor Author

lutaok commented Jun 20, 2023

  • Deleted an eslint text file in order to make lint-js command work again. lint-js execution would look at that file, throw a Syntax Error that onFatalError in eslint.js would catch and make the linter execution stop.

I might be misunderstanding what's going on here, but I think that file will likely be re-added the next time eslint is updated. Regardless, lint-js should not be linting files that do not have a .*js suffix, so I'm not sure why it was causing a problem. (Like I said, I might just be not understanding what's going on here.)

Thank you for your response :)
I've investigated this problem more in depth and I found out that eslint text file wasn't the real problem. I'm sorry that I made the wrong assumptions.

I'll try to reconstruct my steps:

  • launch command lint-js from vcbuild.bat file -> Immediate Syntax Error on that eslint text file. In the error stack though there's a reference to tools\node_modules\eslint\node_modules\eslint-plugin-jsdoc\dist\rules\checkExamples.js:8:15 which is a require("eslint")
  • when that lines executes it always points back to the eslint text file, instead of actually pointing to tools\node_modules\eslint\lib\eslint\eslint.js
  • If I manually make the require go look for tools\node_modules\eslint\lib\eslint\eslint.js (with relative paths) then linting Javascript files works fine.

I wanted to bring this up before making any changes because I have no evidence this could work on other OSs where I suppose everything works great already.
Is require working differently between OSs? If so, do you think that replacing that require with relative paths could be a good solution?

Thank you again for your time and consideration!

@Trott
Copy link
Member

Trott commented Jun 23, 2023

This could use some more reviews. @nodejs/linting @nodejs/platform-windows

@targos
Copy link
Member

targos commented Jun 24, 2023

  • Deleted an eslint text file in order to make lint-js command work again. lint-js execution would look at that file, throw a Syntax Error that onFatalError in eslint.js would catch and make the linter execution stop.

I might be misunderstanding what's going on here, but I think that file will likely be re-added the next time eslint is updated. Regardless, lint-js should not be linting files that do not have a .*js suffix, so I'm not sure why it was causing a problem. (Like I said, I might just be not understanding what's going on here.)

This file is a symbolic link. On Windows, symlinks are disabled by default and must be enabled manually.

@lutaok
Copy link
Contributor Author

lutaok commented Jul 29, 2023

Sorry for the late reply.
I've reverted the changes on the Eslint file. Enabling Symlinks by activating Developer Mode on Windows actually made lint-js command work.
Thanks for the suggestion!

.yamllint.yaml Outdated Show resolved Hide resolved
lutaok added a commit to lutaok/node that referenced this pull request Sep 16, 2023
@lutaok lutaok requested a review from Trott October 8, 2023 13:28
@aduh95
Copy link
Contributor

aduh95 commented May 11, 2024

This needs a rebase.

Yaml linting was missing for windows users.
Reversed evaluation order for wsl and GNUMake of lint-yaml and lint-cpp.
Makefile not fully compatible with Windows, so WSL is now preferred.
Added "lint-yaml" command reference into "help" command.
Added "lint-yaml" step to "test" and "lint" commands.
vcbuild lint-js command would always fail on Windows.
eslint.js would inspect the deleted file and throw Syntax Error.
Since it didn't seem a meaningful file, it got deleted.
This reverts commit 4dbc523d0027b4918fa292438d7d0ce5dc387f93.
@lutaok
Copy link
Contributor Author

lutaok commented May 15, 2024

This needs a rebase.

Done, thank you for the reminder! I've been away from my Windows setup for a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. tools Issues and PRs related to the tools directory. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants