[Custom Functions] when importing CommonJS modules, lint does not work if you do not add `.js` in `require`
formulahendry opened this issue · comments
Describe the bug
When importing CommonJS modules, lint does not work if you do not add .js
in require
To Reproduce
- Git clone from https://github.com/formulahendry/test
- Install vscode-spectral extension
- 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.
Environment:
- Extension version: 1.1.2
- VS Code version: 1.86
- Operating System: Windows 11
Additional context
.js
should be optional in require
: