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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include additional schema/types for strict rule name verification #1248

Open
regseb opened this issue Jun 7, 2024 · 2 comments
Open

Include additional schema/types for strict rule name verification #1248

regseb opened this issue Jun 7, 2024 · 2 comments

Comments

@regseb
Copy link
Contributor

regseb commented Jun 7, 2024

If the configuration contains an unknown rule: Markdownlint must report that the rule isn't supported.

For example, ESLint reports the error: Definition for rule 'no-konsole' was not found.

7 years ago, I misspelled the commonds-show-output rule. And I've just realized it, thanks to a spellchecker that reported that the word commonds doesn't exist.

@DavidAnson
Copy link
Owner

This has come up before, though I can’t find the discussion. Basically, because custom rules (like the one you are using) exist, there is no definitive list of valid rules they could appear in configuration. There IS a schema for configuration files and I have instructions for how to use it generally as well as how to identify non-core rules here: https://github.com/DavidAnson/markdownlint/blob/main/schema/ValidatingConfiguration.md

But I do not think it is appropriate to throw an error just because a configured rule does not happen to be in use at the moment. That same configuration file could be used across multiple runs of the tool and some of those runs may include or exclude various rules. It’s not wrong to configure a rule that isn’t in use, though I understand why you would have liked to be alerted in this scenario.

I’m open to suggestions, but think that validating with a schema as above is a reasonable approach.

@regseb
Copy link
Contributor Author

regseb commented Jun 10, 2024

You could provide two schemas: the current markdownlint-config-schema.json and the new markdownlint-config-strict-schema.json which is the same schema, but with “additionalProperties”: false. And export a new type ConfigurationStrict which is type Configuration without [k: string]: unknown.

With this solution, I can detect my problem with the JSDoc /** @type {import("markdownlint").ConfigurationStrict} */ and TypeScript.

@DavidAnson DavidAnson changed the title Report an error for unknown rule Include additional schema/types for strict rule name verification Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants