| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
A `.js` file with no `"type"` in the nearest package.json has no format of its own, and `defaultGetFormat()` reports it as null. `--check` passed that null straight to `wrapSafe()`, which parses as CommonJS. Module syntax makes that parse bail out early, so the file was reported as valid and `--check` exited 0 even though it is not valid JavaScript under either goal. At load time the goal for such a file is decided by looking for module syntax in the source. Decide it the same way here, so the file is parsed as a module and its real syntax error is reported. Files whose format is known are unaffected, as are ambiguous files without module syntax, which are still parsed as CommonJS. Fixes: nodejs#65202 Signed-off-by: Paul Bouchon <mail@bitpshr.net>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #65203 +/- ##
==========================================
+ Coverage 90.15% 90.32% +0.16%
==========================================
Files 744 760 +16
Lines 242517 248538 +6021
Branches 45688 46893 +1205
==========================================
+ Hits 218642 224482 +5840
- Misses 15358 15460 +102
- Partials 8517 8596 +79
... and 188 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
A `.js` file with no `"type"` in the nearest package.json has no format of its own, and `defaultGetFormat()` reports it as null. `--check` passed that null straight to `wrapSafe()`, which parses as CommonJS. Module syntax makes that parse bail out early, so the file was reported as valid and `--check` exited 0 even though it is not valid JavaScript under either goal. At load time the goal for such a file is decided by looking for module syntax in the source. Decide it the same way here, so the file is parsed as a module and its real syntax error is reported. Files whose format is known are unaffected, as are ambiguous files without module syntax, which are still parsed as CommonJS. Fixes: #65202 Signed-off-by: Paul Bouchon <mail@bitpshr.net> PR-URL: #65203 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
A `.js` file with no `"type"` in the nearest package.json has no format of its own, and `defaultGetFormat()` reports it as null. `--check` passed that null straight to `wrapSafe()`, which parses as CommonJS. Module syntax makes that parse bail out early, so the file was reported as valid and `--check` exited 0 even though it is not valid JavaScript under either goal. At load time the goal for such a file is decided by looking for module syntax in the source. Decide it the same way here, so the file is parsed as a module and its real syntax error is reported. Files whose format is known are unaffected, as are ambiguous files without module syntax, which are still parsed as CommonJS. Fixes: #65202 Signed-off-by: Paul Bouchon <mail@bitpshr.net> PR-URL: #65203 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
| Back | FazBrowse Home | New Git URL |
Fixes #65202. node --check exits 0 on a .js file that contains module syntax and a genuine syntax error, when the file's format is ambiguous (no "type" in the nearest package.json).
Such a file has no format of its own, and defaultGetFormat() reports it as null. checkSyntax() passed that null straight to wrapSafe(), which parses as CommonJS; the module syntax makes that parse bail out before the rest of the file is parsed, so nothing was reported.
At load time the goal for an ambiguous file is decided by looking for module syntax in the source, so this decides it the same way before choosing how to parse.
Verified against a local build. Files whose format is known are unaffected, and ambiguous files without module syntax still parse as CommonJS, so sloppy-mode sources keep working:
The added fixture fails the existing test-cli-syntax-bad assertions before this change and passes after. All test-cli-syntax* suites pass locally.
Fixes: #65202