Skip to content

Commit

Permalink
Update default config and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Dec 15, 2022
1 parent ef6bcc8 commit e16e16a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/config/default-config.js
Expand Up @@ -51,7 +51,7 @@ exports.defaultConfig = [
// default ignores are listed here
{
ignores: [
"**/node_modules/**",
"**/node_modules/*",
".git/"
]
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -56,7 +56,7 @@
"bugs": "https://github.com/eslint/eslint/issues/",
"dependencies": {
"@eslint/eslintrc": "^1.3.3",
"@humanwhocodes/config-array": "0.11.7",
"@humanwhocodes/config-array": "^0.11.8",
"@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8",
"ajv": "^6.10.0",
Expand Down
56 changes: 55 additions & 1 deletion tests/lib/eslint/flat-eslint.js
Expand Up @@ -4501,13 +4501,14 @@ describe("FlatESLint", () => {
});
});


describe("ignores can unignore '/node_modules/foo'.", () => {

const { prepare, cleanup, getPath } = createCustomTeardown({
cwd: `${root}-unignores`,
files: {
"eslint.config.js": `module.exports = {
ignores: ["!**/node_modules/foo/**"]
ignores: ["!**/node_modules/foo"]
};`,
"node_modules/foo/index.js": "",
"node_modules/foo/.dot.js": "",
Expand Down Expand Up @@ -4552,6 +4553,59 @@ describe("FlatESLint", () => {
});
});

describe("ignores can unignore '/node_modules/foo/**'.", () => {

const { prepare, cleanup, getPath } = createCustomTeardown({
cwd: `${root}-unignores`,
files: {
"eslint.config.js": `module.exports = {
ignores: ["!**/node_modules/foo/**"]
};`,
"node_modules/foo/index.js": "",
"node_modules/foo/.dot.js": "",
"node_modules/bar/index.js": "",
"foo.js": ""
}
});

beforeEach(prepare);
afterEach(cleanup);

it("'isPathIgnored()' should return 'true' for 'node_modules/foo/index.js'.", async () => {
const engine = new FlatESLint({ cwd: getPath() });

assert.strictEqual(await engine.isPathIgnored("node_modules/foo/index.js"), false);
});

it("'isPathIgnored()' should return 'true' for 'node_modules/foo/.dot.js'.", async () => {
const engine = new FlatESLint({ cwd: getPath() });

assert.strictEqual(await engine.isPathIgnored("node_modules/foo/.dot.js"), false);
});

it("'isPathIgnored()' should return 'true' for 'node_modules/bar/index.js'.", async () => {
const engine = new FlatESLint({ cwd: getPath() });

assert.strictEqual(await engine.isPathIgnored("node_modules/bar/index.js"), true);
});

it("'lintFiles()' should verify 'node_modules/foo/index.js'.", async () => {
const engine = new FlatESLint({ cwd: getPath() });
const result = (await engine.lintFiles("**/*.js"));

const filePaths = result
.map(r => r.filePath)
.sort();

assert.deepStrictEqual(filePaths, [
path.join(getPath(), "eslint.config.js"),
path.join(getPath(), "foo.js"),
path.join(getPath(), "node_modules/foo/.dot.js"),
path.join(getPath(), "node_modules/foo/index.js")
]);
});
});

describe("ignore pattern can re-ignore files that are unignored by a previous pattern.", () => {
const { prepare, cleanup, getPath } = createCustomTeardown({
cwd: `${root}-reignore`,
Expand Down

0 comments on commit e16e16a

Please sign in to comment.