spacepaste

  1.  
  2. diff -Nur ../../original/eslint/lib/cli.js ./lib/cli.js
  3. --- ../../original/eslint/lib/cli.js 2017-02-03 22:46:05.000000000 +0100
  4. +++ ./lib/cli.js 2017-02-04 23:56:32.219034572 +0100
  5. @@ -54,6 +54,7 @@
  6. cacheFile: cliOptions.cacheFile,
  7. cacheLocation: cliOptions.cacheLocation,
  8. fix: cliOptions.fix,
  9. + files: cliOptions._,
  10. allowInlineConfig: cliOptions.inlineConfig
  11. };
  12. }
  13. diff -Nur ../../original/eslint/lib/ignored-paths.js ./lib/ignored-paths.js
  14. --- ../../original/eslint/lib/ignored-paths.js 2017-02-03 22:46:05.000000000 +0100
  15. +++ ./lib/ignored-paths.js 2017-02-05 11:58:50.683550254 +0100
  16. @@ -49,12 +49,35 @@
  17. * @param {string} cwd Current working directory
  18. * @returns {string} Path of ignore file or an empty string.
  19. */
  20. -function findIgnoreFile(cwd) {
  21. - cwd = cwd || DEFAULT_OPTIONS.cwd;
  22. -
  23. - const ignoreFilePath = path.resolve(cwd, ESLINT_IGNORE_FILENAME);
  24. -
  25. - return shell.test("-f", ignoreFilePath) ? ignoreFilePath : "";
  26. +function findIgnoreFile(options) {
  27. + let cwd = options.cwd || DEFAULT_OPTIONS.cwd;
  28. + let ignoreFilePath = path.resolve(cwd, ESLINT_IGNORE_FILENAME);
  29. +
  30. + debug(`Looking for ignore file in ${ignoreFilePath}`);
  31. + if(shell.test("-f", ignoreFilePath)) {
  32. + return ignoreFilePath;
  33. + }
  34. +
  35. + let files = options.files;
  36. + for( let i = 0; i < files.length; i++ ) {
  37. + let dir = path.dirname(files[i]); // take the directory from the cli files parameter
  38. + dir = path.resolve(cwd, dir); // convert it to an absolute path
  39. + let dirArray = dir.split(path.sep);
  40. + let length = dirArray.length;
  41. + for( let k = 0; k < length; k++ ) {
  42. + // adding / so that we have /ESLINT_IGNORE_FILENAME
  43. + // when there is only the '' element in the array left
  44. + let baseDir = dirArray.join(path.sep)+"/";
  45. +
  46. + ignoreFilePath = path.resolve(baseDir, ESLINT_IGNORE_FILENAME);
  47. + debug(`Looking for ignore file in ${ignoreFilePath}`);
  48. + if(shell.test("-f", ignoreFilePath)) {
  49. + return ignoreFilePath;
  50. + }
  51. + dirArray.pop(); // change to parent directory
  52. + }
  53. + }
  54. + return "";
  55. }
  56. /**
  57. @@ -141,14 +164,13 @@
  58. throw e;
  59. }
  60. } else {
  61. - debug(`Looking for ignore file in ${options.cwd}`);
  62. - ignorePath = findIgnoreFile(options.cwd);
  63. + ignorePath = findIgnoreFile(options);
  64. try {
  65. fs.statSync(ignorePath);
  66. debug(`Loaded ignore file ${ignorePath}`);
  67. } catch (e) {
  68. - debug("Could not find ignore file in cwd");
  69. + debug("Could not find ignore file");
  70. this.options = options;
  71. }
  72. }
  73.