[GH-ISSUE #219] Extends does not work for subfolders (possible CLI issue) #188

Closed
opened 2026-03-03 01:24:31 +03:00 by kerem · 15 comments
Owner

Originally created by @TheJaredWilcurt on GitHub (Aug 28, 2019).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/219

YAML configs

✔️ YAML next to file works

extends: file.yml

✔️ JSON next to file works

extends: file.json

./ subfolder YAML does not work

extends: ./node_modules/folder/file.yml

./ subfolder JSON does not work

extends: ./node_modules/folder/file.json

Relative subfolder YAML does not work

extends: node_modules/folder/file.yml

Relative subfolder JSON does not work

extends: node_modules/folder/file.json

JSON configs

✔️ YAML next to file works

{
  "extends": "file.yml"
}

✔️ JSON next to file works

{
  "extends": "file.json"
}

./ subfolder YAML does not work

{
  "extends": "./node_modules/folder/file.yml"
}

./ subfolder JSON does not work

{
  "extends": "./node_modules/folder/file.json"
}

Relative subfolder YAML does not work

{
  "extends": "node_modules/folder/file.yml"
}

Relative subfolder JSON does not work

{
  "extends": "node_modules/folder/file.json"
}
Originally created by @TheJaredWilcurt on GitHub (Aug 28, 2019). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/219 # YAML configs ✔️ YAML next to file works ```yml extends: file.yml ``` ✔️ JSON next to file works ```yml extends: file.json ``` ❌ `./` subfolder YAML does not work ```yml extends: ./node_modules/folder/file.yml ``` ❌ `./` subfolder JSON does not work ```yml extends: ./node_modules/folder/file.json ``` ❌ Relative subfolder YAML does not work ```yml extends: node_modules/folder/file.yml ``` ❌ Relative subfolder JSON does not work ```yml extends: node_modules/folder/file.json ``` # JSON configs ✔️ YAML next to file works ```json { "extends": "file.yml" } ``` ✔️ JSON next to file works ```json { "extends": "file.json" } ``` ❌ `./` subfolder YAML does not work ```json { "extends": "./node_modules/folder/file.yml" } ``` ❌ `./` subfolder JSON does not work ```json { "extends": "./node_modules/folder/file.json" } ``` ❌ Relative subfolder YAML does not work ```json { "extends": "node_modules/folder/file.yml" } ``` ❌ Relative subfolder JSON does not work ```json { "extends": "node_modules/folder/file.json" } ```
kerem 2026-03-03 01:24:31 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Aug 28, 2019):

There are tests for relative and absolute path handling for this scenario, so I hope it is not as broken as the above seems to suggest. I believe paths are resolved relative to the working directory rather than the input file. Is there a chance that’s responsible for the behavior above? If not, I will need to try to reproduce this myself.

<!-- gh-comment-id:525818634 --> @DavidAnson commented on GitHub (Aug 28, 2019): There are tests for relative and absolute path handling for this scenario, so I hope it is not as broken as the above seems to suggest. I believe paths are resolved relative to the working directory rather than the input file. Is there a chance that’s responsible for the behavior above? If not, I will need to try to reproduce this myself.
Author
Owner

@DavidAnson commented on GitHub (Aug 28, 2019):

To be clear, I think the extends path is relative to the working directory when specified in the options object, and relative to the config file when specified inside a config file. I’m not entirely sure of the structure you have above.

<!-- gh-comment-id:525823945 --> @DavidAnson commented on GitHub (Aug 28, 2019): To be clear, I think the extends path is relative to the working directory when specified in the options object, and relative to the config file when specified inside a config file. I’m not entirely sure of the structure you have above.
Author
Owner

@TheJaredWilcurt commented on GitHub (Aug 28, 2019):

CWD is C:\project

C:\project> npm run lint
markdownlint -i './node_modules/**/*' --config ./markdownlint.yml ./docs/**/*.md
---
extends: ./node_modules/tjw-markdown-lint-rules/tjwmarkdownlint.yml
proper-names:
  names:
    - Project Name

Folder structure for C:\project

C:\project>
docs\
node_modules\
markdownlint.yml
package.json
README.md

This has a few problems:

  1. The extends doesn't work unless I put the tjwmarkdownlint.yml next to the markdownlint.yml
    • And change markdownlint.yml extend to extends: tjwmarkdownlint.yml
  2. The -i './node_modules/**/*' doesn't seem to actually ignore
  3. I can't target multiple inputs, like './README.md, ./docs/**/*.md'
  4. So I'm stuck just targeting ./docs/**/*.md to avoid linting node_modules. Where as I would prefer to just ignore node_modules and target ./**/*.md. But I know most of these problems are probably for the markdownlint-cli repo.
