Skip to content
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

UTF-8 BOM causes error #283

Closed
beakdoctor opened this issue Oct 8, 2015 · 7 comments

Comments

@beakdoctor
Copy link

commented Oct 8, 2015

I just noticed if you have a file with a UTF-8 BOM standard will throw an error like:
test2.js:1:1: Irregular whitespace not allowed
Is this intentional? Either way it's a confusing error because you can't actually see it visually. Also, Visual Studio apparently loves to add these to your files which will cause a lot of headaches along with this rule.

@dcousens dcousens added the bug label Oct 9, 2015

@dcousens

This comment has been minimized.

Copy link
Member

commented Oct 9, 2015

Can you post a file we can use for reproduction?
If you have trouble copy pasting it into GitHub, just paste the file base64 encoded.

@beakdoctor

This comment has been minimized.

Copy link
Author

commented Oct 9, 2015

I can't attach any files for some reason, but here is the base64:
77u/dmFyIHggPSA0Mg0KbW9kdWxlLmV4cG9ydHMgPSB4DQo=

I have no idea if the bom is preserved, but there is another way. In npm there is a tool called add-bom:

> standard nobom.js


> add-bom -f nobom.js
BOM was appended to nobom.js

> standard nobom.js
standard: Use JavaScript Standard Style (https://github.com/feross/standard)
  C:\kod\oltest\VS-OL\VS-OL\src\nobom.js:1:1: Irregular whitespace not allowed

There is also another tool called strip-bom-cli that is invoked like this:

> strip-bom nobom.js > nobom2.js

> standard nobom2.js

>
@dcousens

This comment has been minimized.

Copy link
Member

commented Oct 11, 2015

Bug confirmed.

@feross I'm guessing this is an eslint issue?

@Flet

This comment has been minimized.

Copy link
Member

commented Oct 12, 2015

I believe this is a feature of the rule:
http://eslint.org/docs/rules/no-irregular-whitespace.html

With this rule enabled the following characters will cause warnings outside of strings:
\ufeff - Zero Width No-Break Space - <BOM>

@feross

This comment has been minimized.

Copy link
Member

commented Oct 12, 2015

There's no need for a BOM character in a plaintext UTF-8 file. It's neither required, nor recommended by the Unicode spec.

It appears there's an option to disable this behavior in Visual Studio: https://stackoverflow.com/questions/5406172/utf-8-without-bom

@feross feross closed this Oct 12, 2015

@dcousens

This comment has been minimized.

Copy link
Member

commented Oct 12, 2015

@Flet that'll teach me for not investigating what a BOM character is.
Not a bug.

@dcousens dcousens removed the bug label Oct 12, 2015

@feross

This comment has been minimized.

Copy link
Member

commented Oct 12, 2015

@dcousens Yeah, I hadn't heard of them before this either.

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
4 participants
You can’t perform that action at this time.