Update the `@typescript-eslint/eslint-plugin` and
`@typescript-eslint/parser` plugin to v6.
The full list of changes needed can be found in the
[Announcing typescript-eslint v6 blog post][1], but the ones that
affect us are:
- Dropped support for Node.JS v14.
This isn't a big deal for us, since Mermaid uses a version of
`eslint-plugin-jsdoc` that does not support Node.JS v14 either,
see 120029913d31668e45daa84f7de70dfa519f3b81
(chore(deps): update dependency eslint-plugin-jsdoc to v46, 2023-06-27)
- Changes to the `plugin:@typescript-eslint/recommended` configuration.
I've manually changed the following two rules to match their old
`@typescript-eslint/parser` v5 settings, to avoid turning ESLint
warnings into errors:
- `@typescript-eslint/no-explicit-any` to `warn`
- `@typescript-eslint/no-unused-vars` to `warn`
[1]: https://main--typescript-eslint.netlify.app/blog/announcing-typescript-eslint-v6
Add script `packages/mermaid/scripts/create-types-from-json-schema.mts`
to automatically generate the TypeScript definition for `MermaidConfig`
from the `MermaidConfig` JSON Schema at
`packages/mermaid/src/schemas/config.schema.yaml`.
To do this, we are using this library
[`json-schema-to-typescript`][1], which is also used by Webpack to
generate their types from their JSON Schema.
In order to make sure that this isn't a breaking change, the script
makes all fields **optional**, as that is what the original typescript
file has.
Additionally, I've put in some custom logic into the script, so that
the exact same order is used for the TypeScript file, to make the
`git diff` easier to review. In the future, we can remove this custom
logic, once we no longer need to worry about `git merge` conflicts.
[1]: https://github.com/bcherny/json-schema-to-typescript