<!-- gh-comment-id:525852264 --> @TheJaredWilcurt commented on GitHub (Aug 28, 2019): CWD is `C:\project` ``` C:\project> npm run lint markdownlint -i './node_modules/**/*' --config ./markdownlint.yml ./docs/**/*.md ``` ```yml --- extends: ./node_modules/tjw-markdown-lint-rules/tjwmarkdownlint.yml proper-names: names: - Project Name ``` Folder structure for `C:\project` ``` C:\project> docs\ node_modules\ markdownlint.yml package.json README.md ``` This has a few problems: 1. The extends doesn't work unless I put the `tjwmarkdownlint.yml` next to the `markdownlint.yml` * And change `markdownlint.yml` extend to `extends: tjwmarkdownlint.yml` 1. The `-i './node_modules/**/*'` doesn't seem to actually ignore 1. I can't target multiple inputs, like `'./README.md, ./docs/**/*.md'` 1. So I'm stuck just targeting `./docs/**/*.md` to avoid linting `node_modules`. Where as I would prefer to just ignore `node_modules` and target `./**/*.md`. But I know most of these problems are probably for the `markdownlint-cli` repo.
Author
Owner

@TheJaredWilcurt commented on GitHub (Aug 28, 2019):

For clarification, running npm run lint above will still run and lint, it just won't use any of the rules set by the file I am extending (unless it is moved to the same directory level)

<!-- gh-comment-id:525869107 --> @TheJaredWilcurt commented on GitHub (Aug 28, 2019): For clarification, running `npm run lint` above will still run and lint, it just won't use any of the rules set by the file I am extending (unless it is moved to the same directory level)
Author
Owner

@DavidAnson commented on GitHub (Aug 28, 2019):

If you have a repo that shows the problem, please provide a link. You are right that some of this may be CLI behavior. It’s curious you find that ignore does not work - could you please look at this exchange and the example I created for that scenario? https://github.com/igorshubovych/markdownlint-cli/issues/62

<!-- gh-comment-id:525874934 --> @DavidAnson commented on GitHub (Aug 28, 2019): If you have a repo that shows the problem, please provide a link. You are right that some of this may be CLI behavior. It’s curious you find that ignore does not work - could you please look at this exchange and the example I created for that scenario? https://github.com/igorshubovych/markdownlint-cli/issues/62
Author
Owner

@DavidAnson commented on GitHub (Aug 28, 2019):

Your 1 definitely seems like a problem. I’ll need to debug to determine where, though.

<!-- gh-comment-id:525876538 --> @DavidAnson commented on GitHub (Aug 28, 2019): Your 1 definitely seems like a problem. I’ll need to debug to determine where, though.
Author
Owner

@TheJaredWilcurt commented on GitHub (Aug 28, 2019):

@DavidAnson I'm working on this:

Currently in Windows. Will try Ubuntu VM to see if issue occurs in other OS's.

<!-- gh-comment-id:525876937 --> @TheJaredWilcurt commented on GitHub (Aug 28, 2019): @DavidAnson I'm working on this: * https://github.com/tjw-lint/tjw-markdownlint-rules Currently in Windows. Will try Ubuntu VM to see if issue occurs in other OS's.
Author
Owner

@TheJaredWilcurt commented on GitHub (Aug 28, 2019):

On Ubuntu VM:

Following instructions from:

Using this repo for testing

  1. "Extends" won't work unless in the same directory
  2. The ignore works (Making the "ignore" issue a Windows specific bug, probably for CLI)
  3. I still can't target multiple inputs, like './README.md, ./content/**/*.md', happening on Win and Lin, likely CLI related.
<!-- gh-comment-id:525884257 --> @TheJaredWilcurt commented on GitHub (Aug 28, 2019): On Ubuntu VM: Following instructions from: * https://github.com/tjw-lint/tjw-markdownlint-rules#how-to-use-this Using [this repo](https://github.com/TheJaredWilcurt/cole-cat) for testing 1. "Extends" won't work unless in the same directory 1. The ignore works (Making the "ignore" issue a Windows specific bug, probably for CLI) 1. I still can't target multiple inputs, like `'./README.md, ./content/**/*.md'`, happening on Win and Lin, likely CLI related.
Author
Owner

@DavidAnson commented on GitHub (Aug 28, 2019):

Quoting multiple inputs is not supported by the CLI as far as I know. I will look into the path issue with extends. But I do almost all of my ignore testing on Windows, so it’s odd that you are seeing something I am not. I will try with your repository when I look into this. However, I am in the middle of a sizable change, so won’t be able to do that immediately.

<!-- gh-comment-id:525885601 --> @DavidAnson commented on GitHub (Aug 28, 2019): Quoting multiple inputs is not supported by the CLI as far as I know. I will look into the path issue with extends. But I do almost all of my ignore testing on Windows, so it’s odd that you are seeing something I am not. I will try with your repository when I look into this. However, I am in the middle of a sizable change, so won’t be able to do that immediately.
Author
Owner

@DavidAnson commented on GitHub (Aug 28, 2019):

BTW, glob and ignore are CLI features - the library just takes a list of file names and lints them.

<!-- gh-comment-id:525886496 --> @DavidAnson commented on GitHub (Aug 28, 2019): BTW, glob and ignore are CLI features - the library just takes a list of file names and lints them.
Author
Owner

@TheJaredWilcurt commented on GitHub (Aug 29, 2019):

I updated this repo:

