Skip to content

feat!: set no-missing-link-fragments default ignoreCase to true #447

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

Open
wants to merge 3 commits into
base: main
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions docs/rules/no-missing-link-fragments.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,26 @@ Examples of **correct** code for this rule:
This rule supports the following options:

* `ignoreCase: boolean` -
When `true`, link fragments are compared with heading and anchor IDs in a case-insensitive manner. (default: `false`)
When `false`, link fragments are compared with heading and anchor IDs in a case-sensitive manner. (default: `true`)

Examples of **correct** code when configured as `"no-missing-link-fragments": ["error", { ignoreCase: true }]`:
Examples of **incorrect** code when configured as `"no-missing-link-fragments": ["error", { ignoreCase: false }]`:

```markdown
<!-- eslint markdown/no-missing-link-fragments: ["error", { ignoreCase: true }] -->
<!-- eslint markdown/no-missing-link-fragments: ["error", { ignoreCase: false }] -->

# Case Test

[Valid Link with different case](#CASE-TEST)
[Invalid Link with different case](#CASE-TEST)
```

Examples of **correct** code when configured as `"no-missing-link-fragments": ["error", { ignoreCase: false }]`:

```markdown
<!-- eslint markdown/no-missing-link-fragments: ["error", { ignoreCase: false }] -->

# Case Test

[Valid Link with matching case](#case-test)
```

* `allowPattern: string` -
Expand Down
4 changes: 1 addition & 3 deletions src/rules/no-missing-link-fragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ export default {
properties: {
ignoreCase: {
type: "boolean",
default: false,
},
allowPattern: {
type: "string",
default: "",
},
},
additionalProperties: false,
Expand All @@ -99,7 +97,7 @@ export default {

defaultOptions: [
{
ignoreCase: false,
ignoreCase: true,
allowPattern: "",
},
],
Expand Down
25 changes: 16 additions & 9 deletions tests/rules/no-missing-link-fragments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,19 @@ ruleTester.run("no-missing-link-fragments", rule, {
[Reference Line Range with Columns](#L6C13-L8C1)
`,

// Case-insensitive matching (with option)
{
code: dedent`
# Heading Name
[Link](#HEADING-NAME)
`,
options: [{ ignoreCase: true }],
},
// Case-insensitive matching
dedent`
# Heading Name
[Link](#HEADING-NAME)
`,
dedent`
# Heading Name
[Link](#HeAdInG-nAmE)
`,
dedent`
# Heading Name
[Link](#Heading-Name)
`,

// Ignored pattern (with option)
{
Expand Down Expand Up @@ -313,12 +318,13 @@ ruleTester.run("no-missing-link-fragments", rule, {
],
},

// Case-sensitive mismatch (without ignoreCase option)
// Case-sensitive mismatch (with ignoreCase false option)
{
code: dedent`
# Heading Name
[Invalid](#HEADING-NAME)
`,
options: [{ ignoreCase: false }],
errors: [
{
messageId: "invalidFragment",
Expand Down Expand Up @@ -382,6 +388,7 @@ ruleTester.run("no-missing-link-fragments", rule, {
# Heading {#Invalid-ID-With-Caps}
[Link](#Invalid-ID-With-Caps)
`,
options: [{ ignoreCase: false }],
errors: [
{
messageId: "invalidFragment",
Expand Down