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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dot option to treat dots as normal characters #167

Merged
merged 4 commits into from Feb 26, 2021
Merged
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
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -29,13 +29,14 @@ markdownlint --help

-h, --help output usage information
-V, --version output the version number
-f, --fix fix basic errors (does not work with STDIN)
-s, --stdin read from STDIN (does not work with files)
-o, --output [outputFile] write issues to file (no console)
-c, --config [configFile] configuration file (JSON, JSONC, JS, or YAML)
-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
-o, --output [outputFile] write issues to file (no console)
-p, --ignore-path [file] path to file with ignore pattern(s)
-r, --rules [file|directory|glob|package] custom rule files
-s, --stdin read from STDIN (does not work with files)
```

### Globbing
Expand Down
10 changes: 6 additions & 4 deletions markdownlint.js
Expand Up @@ -78,6 +78,7 @@ function readConfiguration(args) {

function prepareFileList(files, fileExtensions, previousResults) {
const globOptions = {
dot: !!options.dot,
nodir: true
};
let extensionGlobPart = '*.';
Expand Down Expand Up @@ -187,13 +188,14 @@ program
.version(pkg.version)
.description(pkg.description)
.usage('[options] <files|directories|globs>')
.option('-f, --fix', 'fix basic errors (does not work with STDIN)')
.option('-s, --stdin', 'read from STDIN (does not work with files)')
.option('-o, --output [outputFile]', 'write issues to file (no console)')
.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('-o, --output [outputFile]', 'write issues to file (no console)')
.option('-p, --ignore-path [file]', 'path to file with ignore pattern(s)')
.option('-r, --rules [file|directory|glob|package]', 'custom rule files', concatArray, []);
.option('-r, --rules [file|directory|glob|package]', 'custom rule files', concatArray, [])
.option('-s, --stdin', 'read from STDIN (does not work with files)');

program.parse(process.argv);

Expand Down
8 changes: 8 additions & 0 deletions test/.folder/.file-with-dot.md
@@ -0,0 +1,8 @@
## header 2
# header

```fence
$ code
```

text
26 changes: 26 additions & 0 deletions test/.folder/incorrect-dot.md
@@ -0,0 +1,26 @@
## header 2
# header

```fence
$ code
```

text

```fence
$ code
```

text

```fence
$ code
```

text

```fence
$ code
```

text
20 changes: 20 additions & 0 deletions test/test.js
Expand Up @@ -740,3 +740,23 @@ test('Linter text file --output must end with EOF newline', async t => {
fs.unlinkSync(output);
}
});

test('--dot option to include folders/files with a dot', async (t) => {
try {
await execa('../markdownlint.js',
['--config', 'test-config.json', '--dot', '**/incorrect-dot.md', '**/.file-with-dot.md', '**/correct.md'],
{stripFinalNewline: false});
t.fail();
} catch (error) {
t.is(error.stdout, '');
t.is(error.stderr.match(errorPattern).length, 13);
}
});

test('without --dot option exclude folders/files with a dot', async (t) => {
const result = await execa('../markdownlint.js',
['--config', 'test-config.json', '**/incorrect-dot.md', '**/.file-with-dot.md', '**/correct.md'],
{stripFinalNewline: false});
t.is(result.stdout, '');
t.is(result.stderr, '');
});