Skip to content

Commit

Permalink
feat: rule for checking for tags in frontmatter to config (#11)
Browse files Browse the repository at this point in the history
* Update generate.js

* Update package.json

* Update package.json

* Update package.json

* Update generate.js

* Update linter-test-B.md

* Update linter-test-no-errors.md

* Update linter-test-A.md

* Update article.md

* Update linter.spec.js

* Update generate.js

disabled tag checking and MD034

* Update package.json

* fix tests

* bump version
  • Loading branch information
TOsmanov authored Feb 21, 2024
1 parent 4e229d9 commit 36326e5
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 141 deletions.
20 changes: 12 additions & 8 deletions generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ function createConfig (mode = 'full', source = '', project = '') {
path.join(__dirname, '/node_modules/markdownlint-rules-foliant/lib/non-literal-fence-label'),
path.join(__dirname, '/node_modules/markdownlint-rules-foliant/lib/fenced-code-in-quote'),
path.join(__dirname, '/node_modules/markdownlint-rules-foliant/lib/typograph'),
path.join(__dirname, '/node_modules/markdownlint-rules-foliant/lib/validate-internal-links')
path.join(__dirname, '/node_modules/markdownlint-rules-foliant/lib/validate-internal-links'),
path.join(__dirname, '/node_modules/markdownlint-rules-foliant/lib/frontmatter-tags-exist')
]
} else {
customRules = [
path.resolve(__dirname, '../markdownlint-rules-foliant/lib/indented-fence'),
path.resolve(__dirname, '../markdownlint-rules-foliant/lib/non-literal-fence-label'),
path.resolve(__dirname, '../markdownlint-rules-foliant/lib/fenced-code-in-quote'),
path.resolve(__dirname, '../markdownlint-rules-foliant/lib/typograph'),
path.resolve(__dirname, '../markdownlint-rules-foliant/lib/validate-internal-links')

path.resolve(__dirname, '../markdownlint-rules-foliant/lib/validate-internal-links'),
path.resolve(__dirname, '../markdownlint-rules-foliant/lib/frontmatter-tags-exist')
]
}

Expand Down Expand Up @@ -53,7 +54,7 @@ function createConfig (mode = 'full', source = '', project = '') {
MD031: true,
MD032: false,
MD033: false,
MD034: true,
MD034: false,
MD036: true,
MD037: true,
MD038: true,
Expand All @@ -74,7 +75,8 @@ function createConfig (mode = 'full', source = '', project = '') {
'validate-internal-links': {
src: source.length === 0 ? undefined : source,
project: project.length === 0 ? undefined : project
}
},
'frontmatter-tags-exist': false
}

const configSlim = {
Expand All @@ -100,7 +102,7 @@ function createConfig (mode = 'full', source = '', project = '') {
MD031: false,
MD032: false,
MD033: false,
MD034: true,
MD034: false,
MD036: false,
MD037: false,
MD038: false,
Expand All @@ -122,7 +124,8 @@ function createConfig (mode = 'full', source = '', project = '') {
'validate-internal-links': {
src: source.length === 0 ? undefined : source,
project: project.length === 0 ? undefined : project
}
},
'frontmatter-tags-exist': false
}

const configTypograph = {
Expand Down Expand Up @@ -176,7 +179,8 @@ function createConfig (mode = 'full', source = '', project = '') {
'non-literal-fence-label': false,
'fenced-code-in-quote': false,
typograph: true,
'validate-internal-links': false
'validate-internal-links': false,
'frontmatter-tags-exist': false
}

let config
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "foliant-md-linter",
"version": "0.1.10",
"version": "0.1.11",
"description": "CLI tool for linting Foliant markdown sources",
"license": "MIT",
"homepage": "https://github.com/holamgadol/foliant-md-linter",
Expand Down
5 changes: 5 additions & 0 deletions test/alt-src/linter-test-B.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
tags:
- none
---

# Linter test B

```non-literal-fence-label{
Expand Down
264 changes: 132 additions & 132 deletions test/linter.spec.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions test/no-errors-src/linter-test-no-errors.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
tags:
- none
---

# Linter test with no errors

## Heading
Expand Down
5 changes: 5 additions & 0 deletions test/src/linter-test-A.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
tags:
- none
---

# Linter test A

### MD001: Heading levels should only increment by one level at a time
Expand Down
5 changes: 5 additions & 0 deletions test/src/subproject/article.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
tags:
- none
---

# Article

[broken local link](#anchor)
Expand Down

0 comments on commit 36326e5

Please sign in to comment.