Skip to content

Commit

Permalink
Fix: shebang false positive
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Feb 13, 2016
1 parent 7552697 commit 47e0896
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/rules/shebang.js
Expand Up @@ -59,7 +59,7 @@ function getShebangInfo(sourceCode) {
bom: (typeof sourceCode.hasBOM === "boolean" ? sourceCode.hasBOM : Boolean(m && m[1])),
cr: Boolean(m && m[3]),
length: (m && m[0].length || (sourceCode.text.charCodeAt(0) === 0xFEFF ? 1 : 0)),
shebang: (m && (m[2] + "\n") || "")
shebang: (m && m[2] && (m[2] + "\n") || "")
};
}

Expand Down Expand Up @@ -145,15 +145,12 @@ module.exports.schema = [
convertPath: {
type: "object",
properties: {},
patternProperties: {
"^.+$": {
type: "array",
items: {type: "string"},
minItems: 2,
maxItems: 2
}
},
additionalProperties: false
additionalProperties: {
type: "array",
items: {type: "string"},
minItems: 2,
maxItems: 2
}
}
},
additionalProperties: false
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/rules/shebang.js
Expand Up @@ -124,6 +124,12 @@ ruleTester.run("shebang", rule, {
{
filename: fixture("string-bin/lib/test.js"),
code: "\uFEFFhello();\r\n"
},

// blank lines on the top of files.
{
filename: fixture("string-bin/lib/test.js"),
code: "\n\n\nhello();"
}
],
invalid: [
Expand Down

0 comments on commit 47e0896

Please sign in to comment.