From 774538c3fa40b563b3c1234fd948551dbbf4840f Mon Sep 17 00:00:00 2001 From: Michoel Chaikin Date: Thu, 5 Jun 2025 01:46:00 +0000 Subject: [PATCH] Fix entry point validation to handle null scriptType Fixes https://github.com/acdvs/eslint-plugin-suitescript/issues/24 --- lib/rules/entry-points.js | 2 +- tests/rules/entry-points.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rules/entry-points.js b/lib/rules/entry-points.js index 1cd4bf9..83c19c5 100644 --- a/lib/rules/entry-points.js +++ b/lib/rules/entry-points.js @@ -15,7 +15,7 @@ module.exports = { let hasValidEntryPoint = false; let scriptType = getScriptType(context); - if (!scriptType.value || !scriptType.def) { + if (!scriptType || !scriptType.value || !scriptType.def) { return; } diff --git a/tests/rules/entry-points.js b/tests/rules/entry-points.js index b274e6b..8c82071 100644 --- a/tests/rules/entry-points.js +++ b/tests/rules/entry-points.js @@ -101,6 +101,16 @@ define([], function() { }); `, }, + { + code: ` +// no @NScriptType comment + +define([], function() { + return { foo: 'bar' }; +}); + `, + // Should not error, since scriptType is null and rule should exit early + }, ], invalid: [