function findActualFile()

in eslint-rules/enforce-extensions.js [79:122]


		function findActualFile(basePath) {
			if (!basePath) return null;

			try {
				// Get the directory and base name
				const dir = path.dirname(basePath);
				const base = path.basename(basePath);

				// If the directory doesn't exist, return early
				if (!fs.existsSync(dir)) {
					return null;
				}

				// Read all files in the directory
				const files = fs.readdirSync(dir);

				// Look for files that match our base name plus any extension
				for (const file of files) {
					const fileParts = path.parse(file);

					// If we find a file that matches our base name
					if (fileParts.name === base) {
						// Handle TypeScript to JavaScript conversion
						if (tsToJs && fileParts.ext === ".ts") {
							return {
								actualPath: path.join(dir, file),
								importExt: ".js", // Import as .js even though it's a .ts file
							};
						}

						// Otherwise use the actual extension
						return {
							actualPath: path.join(dir, file),
							importExt: fileParts.ext,
						};
					}
				}
			} catch (error) {
				// If there's an error checking file existence, return null
				console.error("Error checking files:", error);
			}

			return null;
		}