Skip to content

Commit

Permalink
feat: add dot option to treat dots as normal characters (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
theoludwig committed Feb 26, 2021
1 parent 780a947 commit 37ac48e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 7 deletions.
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, '');
});

0 comments on commit 37ac48e

Please sign in to comment.