{"action":"created","comment":{"url":"https://api.github.com/repos/eslint/eslint/pulls/comments/55382767","id":55382767,"diff_hunk":"@@ -0,0 +1,73 @@\n+/**\n+ * @fileoverview Common helpers for operations on filenames and paths\n+ * @author Ian VanSchooten\n+ * @copyright 2016 Ian VanSchooten. All rights reserved.\n+ * See LICENSE in root directory for full license.\n+ */\n+\"use strict\";\n+\n+//------------------------------------------------------------------------------\n+// Requirements\n+//------------------------------------------------------------------------------\n+\n+var path = require(\"path\"),\n+    isAbsolute = require(\"path-is-absolute\");\n+\n+//------------------------------------------------------------------------------\n+// Private\n+//------------------------------------------------------------------------------\n+\n+/**\n+ * Replace Windows with Unix style paths and remove ./ prefix and any\n+ * unnecessary \"../\"\n+ *\n+ * @param {string} filepath Path to normalize\n+ * @returns {string} Normalized filepath\n+ */\n+function normalizeFilepath(filepath) {\n+    var normalizedFilepath = path.normalize(filepath);\n+    var posixFilepath = normalizedFilepath.replace(/\\\\/g, \"/\");\n+    return posixFilepath;\n+}\n+\n+/**\n+ * Converts an absolute filepath to a relative path from a given base bath\n+ *\n+ * For example, if the filepath is `/my/awesome/project/foo.bar`,\n+ * and the base directory is `/my/awesome/project/`,\n+ * then this function should return `foo.bar`.\n+ *\n+ * It does not take into account symlinks (for now).\n+ *\n+ * @param {string} filepath  Path to convert to relative path.  If already relative,\n+ *                           it will be assumed to be relative to process.cwd(),\n+ *                           converted to absolute, and then processed.\n+ * @param {string} [baseDir] Absolute base directory to resolve the filepath from.\n+ *                           If not provided, all this function will do is remove\n+ *                           a leading slash.\n+ * @returns {string} Relative filepath\n+ */\n+function getRelativePath(filepath, baseDir) {","path":"lib/util/path-util.js","position":50,"original_position":50,"commit_id":"baaa07e1671eb8515b0a7fb6c3af3cc2c18701ed","original_commit_id":"baaa07e1671eb8515b0a7fb6c3af3cc2c18701ed","user":{"login":"IanVS","id":4616705,"avatar_url":"https://avatars.githubusercontent.com/u/4616705?v=3","gravatar_id":"","url":"https://api.github.com/users/IanVS","html_url":"https://github.com/IanVS","followers_url":"https://api.github.com/users/IanVS/followers","following_url":"https://api.github.com/users/IanVS/following{/other_user}","gists_url":"https://api.github.com/users/IanVS/gists{/gist_id}","starred_url":"https://api.github.com/users/IanVS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IanVS/subscriptions","organizations_url":"https://api.github.com/users/IanVS/orgs","repos_url":"https://api.github.com/users/IanVS/repos","events_url":"https://api.github.com/users/IanVS/events{/privacy}","received_events_url":"https://api.github.com/users/IanVS/received_events","type":"User","site_admin":false},"body":"[path.relative](https://nodejs.org/api/path.html#path_path_relative_from_to) does something similar, but it requires a baseDir (`from` argument).  This function makes it optional and just removes a leading slash if the baseDir is not given.  I'm honestly not sure why this is needed, but it was doing this before I pulled it out of `ignored-paths.js`.  ","created_at":"2016-03-08T16:17:14Z","updated_at":"2016-03-08T16:17:14Z","html_url":"https://github.com/eslint/eslint/pull/5461#discussion_r55382767","pull_request_url":"https://api.github.com/repos/eslint/eslint/pulls/5461","_links":{"self":{"href":"https://api.github.com/repos/eslint/eslint/pulls/comments/55382767"},"html":{"href":"https://github.com/eslint/eslint/pull/5461#discussion_r55382767"},"pull_request":{"href":"https://api.github.com/repos/eslint/eslint/pulls/5461"}}},"pull_request":{"url":"https://api.github.com/repos/eslint/eslint/pulls/5461","id":61573463,"html_url":"https://github.com/eslint/eslint/pull/5461","diff_url":"https://github.com/eslint/eslint/pull/5461.diff","patch_url":"https://github.com/eslint/eslint/pull/5461.patch","issue_url":"https://api.github.com/repos/eslint/eslint/issues/5461","number":5461,"state":"open","locked":false,"title":"Improve file path resolution","user":{"login":"IanVS","id":4616705,"avatar_url":"https://avatars.githubusercontent.com/u/4616705?v=3","gravatar_id":"","url":"https://api.github.com/users/IanVS","html_url":"https://github.com/IanVS","followers_url":"https://api.github.com/users/IanVS/followers","following_url":"https://api.github.com/users/IanVS/following{/other_user}","gists_url":"https://api.github.com/users/IanVS/gists{/gist_id}","starred_url":"https://api.github.com/users/IanVS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IanVS/subscriptions","organizations_url":"https://api.github.com/users/IanVS/orgs","repos_url":"https://api.github.com/users/IanVS/repos","events_url":"https://api.github.com/users/IanVS/events{/privacy}","received_events_url":"https://api.github.com/users/IanVS/received_events","type":"User","site_admin":false},"body":"### What this does\r\n\r\nThe main changes in this PR are to pass `cwd` around and resolve relative paths.  It also makes some changes to the logic in `glob-util` to account for the recent switch from `minimatch` to `node-ignore` for our ignore system.  \r\n\r\nOther minor changes include breaking out some general path operations into a utility module `path-util`, and cleaning up the tests a bit by using `getFixturePath` more consistently and removing some unnecessary `process.chdir`s (among other tweaks).\r\n\r\n### Why do this\r\n\r\nThese changes address #5314, as well as other downstream issues like https://github.com/AtomLinter/linter-eslint/issues/448, which seemed to mainly occur when tools used `executeOnText` while providing a filename.  \r\n\r\n### Notes\r\n\r\nIt would be great if @gronke and @kaelzhang could give this PR a review, since they are both very familiar with `node-ignore` and might be able to identify any edge-cases we aren't considering or testing for.\r\n\r\nI was planning to add tests for symlinks, but it sounds like this will be added in https://github.com/eslint/eslint/pull/5422 so I've not dealt with it here in the interest of keeping changes at least somewhat focused.\r\n\r\nLastly, I'm getting some failures on AppVeyor, but I'm not so familiar with working with Windows paths.  Maybe someone else on the @eslint/eslint-team can take a look and see why these are failing?","created_at":"2016-03-03T15:15:34Z","updated_at":"2016-03-08T16:17:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d3a10d273e4ef6a8da5043fcd1f5765f60041348","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/eslint/eslint/pulls/5461/commits","review_comments_url":"https://api.github.com/repos/eslint/eslint/pulls/5461/comments","review_comment_url":"https://api.github.com/repos/eslint/eslint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/5461/comments","statuses_url":"https://api.github.com/repos/eslint/eslint/statuses/baaa07e1671eb8515b0a7fb6c3af3cc2c18701ed","head":{"label":"eslint:issue5314","ref":"issue5314","sha":"baaa07e1671eb8515b0a7fb6c3af3cc2c18701ed","user":{"login":"eslint","id":6019716,"avatar_url":"https://avatars.githubusercontent.com/u/6019716?v=3","gravatar_id":"","url":"https://api.github.com/users/eslint","html_url":"https://github.com/eslint","followers_url":"https://api.github.com/users/eslint/followers","following_url":"https://api.github.com/users/eslint/following{/other_user}","gists_url":"https://api.github.com/users/eslint/gists{/gist_id}","starred_url":"https://api.github.com/users/eslint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslint/subscriptions","organizations_url":"https://api.github.com/users/eslint/orgs","repos_url":"https://api.github.com/users/eslint/repos","events_url":"https://api.github.com/users/eslint/events{/privacy}","received_events_url":"https://api.github.com/users/eslint/received_events","type":"Organization","site_admin":false},"repo":{"id":11061773,"name":"eslint","full_name":"eslint/eslint","owner":{"login":"eslint","id":6019716,"avatar_url":"https://avatars.githubusercontent.com/u/6019716?v=3","gravatar_id":"","url":"https://api.github.com/users/eslint","html_url":"https://github.com/eslint","followers_url":"https://api.github.com/users/eslint/followers","following_url":"https://api.github.com/users/eslint/following{/other_user}","gists_url":"https://api.github.com/users/eslint/gists{/gist_id}","starred_url":"https://api.github.com/users/eslint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslint/subscriptions","organizations_url":"https://api.github.com/users/eslint/orgs","repos_url":"https://api.github.com/users/eslint/repos","events_url":"https://api.github.com/users/eslint/events{/privacy}","received_events_url":"https://api.github.com/users/eslint/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eslint/eslint","description":"A fully pluggable tool for identifying and reporting on patterns in JavaScript.","fork":false,"url":"https://api.github.com/repos/eslint/eslint","forks_url":"https://api.github.com/repos/eslint/eslint/forks","keys_url":"https://api.github.com/repos/eslint/eslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eslint/eslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eslint/eslint/teams","hooks_url":"https://api.github.com/repos/eslint/eslint/hooks","issue_events_url":"https://api.github.com/repos/eslint/eslint/issues/events{/number}","events_url":"https://api.github.com/repos/eslint/eslint/events","assignees_url":"https://api.github.com/repos/eslint/eslint/assignees{/user}","branches_url":"https://api.github.com/repos/eslint/eslint/branches{/branch}","tags_url":"https://api.github.com/repos/eslint/eslint/tags","blobs_url":"https://api.github.com/repos/eslint/eslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eslint/eslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eslint/eslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/eslint/eslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eslint/eslint/statuses/{sha}","languages_url":"https://api.github.com/repos/eslint/eslint/languages","stargazers_url":"https://api.github.com/repos/eslint/eslint/stargazers","contributors_url":"https://api.github.com/repos/eslint/eslint/contributors","subscribers_url":"https://api.github.com/repos/eslint/eslint/subscribers","subscription_url":"https://api.github.com/repos/eslint/eslint/subscription","commits_url":"https://api.github.com/repos/eslint/eslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/eslint/eslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/eslint/eslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/eslint/eslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/eslint/eslint/contents/{+path}","compare_url":"https://api.github.com/repos/eslint/eslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eslint/eslint/merges","archive_url":"https://api.github.com/repos/eslint/eslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eslint/eslint/downloads","issues_url":"https://api.github.com/repos/eslint/eslint/issues{/number}","pulls_url":"https://api.github.com/repos/eslint/eslint/pulls{/number}","milestones_url":"https://api.github.com/repos/eslint/eslint/milestones{/number}","notifications_url":"https://api.github.com/repos/eslint/eslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eslint/eslint/labels{/name}","releases_url":"https://api.github.com/repos/eslint/eslint/releases{/id}","deployments_url":"https://api.github.com/repos/eslint/eslint/deployments","created_at":"2013-06-29T23:59:48Z","updated_at":"2016-03-08T15:14:06Z","pushed_at":"2016-03-08T16:04:11Z","git_url":"git://github.com/eslint/eslint.git","ssh_url":"git@github.com:eslint/eslint.git","clone_url":"https://github.com/eslint/eslint.git","svn_url":"https://github.com/eslint/eslint","homepage":"http://eslint.org","size":13413,"stargazers_count":4284,"watchers_count":4284,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":849,"mirror_url":null,"open_issues_count":195,"forks":849,"open_issues":195,"watchers":4284,"default_branch":"master"}},"base":{"label":"eslint:master","ref":"master","sha":"a8cf60bd3f8850ac8fa854b16aef199444585e27","user":{"login":"eslint","id":6019716,"avatar_url":"https://avatars.githubusercontent.com/u/6019716?v=3","gravatar_id":"","url":"https://api.github.com/users/eslint","html_url":"https://github.com/eslint","followers_url":"https://api.github.com/users/eslint/followers","following_url":"https://api.github.com/users/eslint/following{/other_user}","gists_url":"https://api.github.com/users/eslint/gists{/gist_id}","starred_url":"https://api.github.com/users/eslint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslint/subscriptions","organizations_url":"https://api.github.com/users/eslint/orgs","repos_url":"https://api.github.com/users/eslint/repos","events_url":"https://api.github.com/users/eslint/events{/privacy}","received_events_url":"https://api.github.com/users/eslint/received_events","type":"Organization","site_admin":false},"repo":{"id":11061773,"name":"eslint","full_name":"eslint/eslint","owner":{"login":"eslint","id":6019716,"avatar_url":"https://avatars.githubusercontent.com/u/6019716?v=3","gravatar_id":"","url":"https://api.github.com/users/eslint","html_url":"https://github.com/eslint","followers_url":"https://api.github.com/users/eslint/followers","following_url":"https://api.github.com/users/eslint/following{/other_user}","gists_url":"https://api.github.com/users/eslint/gists{/gist_id}","starred_url":"https://api.github.com/users/eslint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslint/subscriptions","organizations_url":"https://api.github.com/users/eslint/orgs","repos_url":"https://api.github.com/users/eslint/repos","events_url":"https://api.github.com/users/eslint/events{/privacy}","received_events_url":"https://api.github.com/users/eslint/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eslint/eslint","description":"A fully pluggable tool for identifying and reporting on patterns in JavaScript.","fork":false,"url":"https://api.github.com/repos/eslint/eslint","forks_url":"https://api.github.com/repos/eslint/eslint/forks","keys_url":"https://api.github.com/repos/eslint/eslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eslint/eslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eslint/eslint/teams","hooks_url":"https://api.github.com/repos/eslint/eslint/hooks","issue_events_url":"https://api.github.com/repos/eslint/eslint/issues/events{/number}","events_url":"https://api.github.com/repos/eslint/eslint/events","assignees_url":"https://api.github.com/repos/eslint/eslint/assignees{/user}","branches_url":"https://api.github.com/repos/eslint/eslint/branches{/branch}","tags_url":"https://api.github.com/repos/eslint/eslint/tags","blobs_url":"https://api.github.com/repos/eslint/eslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eslint/eslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eslint/eslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/eslint/eslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eslint/eslint/statuses/{sha}","languages_url":"https://api.github.com/repos/eslint/eslint/languages","stargazers_url":"https://api.github.com/repos/eslint/eslint/stargazers","contributors_url":"https://api.github.com/repos/eslint/eslint/contributors","subscribers_url":"https://api.github.com/repos/eslint/eslint/subscribers","subscription_url":"https://api.github.com/repos/eslint/eslint/subscription","commits_url":"https://api.github.com/repos/eslint/eslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/eslint/eslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/eslint/eslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/eslint/eslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/eslint/eslint/contents/{+path}","compare_url":"https://api.github.com/repos/eslint/eslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eslint/eslint/merges","archive_url":"https://api.github.com/repos/eslint/eslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eslint/eslint/downloads","issues_url":"https://api.github.com/repos/eslint/eslint/issues{/number}","pulls_url":"https://api.github.com/repos/eslint/eslint/pulls{/number}","milestones_url":"https://api.github.com/repos/eslint/eslint/milestones{/number}","notifications_url":"https://api.github.com/repos/eslint/eslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eslint/eslint/labels{/name}","releases_url":"https://api.github.com/repos/eslint/eslint/releases{/id}","deployments_url":"https://api.github.com/repos/eslint/eslint/deployments","created_at":"2013-06-29T23:59:48Z","updated_at":"2016-03-08T15:14:06Z","pushed_at":"2016-03-08T16:04:11Z","git_url":"git://github.com/eslint/eslint.git","ssh_url":"git@github.com:eslint/eslint.git","clone_url":"https://github.com/eslint/eslint.git","svn_url":"https://github.com/eslint/eslint","homepage":"http://eslint.org","size":13413,"stargazers_count":4284,"watchers_count":4284,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":849,"mirror_url":null,"open_issues_count":195,"forks":849,"open_issues":195,"watchers":4284,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eslint/eslint/pulls/5461"},"html":{"href":"https://github.com/eslint/eslint/pull/5461"},"issue":{"href":"https://api.github.com/repos/eslint/eslint/issues/5461"},"comments":{"href":"https://api.github.com/repos/eslint/eslint/issues/5461/comments"},"review_comments":{"href":"https://api.github.com/repos/eslint/eslint/pulls/5461/comments"},"review_comment":{"href":"https://api.github.com/repos/eslint/eslint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eslint/eslint/pulls/5461/commits"},"statuses":{"href":"https://api.github.com/repos/eslint/eslint/statuses/baaa07e1671eb8515b0a7fb6c3af3cc2c18701ed"}}}}