Skip to content

Commit 3bca438

Browse files
committed
Merge pull request #84 from codeclimate/will/fix-eslintignore-behavior
Keep paths relative to /code
2 parents b6a4060 + b6f95c2 commit 3bca438

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

bin/eslint.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/src/app/bin/node_gc
22

3-
process.chdir('/code');
3+
var CODE_DIR = "/code";
4+
process.chdir(CODE_DIR);
45

56
// Redirect `console.log` so that we are the only ones
67
// writing to STDOUT
@@ -79,10 +80,9 @@ function isFileWithMatchingExtension(file, extensions) {
7980
}
8081

8182
function isFileIgnoredByLibrary(file) {
82-
var path = file.replace(/^\/code\//, "");
83-
var ignored = cli.isPathIgnored(path);
83+
var ignored = cli.isPathIgnored(file);
8484
if (ignored) {
85-
var output = "File `" + path + "` ignored because of your .eslintignore file." + "\n";
85+
var output = "File `" + file + "` ignored because of your .eslintignore file." + "\n";
8686
process.stderr.write(output);
8787
}
8888
return ignored;
@@ -115,18 +115,16 @@ function inclusionBasedFileListBuilder(includePaths) {
115115
if ((/\/$/).test(fileOrDirectory)) {
116116
// if it ends in a slash, expand and push
117117
var filesInThisDirectory = glob.sync(
118-
"/code/" + fileOrDirectory + "/**/**"
118+
fileOrDirectory + "/**/**"
119119
);
120120
prunePathsWithinSymlinks(filesInThisDirectory).forEach(function(file, j){
121121
if (!isFileIgnoredByLibrary(file) && isFileWithMatchingExtension(file, extensions)) {
122122
analysisFiles.push(file);
123123
}
124124
});
125125
} else {
126-
// if not, check for ending in *.js
127-
var fullPath = "/code/" + fileOrDirectory;
128-
if (!isFileIgnoredByLibrary(fullPath) && isFileWithMatchingExtension(fullPath, extensions)) {
129-
analysisFiles.push(fullPath);
126+
if (!isFileIgnoredByLibrary(fileOrDirectory) && isFileWithMatchingExtension(fileOrDirectory, extensions)) {
127+
analysisFiles.push(fileOrDirectory);
130128
}
131129
}
132130
});
@@ -151,7 +149,7 @@ runWithTiming("engineConfig", function () {
151149

152150
var userConfig = engineConfig.config || {};
153151
if (userConfig.config) {
154-
options.configFile = "/code/" + userConfig.config;
152+
options.configFile = CODE_DIR + "/" + userConfig.config;
155153
}
156154

157155
if (userConfig.extensions) {

0 commit comments

Comments
 (0)