Set a small skillet over medium heat. Lay the chiles and garlic in the skillet and dry roast until soft and blotchy in spots, about 10 minutes for the chiles, about 15 minutes for the garlic.
While the chiles and garlic are roasting, scoop the chopped onion into a strainer and rinse under cold water. Shake off the excess water and pour into a medium bowl.
Pull the stems off the roasted chiles and peel the papery skin off the garlic. Scoop them into a food processor and pulse until they are finely chopped. Add the tomatoes, with their juice, re-cover and pulse a few more times, until the mixture is as coarse or smooth as you want your salsa to be.
Pour the tomato mixture into the bowl with the onion. Add the cilantro and stir thoroughly. Thin with a little water if necessary to give the salsa an easily spoonable consistency. Taste and season with lime juice or vinegar, if using, and salt, usually about ½ teaspoon. If not using within an hour or two, cover and refrigerate.
Note: If you’re not planning to use the salsa within a few hours, wait until you’re ready to serve to add the onions and cilantro.