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

[Custom Functions] when importing CommonJS modules, lint does not work if you do not add .js in require #233

Open
formulahendry opened this issue Feb 8, 2024 · 1 comment

Comments

@formulahendry
Copy link

formulahendry commented Feb 8, 2024

Describe the bug
When importing CommonJS modules, lint does not work if you do not add .js in require

To Reproduce

  1. Git clone from https://github.com/formulahendry/test
  2. Install vscode-spectral extension
  3. Open test-spectral\openapi.yaml file

Actual behavior
Lint does not show any error.

Expected behavior
Lint should show error message for message: aaa222: https://github.com/formulahendry/test/blob/91ea37278d2e316a74f016b06dea2b08f80e6bcb/test-spectral/openapi.yaml#L5

However,

If you run from CLI with the same rule: spectral lint .\test-spectral\openapi.yaml --ruleset .\test-spectral\test_rules\my-ruleset.yaml
Lint works!

In test-spectral\test_rules\functions\abc.js, if you add a .js in require: var { getMessages } = require("../function_utils/test.js");
Lint works!

the .js file extension should be optional when importing CommonJS modules.

Screenshots
1707378815548

Environment:

  • Extension version: 1.1.2
  • VS Code version: 1.86
  • Operating System: Windows 11

Additional context
.js should be optional in require:

@dtolb
Copy link

dtolb commented Jul 15, 2024

Same issue here for macos ...

It's not possible for me to update all the references to include the .js as the original ruleset is written in typescript and transpiled to JS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants