Skip to content

Commit

Permalink
lib: fix module linter issues by setting root
Browse files Browse the repository at this point in the history
Eslint searches parent directories looking for config files until it
finds one with "root: true" in it. This sets "root: true" in CitGM's
tmpDir to avoid that.

Fixes: nodejs#399
  • Loading branch information
gibfahn committed Apr 25, 2017
1 parent 83438bf commit 5b10a52
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/temp-directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const mkdirp = require('mkdirp');
const osenv = require('osenv');
const rimraf = require('rimraf');
const uuid = require('uuid');
const fs = require('fs');

function create(context, next) {
if (context.options && context.options.tmpDir) {
Expand All @@ -21,7 +22,17 @@ function create(context, next) {
if (err) {
return next(err);
}
return next(null, context);
/* Tells eslint running in module tests not to look for config files above
this temp directory. */
const eslintrcPath = path.join(context.path, '.eslintrc.yml');
context.emit('data', 'verbose', context.module.name + ' mk.eslintrc',
eslintrcPath);
fs.writeFile(eslintrcPath, 'root: true', function (err) {
if (err) {
return next(err);
}
return next(null, context);
});
});
}

Expand Down

0 comments on commit 5b10a52

Please sign in to comment.