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

[PR] Linting markdown files and checking for broken internal and external links #11

Merged
merged 14 commits into from
Jul 30, 2024

Conversation

LuchoTurtle
Copy link
Member

@LuchoTurtle LuchoTurtle commented Jul 26, 2024

closes #10

This PR adds a few new features:

@LuchoTurtle LuchoTurtle added documentation Improvements or additions to documentation enhancement New feature or enhancement of existing functionality in-progress An issue or pull request that is being worked on by the assigned person labels Jul 26, 2024
@LuchoTurtle LuchoTurtle self-assigned this Jul 26, 2024
@LuchoTurtle LuchoTurtle changed the title [PR] Linting markdown and checking for broken internal and external links [PR] Linting markdown files and checking for broken internal and external links Jul 26, 2024
Copy link

codecov bot commented Jul 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (e8a4856) to head (1a3befc).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #11   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         3    +1     
  Lines          138       211   +73     
  Branches        20        30   +10     
=========================================
+ Hits           138       211   +73     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

tutorial.md Outdated Show resolved Hide resolved
scripts/link-check.mjs Outdated Show resolved Hide resolved
@LuchoTurtle
Copy link
Member Author

Keep getting this error, darn it.

   Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
     • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    /Users/lucho/Documents/dwyl/nextra-demo/node_modules/.pnpm/[email protected]/node_modules/uuid/dist/esm-browser/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export { default as v1 } from './v1.js';
                                                                                      ^^^^^^

    SyntaxError: Unexpected token 'export'

       9 |
      10 | /**
    > 11 |  * This function checks external links that are present in the markdown files.
         |                                                      ^
      12 |  * It checks if they're alive or dead using `markdown-lint-check`.
      13 |  */
      14 | export function checkMarkdownExternalLinks(markdownBody) {

@LuchoTurtle
Copy link
Member Author

jest really is config hell for ESM :(

@LuchoTurtle
Copy link
Member Author

Trying to debug

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From tests/unit/link-check.test.ts.

for ages now.

markdown-link-check using async messes up with Jest. The test effectively passes correctly (as it should) but Jest complains something is trying to be imported after the test is passed.

@LuchoTurtle LuchoTurtle marked this pull request as ready for review July 27, 2024 15:00
@LuchoTurtle
Copy link
Member Author

@nelsonic this should be ready for review 👌

@LuchoTurtle LuchoTurtle assigned nelsonic and unassigned LuchoTurtle Jul 27, 2024
@LuchoTurtle LuchoTurtle added awaiting-review An issue or pull request that needs to be reviewed and removed in-progress An issue or pull request that is being worked on by the assigned person labels Jul 27, 2024
Copy link
Member

@nelsonic nelsonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @LuchoTurtle. 👍
Thanks. 😊

@nelsonic nelsonic merged commit 99e55db into main Jul 30, 2024
3 checks passed
@nelsonic nelsonic deleted the broken-link-checker branch July 30, 2024 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review An issue or pull request that needs to be reviewed documentation Improvements or additions to documentation enhancement New feature or enhancement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to Detect and Fix Broken Links?
2 participants