Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Test fixes for config-array-factory.js (#13)
* Chore: Fix ConfigArrayFactory tests * Make more tests pass * More tests passing * Fix failing tests * Normalize file paths in tests * Add longer timeout for CI * Try to fix tests again * Adjust tests * small test * Use temp-dir to get actual temp directory
- Loading branch information
Showing
5 changed files
with
588 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* @fileoverview Utilities used in tests | ||
*/ | ||
|
||
"use strict"; | ||
|
||
//----------------------------------------------------------------------------- | ||
// Requirements | ||
//----------------------------------------------------------------------------- | ||
|
||
const { createTeardown, addFile } = require("fs-teardown"); | ||
|
||
//----------------------------------------------------------------------------- | ||
// Helpers | ||
//----------------------------------------------------------------------------- | ||
|
||
/** | ||
* Prevents leading spaces in a multiline template literal from appearing in the resulting string | ||
* @param {string[]} strings The strings in the template literal | ||
* @param {any[]} values The interpolation values in the template literal. | ||
* @returns {string} The template literal, with spaces removed from all lines | ||
*/ | ||
function unIndent(strings, ...values) { | ||
const text = strings | ||
.map((s, i) => (i === 0 ? s : values[i - 1] + s)) | ||
.join(""); | ||
const lines = text.replace(/^\n/u, "").replace(/\n\s*$/u, "").split("\n"); | ||
const lineIndents = lines.filter(line => line.trim()).map(line => line.match(/ */u)[0].length); | ||
const minLineIndent = Math.min(...lineIndents); | ||
|
||
return lines.map(line => line.slice(minLineIndent)).join("\n"); | ||
} | ||
|
||
/** | ||
* Creates a new filesystem volume at the given location with the given files. | ||
* @param {Object} desc A description of the filesystem volume to create. | ||
* @param {string} desc.cwd The current working directory ESLint is using. | ||
* @param {Object} desc.files A map of filename to file contents to create. | ||
* @returns {Teardown} An object with prepare(), cleanup(), and getPath() | ||
* methods. | ||
*/ | ||
function createCustomTeardown({ cwd, files = {} }) { | ||
const { prepare, cleanup, getPath } = createTeardown( | ||
cwd, | ||
...Object.keys(files).map(filename => addFile(filename, files[filename])) | ||
); | ||
|
||
return { prepare, cleanup, getPath }; | ||
} | ||
|
||
//----------------------------------------------------------------------------- | ||
// Exports | ||
//----------------------------------------------------------------------------- | ||
|
||
module.exports = { | ||
unIndent, | ||
createCustomTeardown | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
rules: { | ||
"eqeqeq": ["error"], | ||
"curly": ["error"] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
rules: { | ||
"bar": "error" | ||
} | ||
}; |
Oops, something went wrong.