New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
indent
: outerIIFEBody
option not using a multiplier, warning on non-IIFEs?
#6585
Comments
Confirmed |
@eslint/eslint-team do you agree on number 2, that the option should be configured as a multiplier of the indentation (in the same way as the other options), and not directly as the indent size? |
@alberto It's consistent with the current options (so possibly the intended design), but I still think we should abolish multipliers in that rule long-term. |
false negatives also happen - some top-level IIFEs are not recognized: (function () {
var i; // ok
})();
~function () {
var i; // not
}();
!(function () {
var i; // not
})();
!function () {
var i; // not
}();
;(function () {
var i; // ok
})();
var MyClass = (function () {
var i; // not
})(); |
@platinumazure why would we want to get rid of multipliers? Don't forget that "tab" is a valid option as well, and someone may want 3-space indentation. Multipliers are the only thing that makes sense to me for this option, since everything should be measured in "indentation levels", and "what is an indentation level" is what's configured by the first option (ie, n spaces, or a hard tab). |
Because export statements, which technically can contain variable I'm okay with allowing some things to be expressed in terms of indentation @platinumazure https://github.com/platinumazure why would we want to get Multipliers are the only thing that makes sense to me for this option, — Reply to this email directly, view it on GitHub |
If we have an "align" option I hope we have a "never align" option - in my code, I absolutely forbid any indentation solely for alignment. |
@platinumazure let's keep the scope of this issue narrow - there's no need to talk about future long-term possibilities in this context as it's confusing for everyone involved. This option should definitely act like the others and be a multiplier. I'll take a look and see if it's something that can be fixed easily. |
@nzakas confirmed, no errors this time! |
I took the examples of IIFE from https://en.wikipedia.org/wiki/Immediately-invoked_function_expression, no idea if anyone is using the ones with unary operator. I just tried the proposed fix -- it doesn't work on example from google style guide:
|
@wojdyr in that case, that's not an IIFE - that's just a function passed to another function. |
@ljharb yes, true. And since eslint-config-google doesn't look concerned with indentation of goog.scope it may not be important. |
Thank you! |
Sorry, I missed @wojdyr's comment before I had made the fix. Please open a new issue if these are still a problem for you. |
What version of ESLint are you using?
v3.0.0
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/test/test-base.js
What did you expect to happen?
No warnings.
What actually happened? Please include the actual, raw output from ESLint.
$PWD/packages/eslint-config-airbnb-base/test/test-base.js 10:3 error Expected indentation of 1 space character but found 2 indent 14:3 error Expected indentation of 1 space character but found 2 indent 16:3 error Expected indentation of 1 space character but found 2 indent
There are two problems here:
outerIIFEBody
is set to 1 - this should be a multiplier of 1 on the indentation config of "2 spaces" - the errors indicate that it wants "1 space" which should never be required when the base indent is "2".The text was updated successfully, but these errors were encountered: