unicode-bom - ESLint - Pluggable JavaScript Linter

文章推薦指數: 80 %
投票人數:10人

The Unicode Byte Order Mark (BOM) is used to specify whether code units are big endian or little endian. That is, whether the most significant or least ... Skiptomaincontent Versions VersionSwitcher SelectingaversionwilltakeyoutothechosenversionoftheESLintdocs. Version HEAD v8.25.0 Index Search Resultswillbeshownandupdatedasyoutype. Clearsearch UserGuide GettingStarted Configuring ConfigurationFiles(New) ConfigurationFiles ConfiguringLanguageOptions ConfiguringRules ConfiguringPlugins IgnoringCode CommandLineInterface Rules Formatters Integrations Migratingtov8.x DeveloperGuide Architecture GettingtheSourceCode SetUpaDevelopmentEnvironment RuntheTests WorkingwithRules WorkingwithPlugins WorkingwithCustomFormatters WorkingwithCustomParsers ShareableConfigs Node.jsAPI Contributing MaintainerGuide ManagingIssues ReviewingPullRequests ManagingReleases Governance unicode-bom RequireordisallowUnicodebyteordermark(BOM) 🛠Fixable Someproblemsreportedbythisruleareautomaticallyfixablebythe--fixcommandlineoption TableofContents RuleDetails Options always never WhenNotToUseIt Version Resources TheUnicodeByteOrderMark(BOM)isusedtospecifywhethercodeunitsarebig endianorlittleendian.Thatis,whetherthemostsignificantorleast significantbytescomefirst.UTF-8doesnotrequireaBOMbecausebyteordering doesnotmatterwhencharactersareasinglebyte.SinceUTF-8isthedominant encodingoftheweb,wemake"never"thedefaultoption. RuleDetails Ifthe"always"optionisused,thisrulerequiresthatfilesalwaysbegin withtheUnicodeBOMcharacterU+FEFF.If"never"isused,filesmustnever beginwithU+FEFF. Options Thisrulehasastringoption: "always"filesmustbeginwiththeUnicodeBOM "never"(default)filesmustnotbeginwiththeUnicodeBOM always Exampleofcorrectcodeforthisrulewiththe"always"option: /*eslintunicode-bom:["error","always"]*/U+FEFFvarabc; Exampleofincorrectcodeforthisrulewiththe"always"option: /*eslintunicode-bom:["error","always"]*/varabc; never Exampleofcorrectcodeforthisrulewiththedefault"never"option: /*eslintunicode-bom:["error","never"]*/varabc; Exampleofincorrectcodeforthisrulewiththe"never"option: /*eslintunicode-bom:["error","never"]*/U+FEFFvarabc; WhenNotToUseIt IfyouusesomeUTF-16orUTF-32filesandyouwanttoallowafileto optionallybeginwithaUnicodeBOM,youshouldturnthisruleoff. Version ThisrulewasintroducedinESLintv2.11.0. Resources Rulesource Testssource Editthispage TableofContents RuleDetails Options always never WhenNotToUseIt Version Resources



請為這篇文章評分?