-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Wrong semicolon on semi = false mode #1388
Comments
This is on purpose. Here’s a comment that sparked the idea: #736 (comment) |
is it necessary to have semicolon right after opening brace? |
The semicolon in your example is technically not needed – right now. But when you add a new line it is: it('should blah blah', () => {
+ console.log('is this test even running??')
['vinh'].forEach(t => {
expect(convertRawToIds(t)).toEqual(['vinh'])
})
}) When you now run the tests you will be greeted by it('should blah blah', () => {
console.log('is this test even running??')['vinh'].forEach(t => {
expect(convertRawToIds(t)).toEqual(['vinh'])
})
}) Luckily, Prettier prints that “unnecessary” semicolon so you don’t have to think about them and won’t fall into frustrating traps. :) |
Could you explain more about how the compiler works in this case? @lydell |
Sorry, I don’t understand what you mean. |
@lydell the problem was that I misunderstood how semicolon is inserted automatically: |
From
To
https://prettier.github.io/prettier/#%7B%22content%22%3A%22%20%20it('should%20blah%20blah'%2C%20()%20%3D%3E%20%7B%5Cn%20%20%20%20%5B%5Cn%20%20%20%20%20%20'vinh'%2C%5Cn%20%20%20%20%5D.forEach(t%20%3D%3E%20%7B%5Cn%20%20%20%20%20%20expect(convertRawToIds(t)).toEqual(%5B%5Cn%20%20%20%20%20%20%20%20'vinh'%5Cn%20%20%20%20%20%20%5D)%5Cn%20%20%20%20%7D)%5Cn%20%20%7D)%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Atrue%2C%22trailingComma%22%3A%22none%22%2C%22bracketSpacing%22%3Atrue%2C%22jsxBracketSameLine%22%3Afalse%2C%22parser%22%3A%22babylon%22%2C%22semi%22%3Afalse%2C%22useTabs%22%3Afalse%2C%22doc%22%3Afalse%7D%7D
The text was updated successfully, but these errors were encountered: