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

Configured markdownlint to load custom config 🪇 #5

Merged
merged 14 commits into from
Jul 15, 2024

Conversation

01taylop
Copy link
Owner

@01taylop 01taylop commented Jul 15, 2024

Details

What have you changed?

  • 📑 Configured markdownlint to load custom config, defaulting to config defined by Lint Pilot.
  • 🗞️ Installed and configured @rollup/plugin-replace.
  • 🃏 Added a custom Jest matcher, toHaveBeenCalledOnceWith.
  • 🌟 Improved unit tests, TypeScript types, utility functions, and global options such as debug.

Why are you making these changes?

  • 🗞️ The @rollup/plugin-replace plugin means we can have conditional logic, such as if (process.env.NODE_ENV === 'development') { ... }, which can be removed from the bundle when compiling the module.
  • 🃏 In many tests we assert that a mock is called once and with the correct arguments. A primary use-case is when asserting console.log to ensure there are no unexpected logs. This custom matcher combines two assertions into one which helps keep the tests cleaner, leaner, and therefore easier to read and maintain.
  • 🌟 Improvements:
    • The unit tests are more concise, clearer, and more maintainable.
    • The TypeScript types are defined clearly in the most relevant files for their usage.
    • The utils such as colourLog has been improved and can now be used for all logging, including errors.
    • The option "debug" is now stored as a global so it can be accessed anywhere without needing to pass it around in each function.

This can be used to have conditional code removed when building the
module (for example, when file paths are different post-build).
This function, `colourLog.error`, can log an error in a consistent way
throughout the codebase. If `global.debug` is true, the original error
will also be logged.
Custom config is loaded from a `markdownlint.json` file.
If no config is found, default config provided by Lint Pilot is used.
@01taylop 01taylop marked this pull request as ready for review July 15, 2024 22:47
@01taylop 01taylop changed the title Improved the utils code and tests 🐠 Configured markdownlint to load custom config 🪇 Jul 15, 2024
@01taylop 01taylop merged commit 959e7aa into main Jul 15, 2024
5 checks passed
@01taylop 01taylop deleted the markdownlint-config branch July 15, 2024 23:12
@01taylop 01taylop changed the title Configured markdownlint to load custom config 🪇 Configured markdownlint to load custom config 🪇 Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant