eslint: no-extra-semi exception or new option

http://eslint.org/docs/rules/no-extra-semi

  • ESLint 2.9.0
  • being able to safely concatenate several JS files into one and use no-extra-semi at the same time

If the first character of the file—excluding the eventual preceding whitespace—is ; it should be ignored. cf http://stackoverflow.com/q/1873983/248058

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 22 (16 by maintainers)

Most upvoted comments

Let’s be careful not to mis-characterize each other’s comments.

@Mouvedia I think by “appeal to authority”, @michaelficarra was referring to the Stack Overflow link, but I don’t think you were actually trying to cite it as an authority (rather, you were more likely just using it as a reference). As much as possible, we should try to assume positive intent and assume that @michaelficarra was just trying to say we needed to test it ourselves.

And I think it’s good for all of us to understand that @michaelficarra and @Mouvedia are coming from different (but equally valid) places here. @Mouvedia is talking about the common experience of concatenation and left out a few subconscious assumptions. @michaelficarra is talking about corner cases that are still nonetheless worth considering. The challenge is to find some common ground. 😄

My personal take (bearing in mind I’m not on the core team) is that even if semicolon prefixing might not be sufficient, it is still commonly done and might deserve some consideration. I also don’t think that no-extra-semi was designed to flag for this particular anti-pattern, and so it doesn’t seem right that it should take on this extra responsibility. I could see a new rule for ensuring that the beginning of file allows for safe concatenation. At this point, though, I still think there is merit in a rule option to avoid a semicolon from being flagged at the beginning of the file by the no-extra-semi rule specifically.