This will mainly depend on the type of transaction and the documents that were executed. You might have a cause of action under Residential Real Property Disclosure Act. (link http://www.ilga.gov/legislation/ilcs/ilcs5.asp?ActID=2152&ChapterID=62 ) but there is no way of knowing without review all the documents that were executed.
I strongly suggest you take all the documents you have and take them to an attorney in the area where the property is located to see if you even have a cause of action. Good Luck
If you are seeking relief under the Residential Real Property Disclosure Act, the statute of limitations is one year. As a practical matter, you will want to repair and correct any unsafe wiring as soon as possible. Take pictures of the wiring before the repair, and if the electrician indicates it is not up to code, try and find out if the wiring was code compliant at the time the home was built. After you have this information, seek a local attorney who practices in this area and review the potential case with the attorney. Keep track of any repair expenses, including copies of all receipts, invoices, etc, as this will assist you in determining if you have a claim, and if so, will assist you in pursuing the claim.
In Illinois the breach of a written contract has a 10-year statute of limitations, but if this is new construction and you are the first buyer, it is a 4-year statute from when you knew or should have known of the construction defect. But that is the easy part. The hard part is to review the contract and the closing documents, because many "collateral" issues -- i.e. non-title issues -- do not merge and "disappear" once the deed is given, but many do. Depending on how much it will cost to remedy the situation, allowing an attorney the chance to review your chances with you would be the thing to do.