]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/unicode-bom.js
2 * @fileoverview Require or disallow Unicode BOM
3 * @author Andrew Johnston <https://github.com/ehjay>
7 //------------------------------------------------------------------------------
9 //------------------------------------------------------------------------------
11 /** @type {import('../shared/types').Rule} */
17 description
: "Require or disallow Unicode byte order mark (BOM)",
19 url
: "https://eslint.org/docs/latest/rules/unicode-bom"
22 fixable
: "whitespace",
26 enum: ["always", "never"]
30 expected
: "Expected Unicode BOM (Byte Order Mark).",
31 unexpected
: "Unexpected Unicode BOM (Byte Order Mark)."
37 //--------------------------------------------------------------------------
39 //--------------------------------------------------------------------------
43 Program
: function checkUnicodeBOM(node
) {
45 const sourceCode
= context
.sourceCode
,
46 location
= { column
: 0, line
: 1 },
47 requireBOM
= context
.options
[0] || "never";
49 if (!sourceCode
.hasBOM
&& (requireBOM
=== "always")) {
53 messageId
: "expected",
55 return fixer
.insertTextBeforeRange([0, 1], "\uFEFF");
58 } else if (sourceCode
.hasBOM
&& (requireBOM
=== "never")) {
62 messageId
: "unexpected",
64 return fixer
.removeRange([-1, 0]);