We are having a debate around whether the AirBnB guidelines for object-curly-newline (10.8) should affect destructuring or not, particularly for props.
Example:
// GoodexportdefaultfunctionmyComponent({ prop1, prop2, prop3 }){ ... }exportdefaultfunctionmyComponent({
prop1, prop2, prop3,}){ ... }exportdefaultfunctionmyComponent({
prop1,
prop2,
prop3,}){ ... }// Is this bad?exportdefaultfunctionmyComponent({
prop1, prop2,
prop3,}){ ... }// Goodconst{ env1, env2, env3 }=process.env;// Is this bad?const{
env1, env2,
env3,}=process.env;
We know eslint does not support this at all (and have chosen not to), so if we want to do it we have to use prettier or eslint-plugin-putout. We are curious if AirBnB standards have been defined for this circumstance? There has been many discussions around whether rules 7.15 and 10.8 were intended to affect this.
Many thanks for your time. I apologize if this was answered elsewhere, couldn't seem to find it.
The text was updated successfully, but these errors were encountered:
Yes, those examples you’re asking about are bad (the 2nd, 4th, and 6th).
Any multi-part construct that can’t fit entirely on a single line, must have each part on its own line. For destructuring, that means either the entire statement is on one line, or each property being destructured must be on its own line.
To be clear, the guide dictates this, and it’s irrelevant that the linter config does not, as not everything in the guide is, or needs to be, lintable.
@ljharb Thank you very much for the clarification. Would you be willing to point to where in the guide this is dictated? This isn't the first time this has come up for our team, as I believe half of us are misinterpreting the guide around this concept. I would like to update our documentation appropriately to make sure we are all on the same page moving forward.
kjenkins19 commentedJun 2, 2021
•
edited
We are having a debate around whether the AirBnB guidelines for object-curly-newline (10.8) should affect destructuring or not, particularly for props.
Example:
We know eslint does not support this at all (and have chosen not to), so if we want to do it we have to use prettier or eslint-plugin-putout. We are curious if AirBnB standards have been defined for this circumstance? There has been many discussions around whether rules 7.15 and 10.8 were intended to affect this.
Many thanks for your time. I apologize if this was answered elsewhere, couldn't seem to find it.
The text was updated successfully, but these errors were encountered: