Open formulahendry opened 9 months ago
Describe the bug When importing CommonJS modules, lint does not work if you do not add .js in require
.js
require
To Reproduce
test-spectral\openapi.yaml
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
message: aaa222
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!
spectral lint .\test-spectral\openapi.yaml --ruleset .\test-spectral\test_rules\my-ruleset.yaml
In test-spectral\test_rules\functions\abc.js, if you add a .js in require: var { getMessages } = require("../function_utils/test.js"); Lint works!
test-spectral\test_rules\functions\abc.js
var { getMessages } = require("../function_utils/test.js");
the .js file extension should be optional when importing CommonJS modules.
Screenshots
Environment:
Additional context .js should be optional in require:
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.
Describe the bug When importing CommonJS modules, lint does not work if you do not add
.js
inrequire
To Reproduce
test-spectral\openapi.yaml
fileActual 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#L5However,
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
inrequire
:var { getMessages } = require("../function_utils/test.js");
Lint works!the
.js
file extension should be optional when importing CommonJS modules.Screenshots
Environment:
Additional context
.js
should be optional inrequire
: