Skip to content

Commit

Permalink
Fix: no-missing-require had false positive (fixes #70)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Mar 14, 2017
1 parent 242eeeb commit 113c68f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/util/exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const path = require("path")
// Helpers
//------------------------------------------------------------------------------

const ROOT = /^(?:[/.]|\.\.|[A-Z]:\\|\\\\)$/
const ROOT = /^(?:[/.]|\.\.|[A-Z]:\\|\\\\)(?:[/\\]\.\.)*$/

/**
* Check whether the file exists or not.
Expand Down
25 changes: 25 additions & 0 deletions tests/lib/rules/no-missing-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,28 @@ ruleTester.run("no-missing-require", rule, {
},
],
})

/*eslint-env mocha */
describe("On specific working directory:", () => {
const filename = fixture("test.js")
let originalDir = null

before(() => {
originalDir = process.cwd()
process.chdir(path.dirname(filename))
})
after(() => {
process.chdir(originalDir)
})

ruleTester.run("no-missing-require", rule, {
valid: [
{
filename: fixture("test.js"),
code: "require('../../lib/rules/no-missing-require');",
env: {node: true},
},
],
invalid: [],
})
})

0 comments on commit 113c68f

Please sign in to comment.