Consider this piece of JavaScript code:
MyCompany.MyProduct = {};
(function () {
"use strict";
MyCompany.MyProduct.doSomethingAmazing = function () {
};
}());
This approach is acceptable and passes Mr Crockford's JavaScript lint. However, Resharper (6.1 in Visual Studio 2010) flagged an issue on the last line:
Unexpected Expression
The bracket placement at the end is controversial, with some preferring `})();` over `}());`. Despite attempts to find a compromise that pleases both Resharper and JS Lint, no satisfactory solution has been found.
An alternative attempt was made:
MyCompany.MyProduct = {};
!function () {
"use strict";
MyCompany.MyProduct.doSomethingAmazing = function () {
};
}();
Although this structure satisfied Resharper, it invoked warnings from JS Lint:
Wrap an immediate function invocation in parentheses to assist the reader in understanding...
Given the nuances of JavaScript syntax, I am exploring if there exists a format that satisfies both Resharper's and JS Lint's criteria. Is there a syntax that can make both tools happy?