Skip to content

Commit

Permalink
Finish tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Feb 9, 2021
1 parent ee3157e commit 183f9e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/config-array/ignore-pattern.js
Expand Up @@ -167,7 +167,7 @@ class IgnorePattern {
const relPath = relPathRaw && (relPathRaw + dirSuffix(filePath));
const adoptedIg = dot ? dotIg : ig;
const result = relPath !== "" && adoptedIg.ignores(relPath);

debug("Check", { filePath, dot, relativePath: relPath, result });
return result;
},
Expand Down
3 changes: 1 addition & 2 deletions lib/flat-compat.js
Expand Up @@ -153,7 +153,7 @@ function translateESLintRC(eslintrcConfig, {
flatConfig.plugins[pluginName] = plugin;

// create a config for any processors
if (plugin.processors) { console.dir(pluginProcessors);
if (plugin.processors) {
for (const processorName of Object.keys(plugin.processors)) {
if (processorName.startsWith(".")) {
debug(`Assigning processor: ${pluginName}/${processorName}`);
Expand Down Expand Up @@ -262,7 +262,6 @@ class FlatCompat {
// This filters config array elements by `files`/`excludedFiles` then merges the elements.
const finalConfig = eslintrcArray.extractConfig(filePath);


// Test the `ignorePattern` properties of the final config.
return Boolean(finalConfig.ignores) && finalConfig.ignores(filePath);
}]
Expand Down
16 changes: 8 additions & 8 deletions tests/lib/flat-compat.js
Expand Up @@ -74,8 +74,8 @@ describe("FlatCompat", () => {

assert.strictEqual(result.length, 1);
assert.typeOf(result[0].ignores[0], "function");
assert.isTrue(result[0].ignores[0]("/usr/eslint/foo.jsx"));
assert.isFalse(result[0].ignores[0]("/usr/eslint/foo.js"));
assert.isTrue(result[0].ignores[0](path.join(baseDirectory, "foo.jsx")));
assert.isFalse(result[0].ignores[0](path.join(baseDirectory, "foo.js")));
});

it("should translate ignorePatterns array into ignores array", () => {
Expand All @@ -85,8 +85,8 @@ describe("FlatCompat", () => {

assert.strictEqual(result.length, 1);
assert.typeOf(result[0].ignores[0], "function");
assert.isTrue(result[0].ignores[0]("/usr/eslint/foo.jsx"));
assert.isFalse(result[0].ignores[0]("/usr/eslint/foo.js"));
assert.isTrue(result[0].ignores[0](path.join(baseDirectory, "foo.jsx")));
assert.isFalse(result[0].ignores[0](path.join(baseDirectory, "foo.js")));
});

it("should ignore second argument of ignore function from ignorePatterns", () => {
Expand All @@ -96,8 +96,8 @@ describe("FlatCompat", () => {

assert.strictEqual(result.length, 1);
assert.typeOf(result[0].ignores[0], "function");
assert.isTrue(result[0].ignores[0]("/usr/eslint/foo.jsx", {}));
assert.isFalse(result[0].ignores[0]("/usr/eslint/foo.js", ""));
assert.isTrue(result[0].ignores[0](path.join(baseDirectory, "foo.jsx"), {}));
assert.isFalse(result[0].ignores[0](path.join(baseDirectory, "foo.js"), ""));
});

it("should combine ignorePatterns from extended configs", () => {
Expand All @@ -108,8 +108,8 @@ describe("FlatCompat", () => {

assert.strictEqual(result.length, 1);
assert.typeOf(result[0].ignores[0], "function");
assert.isTrue(result[0].ignores[0]("/usr/eslint/foo/baz.js"));
assert.isFalse(result[0].ignores[0]("/usr/eslint/foo/bar/baz.js"));
assert.isTrue(result[0].ignores[0](path.join(baseDirectory, "foo/baz.js")));
assert.isFalse(result[0].ignores[0](path.join(baseDirectory, "foo/bar/baz.js")));
});


Expand Down

0 comments on commit 183f9e9

Please sign in to comment.