Skip to content

Commit

Permalink
Merge pull request #497 from michaelficarra/GH-494
Browse files Browse the repository at this point in the history
fixes #494 and #496: allow shebangs and allow explicit CLI args to override .eslintignore
  • Loading branch information
nzakas committed Jan 10, 2014
2 parents 09346ea + 109a57b commit 00e773e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
12 changes: 1 addition & 11 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,9 @@ function processFile(filename, configHelper) {
text,
messages;

try {
configHelper.cacheExclusions(path.dirname(filePath));
} catch(e) {
/* istanbul ignore next Error handling doesn't need testing */
console.log(e.message);
}

if (configHelper.checkForExclusion(filePath)) {
return;
}
if (existsSync(filePath)) {
config = configHelper.getConfig(filePath);
text = fs.readFileSync(path.resolve(filename), "utf8");
text = fs.readFileSync(path.resolve(filename), "utf8").replace(/^#![^\r\n]+[\r\n]/, "");
messages = eslint.verify(text, config);
} else {
messages = [{
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/shebang.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

var cli = require("../lib/cli");
var exitCode = cli.execute(Array.prototype.slice.call(process.argv, 2));
process.exit(exitCode);
28 changes: 19 additions & 9 deletions tests/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ describe("cli", function() {
});
});

describe("when given a file with eslint excluded files in the same directory", function() {
var code = "tests/fixtures/missing-semicolon.js";
describe("when given a directory with eslint excluded files in the directory", function() {
var code = "tests/fixtures";

it("should not process file", function() {
it("should not process any files", function() {
var exit = cli.execute([code]);

assert.isTrue(console.log.calledOnce);
Expand All @@ -220,14 +220,24 @@ describe("cli", function() {
});
});

describe("when given two files in the same dir with exclusions", function() {
var code = ["tests/fixtures/missing-semicolon.js", "tests/fixtures/single-quoted.js"];
describe("when given a file in excluded files list", function() {
var code = "tests/fixtures/missing-semicolon.js";

it("should not process any files", function() {
var exit = cli.execute(code);
it("should process the file anyway", function() {
var exit = cli.execute([code]);

assert.isTrue(console.log.called);
assert.isFalse(console.log.alwaysCalledWith(""));
assert.equal(exit, 0);
});
});

describe("when executing a file with a shebang", function() {
var code = "tests/fixtures/shebang.js";

it("should execute without error", function() {
var exit = cli.execute([code]);

assert.isTrue(console.log.calledOnce);
assert.isTrue(console.log.calledWithExactly(""));
assert.equal(exit, 0);
});
});
Expand Down

0 comments on commit 00e773e

Please sign in to comment.