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

Ignore node_modules/ by default #460

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ markdownlint --help
-c, --config [configFile] configuration file (JSON, JSONC, JS, YAML, or TOML)
-d, --dot include files/folders with a dot (for example `.github`)
-f, --fix fix basic errors (does not work with STDIN)
-i, --ignore [file|directory|glob] file(s) to ignore/exclude (default: [])
-i, --ignore [file|directory|glob] file(s) to ignore/exclude (default: ['node_modules'])
-p, --ignore-path [file] path to file with ignore pattern(s)
-j, --json write issues in json format
-o, --output [outputFile] write issues to file (no console)
-p, --ignore-path [file] path to file with ignore pattern(s)
-q, --quiet do not write issues to STDOUT
-r, --rules [file|directory|glob|package] include custom rule files (default: [])
-s, --stdin read from STDIN (does not work with files)
Expand Down
4 changes: 2 additions & 2 deletions markdownlint.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ program
.option('-c, --config [configFile]', 'configuration file (JSON, JSONC, JS, or YAML)')
.option('-d, --dot', 'include files/folders with a dot (for example `.github`)')
.option('-f, --fix', 'fix basic errors (does not work with STDIN)')
.option('-i, --ignore [file|directory|glob]', 'file(s) to ignore/exclude', concatArray, [])
.option('-i, --ignore [file|directory|glob]', 'file(s) to ignore/exclude', concatArray, ['node_modules'])
.option('-p, --ignore-path [file]', 'path to file with ignore pattern(s)')
.option('-j, --json', 'write issues in json format')
.option('-o, --output [outputFile]', 'write issues to file (no console)')
.option('-p, --ignore-path [file]', 'path to file with ignore pattern(s)')
.option('-q, --quiet', 'do not write issues to STDOUT')
.option('-r, --rules [file|directory|glob|package]', 'include custom rule files', concatArray, [])
.option('-s, --stdin', 'read from STDIN (does not work with files)')
Expand Down
1 change: 1 addition & 0 deletions test/default-ignore/incorrect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# header
26 changes: 26 additions & 0 deletions test/default-ignore/node_modules/vendor/package/incorrect.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 20 additions & 5 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ test('glob linting works with failing files', async t => {
t.fail();
} catch (error) {
t.is(error.stdout, '');
t.is(error.stderr.match(errorPattern).length, 15);
t.is(error.stderr.match(errorPattern).length, 23);
t.is(error.exitCode, 1);
}
});
Expand Down Expand Up @@ -217,7 +217,7 @@ test('glob linting with failing files has fewer errors when ignored by dir', asy
t.fail();
} catch (error) {
t.is(error.stdout, '');
t.is(error.stderr.match(errorPattern).length, 8);
t.is(error.stderr.match(errorPattern).length, 16);
t.is(error.exitCode, 1);
}
});
Expand All @@ -228,7 +228,7 @@ test('glob linting with failing files has fewer errors when ignored by dir and a
t.fail();
} catch (error) {
t.is(error.stdout, '');
t.is(error.stderr.match(errorPattern).length, 8);
t.is(error.stderr.match(errorPattern).length, 16);
t.is(error.exitCode, 1);
}
});
Expand Down Expand Up @@ -413,7 +413,7 @@ test('linting using a toml configuration file works', async t => {
t.fail();
} catch (error) {
t.is(error.stdout, '');
t.is(error.stderr.match(errorPattern).length, 15);
t.is(error.stderr.match(errorPattern).length, 23);
t.is(error.exitCode, 1);
}
});
Expand All @@ -424,7 +424,7 @@ test('linting using a yaml configuration file works', async t => {
t.fail();
} catch (error) {
t.is(error.stdout, '');
t.is(error.stderr.match(errorPattern).length, 15);
t.is(error.stderr.match(errorPattern).length, 23);
t.is(error.exitCode, 1);
}
});
Expand Down Expand Up @@ -665,6 +665,21 @@ test('fixing errors with a glob yields fewer errors', async t => {
}
});

test('default ignore is applied correctly', async t => {
try {
await execa(path.resolve('..', 'markdownlint.js'), ['.'], {
cwd: path.join(__dirname, 'default-ignore'),
stripFinalNewline: false
});
t.fail();
} catch (error) {
const expected = ['incorrect.md:1:8 MD047/single-trailing-newline Files should end with a single newline character', ''].join('\n');
t.is(error.stdout, '');
t.is(error.stderr.replaceAll('\\', '/'), expected);
t.is(error.exitCode, 1);
}
});

test('.markdownlintignore is applied correctly', async t => {
try {
await execa(path.resolve('..', 'markdownlint.js'), ['.'], {
Expand Down