So you just need to do

  1. git clone https://github.com/TheJaredWilcurt/cole-cat.git
  2. cd cole-cat
  3. npm install
  4. npm run markdown-lint

Should be able to see it not ignoring node_modules, and not extending the rules.

<!-- gh-comment-id:526272118 --> @TheJaredWilcurt commented on GitHub (Aug 29, 2019): I updated this repo: * https://github.com/TheJaredWilcurt/cole-cat So you just need to do 1. `git clone https://github.com/TheJaredWilcurt/cole-cat.git` 1. `cd cole-cat` 1. `npm install` 1. `npm run markdown-lint` Should be able to see it not ignoring `node_modules`, and not extending the rules.
Author
Owner

@DavidAnson commented on GitHub (Aug 29, 2019):

Thank you!

<!-- gh-comment-id:526323883 --> @DavidAnson commented on GitHub (Aug 29, 2019): Thank you!
Author
Owner

@DavidAnson commented on GitHub (Sep 3, 2019):

@TheJaredWilcurt:

  • The problem of the CLI not ignoring node_modules is because of the single quotes around the path which get interpreted as part of the path. Removing them gives the expected behavior.
  • The problem of the CLI not extending the rules is due to a typo in the file path of the root config file. Fixing that gives the expected behavior.
    • It's possible that's what was responsible for the original "extends doesn't work" issue as well - please double-check?

Here's a diff with the two change I made to the above repo on Windows to get this working:

diff --git a/.markdown-lint.yml b/.markdown-lint.yml
index 930040d..eb86918 100644
--- a/.markdown-lint.yml
+++ b/.markdown-lint.yml
@@ -1,5 +1,5 @@
 ---
-extends: ./node_modules/tjw-markdown-lint-rules/tjwmarkdownlint.yml
+extends: ./node_modules/tjw-markdownlint-rules/tjwmarkdownlint.yml
 # Override the proper-names rule to enforce capitalization of your project's name and other proper nouns
 proper-names:
   names:
diff --git a/package.json b/package.json
index d1285b4..e19a19c 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
     "start": "node node_modules/npm-free-server/dist/server.js",
     "lint": "eslint components/**/*.vue",
     "fix": "npm run lint -- --fix",
-    "markdown-lint": "markdownlint -i './node_modules/**/*' --config ./.markdown-lint.yml ./**/*.md"
+    "markdown-lint": "markdownlint -i ./node_modules/**/* --config ./.markdown-lint.yml ./**/*.md"
   },
   "license": "MIT",
   "devDependencies": {
<!-- gh-comment-id:527293505 --> @DavidAnson commented on GitHub (Sep 3, 2019): @TheJaredWilcurt: - The problem of the CLI not ignoring `node_modules` is because of the single quotes around the path which get interpreted as part of the path. Removing them gives the expected behavior. - The problem of the CLI not extending the rules is due to a typo in the file path of the root config file. Fixing that gives the expected behavior. - It's possible that's what was responsible for the original "extends doesn't work" issue as well - please double-check? Here's a diff with the two change I made to the above repo on Windows to get this working: ```diff diff --git a/.markdown-lint.yml b/.markdown-lint.yml index 930040d..eb86918 100644 --- a/.markdown-lint.yml +++ b/.markdown-lint.yml @@ -1,5 +1,5 @@ --- -extends: ./node_modules/tjw-markdown-lint-rules/tjwmarkdownlint.yml +extends: ./node_modules/tjw-markdownlint-rules/tjwmarkdownlint.yml # Override the proper-names rule to enforce capitalization of your project's name and other proper nouns proper-names: names: diff --git a/package.json b/package.json index d1285b4..e19a19c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "start": "node node_modules/npm-free-server/dist/server.js", "lint": "eslint components/**/*.vue", "fix": "npm run lint -- --fix", - "markdown-lint": "markdownlint -i './node_modules/**/*' --config ./.markdown-lint.yml ./**/*.md" + "markdown-lint": "markdownlint -i ./node_modules/**/* --config ./.markdown-lint.yml ./**/*.md" }, "license": "MIT", "devDependencies": { ```
Author
Owner

@TheJaredWilcurt commented on GitHub (Sep 3, 2019):

The ignore being double quotes was really dumb and I should have caught. I originally had no quotes, then it wouldn't work in Linux, so I added single quotes and it worked in linux but not Windows. Anyways, double quotes works for that!

And yeah, the typo thing is really dumb too. Thanks for catching that.

<!-- gh-comment-id:527560956 --> @TheJaredWilcurt commented on GitHub (Sep 3, 2019): The ignore being double quotes was really dumb and I should have caught. I originally had no quotes, then it wouldn't work in Linux, so I added single quotes and it worked in linux but not Windows. Anyways, double quotes works for that! And yeah, the typo thing is really dumb too. Thanks for catching that.
Author
Owner

@DavidAnson commented on GitHub (Sep 3, 2019):

Glad this had a happy ending! :)

<!-- gh-comment-id:527569713 --> @DavidAnson commented on GitHub (Sep 3, 2019): Glad this had a happy ending! :)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#188
No description provided.