Cook the pasta according to package instructions until al dente. Drain and set aside, reserving 1/2 cup of pasta water.
In a large skillet, heat the olive oil over medium heat. Add the chopped onion and sauté until translucent, about 5 minutes.
Stir in the minced garlic and cook for an additional minute.
Add the diced eggplant to the skillet and cook until softened, about 8-10 minutes.
Stir in the crushed tomatoes, oregano, salt, pepper, and red pepper flakes if using. Simmer for 10 minutes, allowing the flavors to meld.
Combine the cooked pasta with the eggplant sauce in the skillet, adding reserved pasta water as needed to reach desired consistency.
Stir in the fresh basil leaves.
Serve the pasta topped with dollops of ricotta cheese and a sprinkle of grated Parmesan. Enjoy warm.