Skip to content

Commit

Permalink
fix flat-eslint tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed Jun 1, 2023
1 parent cc9019a commit 21a6225
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
5 changes: 5 additions & 0 deletions tests/fixtures/simple-valid-project/eslint.config.js
@@ -0,0 +1,5 @@
module.exports = [{
rules: {
quotes: ["error", "single"]
}
}];
1 change: 1 addition & 0 deletions tests/fixtures/simple-valid-project/foo.js
@@ -0,0 +1 @@
var a = 'b';
1 change: 1 addition & 0 deletions tests/fixtures/simple-valid-project/src/foobar.js
@@ -0,0 +1 @@
var a = 'b';
21 changes: 13 additions & 8 deletions tests/lib/eslint/flat-eslint.js
Expand Up @@ -769,9 +769,9 @@ describe("FlatESLint", () => {
it("should report zero messages when given a config file and a valid file", async () => {
eslint = new FlatESLint({
cwd: originalDir,
overrideConfigFile: "eslint.config.js"
overrideConfigFile: "tests/fixtures/simple-valid-project/eslint.config.js"
});
const results = await eslint.lintFiles(["lib/**/cli*.js"]);
const results = await eslint.lintFiles(["tests/fixtures/simple-valid-project/**/foo*.js"]);

assert.strictEqual(results.length, 2);
assert.strictEqual(results[0].messages.length, 0);
Expand All @@ -782,9 +782,13 @@ describe("FlatESLint", () => {
it("should handle multiple patterns with overlapping files", async () => {
eslint = new FlatESLint({
cwd: originalDir,
overrideConfigFile: "eslint.config.js"
overrideConfigFile: "tests/fixtures/simple-valid-project/eslint.config.js"
});
const results = await eslint.lintFiles(["lib/**/cli*.js", "lib/cli.?s", "lib/{cli,cli-engine/cli-engine}.js"]);
const results = await eslint.lintFiles([
"tests/fixtures/simple-valid-project/**/foo*.js",
"tests/fixtures/simple-valid-project/foo.?s",
"tests/fixtures/simple-valid-project/{foo,src/foobar}.js"
]);

assert.strictEqual(results.length, 2);
assert.strictEqual(results[0].messages.length, 0);
Expand Down Expand Up @@ -1408,11 +1412,10 @@ describe("FlatESLint", () => {
}, /All files matched by '\.\/tests\/fixtures\/cli-engine\/' are ignored\./u);
});

it("should throw an error when all given files are ignored via ignore-pattern", async () => {
it("should throw an error when all given files are ignored via ignorePatterns", async () => {
eslint = new FlatESLint({
overrideConfig: {
ignorePatterns: "tests/fixtures/single-quoted.js"
}
overrideConfigFile: true,
ignorePatterns: ["tests/fixtures/single-quoted.js"]
});

await assert.rejects(async () => {
Expand Down Expand Up @@ -1817,6 +1820,7 @@ describe("FlatESLint", () => {
it("should warn when deprecated rules are configured", async () => {
eslint = new FlatESLint({
cwd: originalDir,
overrideConfigFile: true,
overrideConfig: {
rules: {
"indent-legacy": 1,
Expand All @@ -1840,6 +1844,7 @@ describe("FlatESLint", () => {
it("should not warn when deprecated rules are not configured", async () => {
eslint = new FlatESLint({
cwd: originalDir,
overrideConfigFile: true,
overrideConfig: {
rules: { indent: 1, "valid-jsdoc": 0, "require-jsdoc": 0 }
}
Expand Down

0 comments on commit 21a6225

Please sign in to comment.