Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: fix module linter issues by setting root #400

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/temp-directory.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
const fs = require('fs');
let path = require('path'); // Mocked in tests

const mkdirp = require('mkdirp');
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');

This comment was marked as off-topic.

context.emit('data', 'verbose', context.module.name + ' mk.eslintrc',

This comment was marked as off-topic.

eslintrcPath);
fs.writeFile(eslintrcPath, 'root: true', function (err) {
if (err) {
return next(err);
}
return next(null, context);
});
});
}

Expand Down
8 changes: 7 additions & 1 deletion test/test-temp-directory.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const fs = require('fs');
const path = require('path');

const test = require('tap').test;
const rewire = require('rewire');
Expand Down Expand Up @@ -43,7 +44,12 @@ test('tempDirectory.create:', function (t) {
fs.stat(ctx.path, function (err, stats) {
t.error(err);
t.ok(stats.isDirectory(), 'the path should exist and be a folder');
t.end();
const eslintrcPath = path.join(ctx.path, '.eslintrc.yml');
fs.readFile(eslintrcPath, 'utf-8', function (err, data) {
t.error(err);
t.equal(data, 'root: true', 'tmpDir should have a .eslintrc.yml file');

This comment was marked as off-topic.

This comment was marked as off-topic.

t.end();
});
});
});
});
Expand Down