-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat!: map known code block languages to respective file extensions #246
feat!: map known code block languages to respective file extensions #246
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting this together. I agree, this looks like a breaking change, so adding the label.
It actually looks like this change might have broken the lint task, can you take a look at that?
Otherwise, just a few suggestions throughout.
@@ -115,7 +115,7 @@ describe("processor", () => { | |||
"```js", | |||
"backticks", | |||
"```", | |||
"~~~javascript", | |||
"~~~js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would make sense to leave this as "javascript" to ensure it gets translated into .js
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are already the preexisting test cases "should find code fences with javascript info string" and "should find code fences with node info string" which test the mapping. As such I changed it in the other test cases.
The lint task was failing as one of the mappings also enabled linting the nested code blocks nested in |
I removed the code block language mapping from |
I think at this point we don't need to do anything to cater to CommonJS, specifically. I'm not sure what |
Can you explain this a bit more? I'm not quite sure I follow what happened here. On HEAD linting passes as-is, so I don't just want to disable rules without understanding what changed. |
One of the added mappings from code block language was from markdown to md. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. This looks good to me now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, one last thing: can you please update the README to explain how this works? (There's already a section about how filenames are determined, so expanding on that would be great.)
Co-authored-by: Nicholas C. Zakas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks! Just leaving open to see if other wants to review before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note about the docs, otherwise LGTM.
Co-authored-by: Francesco Trotta <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
##### [v5.1.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#510-2024-07-05) ##### Features - add name to flat configs ([#256](eslint/markdown#256)) ([001d51e](eslint/markdown@001d51e)) ##### [v5.0.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#500-2024-05-01) ##### ⚠ BREAKING CHANGES - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ##### Features - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ([096cff4](eslint/markdown@096cff4)) ##### Bug Fixes - check upper bounds of message line numbers for code blocks ([#247](eslint/markdown#247)) ([00adccb](eslint/markdown@00adccb)) ##### Chores - run tests in Node.js 22, with ESLint 9 ([#250](eslint/markdown#250)) ([085e6d5](eslint/markdown@085e6d5)) - switch to eslint v9, eslint-config-eslint v10 ([#251](eslint/markdown#251)) ([a76cdf5](eslint/markdown@a76cdf5))
##### [v5.1.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#510-2024-07-05) ##### Features - add name to flat configs ([#256](eslint/markdown#256)) ([001d51e](eslint/markdown@001d51e)) ##### [v5.0.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#500-2024-05-01) ##### ⚠ BREAKING CHANGES - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ##### Features - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ([096cff4](eslint/markdown@096cff4)) ##### Bug Fixes - check upper bounds of message line numbers for code blocks ([#247](eslint/markdown#247)) ([00adccb](eslint/markdown@00adccb)) ##### Chores - run tests in Node.js 22, with ESLint 9 ([#250](eslint/markdown#250)) ([085e6d5](eslint/markdown@085e6d5)) - switch to eslint v9, eslint-config-eslint v10 ([#251](eslint/markdown#251)) ([a76cdf5](eslint/markdown@a76cdf5))
##### [v5.1.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#510-2024-07-05) ##### Features - add name to flat configs ([#256](eslint/markdown#256)) ([001d51e](eslint/markdown@001d51e)) ##### [v5.0.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#500-2024-05-01) ##### ⚠ BREAKING CHANGES - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ##### Features - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ([096cff4](eslint/markdown@096cff4)) ##### Bug Fixes - check upper bounds of message line numbers for code blocks ([#247](eslint/markdown#247)) ([00adccb](eslint/markdown@00adccb)) ##### Chores - run tests in Node.js 22, with ESLint 9 ([#250](eslint/markdown#250)) ([085e6d5](eslint/markdown@085e6d5)) - switch to eslint v9, eslint-config-eslint v10 ([#251](eslint/markdown#251)) ([a76cdf5](eslint/markdown@a76cdf5))
##### [v5.1.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#510-2024-07-05) ##### Features - add name to flat configs ([#256](eslint/markdown#256)) ([001d51e](eslint/markdown@001d51e)) ##### [v5.0.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#500-2024-05-01) ##### ⚠ BREAKING CHANGES - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ##### Features - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ([096cff4](eslint/markdown@096cff4)) ##### Bug Fixes - check upper bounds of message line numbers for code blocks ([#247](eslint/markdown#247)) ([00adccb](eslint/markdown@00adccb)) ##### Chores - run tests in Node.js 22, with ESLint 9 ([#250](eslint/markdown#250)) ([085e6d5](eslint/markdown@085e6d5)) - switch to eslint v9, eslint-config-eslint v10 ([#251](eslint/markdown#251)) ([a76cdf5](eslint/markdown@a76cdf5))
##### [v5.1.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#510-2024-07-05) ##### Features - add name to flat configs ([#256](eslint/markdown#256)) ([001d51e](eslint/markdown@001d51e)) ##### [v5.0.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#500-2024-05-01) ##### ⚠ BREAKING CHANGES - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ##### Features - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ([096cff4](eslint/markdown@096cff4)) ##### Bug Fixes - check upper bounds of message line numbers for code blocks ([#247](eslint/markdown#247)) ([00adccb](eslint/markdown@00adccb)) ##### Chores - run tests in Node.js 22, with ESLint 9 ([#250](eslint/markdown#250)) ([085e6d5](eslint/markdown@085e6d5)) - switch to eslint v9, eslint-config-eslint v10 ([#251](eslint/markdown#251)) ([a76cdf5](eslint/markdown@a76cdf5))
##### [v5.1.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#510-2024-07-05) ##### Features - add name to flat configs ([#256](eslint/markdown#256)) ([001d51e](eslint/markdown@001d51e)) ##### [v5.0.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#500-2024-05-01) ##### ⚠ BREAKING CHANGES - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ##### Features - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ([096cff4](eslint/markdown@096cff4)) ##### Bug Fixes - check upper bounds of message line numbers for code blocks ([#247](eslint/markdown#247)) ([00adccb](eslint/markdown@00adccb)) ##### Chores - run tests in Node.js 22, with ESLint 9 ([#250](eslint/markdown#250)) ([085e6d5](eslint/markdown@085e6d5)) - switch to eslint v9, eslint-config-eslint v10 ([#251](eslint/markdown#251)) ([a76cdf5](eslint/markdown@a76cdf5))
##### [v5.1.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#510-2024-07-05) ##### Features - add name to flat configs ([#256](eslint/markdown#256)) ([001d51e](eslint/markdown@001d51e)) ##### [v5.0.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#500-2024-05-01) ##### ⚠ BREAKING CHANGES - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ##### Features - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ([096cff4](eslint/markdown@096cff4)) ##### Bug Fixes - check upper bounds of message line numbers for code blocks ([#247](eslint/markdown#247)) ([00adccb](eslint/markdown@00adccb)) ##### Chores - run tests in Node.js 22, with ESLint 9 ([#250](eslint/markdown#250)) ([085e6d5](eslint/markdown@085e6d5)) - switch to eslint v9, eslint-config-eslint v10 ([#251](eslint/markdown#251)) ([a76cdf5](eslint/markdown@a76cdf5))
##### [v5.1.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#510-2024-07-05) ##### Features - add name to flat configs ([#256](eslint/markdown#256)) ([001d51e](eslint/markdown@001d51e)) ##### [v5.0.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#500-2024-05-01) ##### ⚠ BREAKING CHANGES - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ##### Features - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ([096cff4](eslint/markdown@096cff4)) ##### Bug Fixes - check upper bounds of message line numbers for code blocks ([#247](eslint/markdown#247)) ([00adccb](eslint/markdown@00adccb)) ##### Chores - run tests in Node.js 22, with ESLint 9 ([#250](eslint/markdown#250)) ([085e6d5](eslint/markdown@085e6d5)) - switch to eslint v9, eslint-config-eslint v10 ([#251](eslint/markdown#251)) ([a76cdf5](eslint/markdown@a76cdf5))
##### [v5.1.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#510-2024-07-05) ##### Features - add name to flat configs ([#256](eslint/markdown#256)) ([001d51e](eslint/markdown@001d51e)) ##### [v5.0.0](https://github.com/eslint/eslint-plugin-markdown/blob/HEAD/CHANGELOG.md#500-2024-05-01) ##### ⚠ BREAKING CHANGES - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ##### Features - map known code block languages to respective file extensions ([#246](eslint/markdown#246)) ([096cff4](eslint/markdown@096cff4)) ##### Bug Fixes - check upper bounds of message line numbers for code blocks ([#247](eslint/markdown#247)) ([00adccb](eslint/markdown@00adccb)) ##### Chores - run tests in Node.js 22, with ESLint 9 ([#250](eslint/markdown#250)) ([085e6d5](eslint/markdown@085e6d5)) - switch to eslint v9, eslint-config-eslint v10 ([#251](eslint/markdown#251)) ([a76cdf5](eslint/markdown@a76cdf5))
Fixes #245.
I researched common language codes for javascript and markdown which are not the same as the file extension.
There may be additional ones.
The current tests had test cases for the language codes
javascript
andnode
already, so I adjusted them and added a case to make sure the mapping from code block language to file extension is done after the code block language normalization.This may be a breaking change as additional code blocks may be linted.