Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upEnforce consistent line breaks inside braces (object-curly-newline) #782
Comments
feross
added
blocked
enhancement
labels
Feb 10, 2017
feross
added this to the
standard v10 milestone
Feb 10, 2017
feross
modified the milestones:
standard v10,
standard v11
Mar 1, 2017
feross
modified the milestones:
standard v12,
standard v13
Aug 28, 2018
feross
modified the milestones:
standard v13,
standard v14
Jul 5, 2019
This comment has been minimized.
This comment has been minimized.
|
Thanks for the feedback on this rule, everyone. In re-reading what I proposed here, I think @mafintosh's downvote is actually the right call. We have a policy of never accepting rules which involve "magic numbers". The requirement to count the number of properties and change style based on the difference between 2 vs. 3 properties is not in the spirit of That said, if we just remove the // ok
var one = { a: 1 }
// ok
var two = { a: 1, b: 2 }
// ok
var three = { a: 1, b: 2, c: 3 }
// ok
var oneM = {
a: 1
}
// ok
var twoM = {
a: 1,
b: 2
}
// ok
var threeM = {
a: 1,
b: 2,
c: 3
}
// not ok
var wat = { a: 1
}
// not ok
var wat2 = {
a: 1 }
// not ok
var wat3 = { a: 1,
b: 2,
c: 3 }This seems totally uncontroversial and very useful to enforce. All 4 ecosystem repos which fail after this rule is enabled actually have bad style. Here are some examples: const options = { native: false, // not ok
skipCovers: true,
fileSize: file.length,
observer: event => {
ipc.send('wt-audio-metadata', infoHash, index, event.metadata)
} } // not ok const bestScore = ['audio', 'video', 'image'].map(mediaType => {
return {
type: mediaType,
size: calculateDataLengthByExtension(torrent, mediaExtensions[mediaType]) } // not ok
}) model.Course
.find({ $or: [ // not ok
{ name: regexForQuery(query) },
{ searchName: regexForQuery(query) }
] }) var opts = {
pkg: { binary: { // not ok
module_name: 'module_name',
module_path: 'module_path'
} }
}I am going to enable this in |
feross
closed this
in
7e61b87
Aug 14, 2019
This comment has been minimized.
This comment has been minimized.
|
Beautiful. Right call. |
feross commentedFeb 10, 2017
•
edited
I propose that we enforce the following:
The "consistent" option in this rule is not part of ESLint yet, but when it is, we should enable it:
Rule:
For context, see: