-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Explain UTF-8 BOM rule in readme #1640
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
Comments
The rule page says "UTF-8 does not require a BOM because byte ordering does not matter when characters are a single byte. Since UTF-8 is the dominant encoding of the web, we make "never" the default option." - the reasoning for choosing "never" is because files should always only be in UTF-8. Are you running into issues with this rule? |
Yes, that's what I found there as well. It's ok as a default for eslint. I thought the patch repeats this because there had been a stronger reason for "never". To reproduce, run Python 2.7.6 and Firefox 57 on Ubuntu trusty with system locale |
In general, this config repeats all the defaults explicitly. I'd say that your solution should be to use a build process to auto-insert the BOM for you, rather than encoding that directly in the file. Separately, lots of web features are broken on |
I could imagine an argument for separation of concerns: The transport and compatibility issues should be solved by some other mechanism because the code files should only be concerned with behavior. |
Modern web dev requires a build process anyways (for minification, babel, etc) - it has for years, and it will for the foreseeable future. |
I think those are reasons worthy to be mentioned in the style guide. How about this? Update: Changed the "ing"s to "er"s to match the search keywords. |
I guess that's fine; this isn't something that almost anybody runs into because almost everyone uses tools that assume UTF-8. Want to send a PR? |
ok, PR coming up later. |
For whatever it's worth, this rule does make it harder to work with Visual Studio default file saving behavior. See: |
Your SO link contains a link to a vscode extension that fixes the vscode bug. |
In my case, it has been easier to disable the rule so that other developers working on the projects using the config don't have to install an extension or otherwise configure things specifically to satisfy the rule (granted, there may be reasons to keep the rule enabled, but I haven't run into them). I mostly mentioned the Visual Studio case in response to your question to the OP ("Are you running into issues with this rule?") and in case it's considered worth consideration, given the popularity of Visual Studio. I agree with @mk-pmb's suggestion that the documentation should explain why exactly BOM is disallowed. Given that the only options for the rule are "always" or "never", it's clear why the default is "never", given your explanation and the explanation in the rule page. However, I don't think it's clear why the Airbnb config enables the rule as an error. The rule page says that "UTF-8 does not require a BOM" but it's not clear why that should translate to the BOM being disallowed. |
See my PR #1643 for potential reasons. |
Uh oh!
There was an error while loading. Please reload this page.
Most style decisions are explained in the readme, but I couldn't find the reasoning on why a BOM is considered bad. Where I've looked:
javascript/packages/eslint-config-airbnb-base/rules/style.js
Lines 472 to 474 in 8cf2c70
Could someone explain it, or add search keywords to make the explanation easier to find?
Update: Also, is there a recommendation on how to declare the file encoding instead? I searched the readme for "charset", "encod" and "character set" but no matches.
The text was updated successfully, but these errors were encountered: