From c12a6a8613d81cf2bb115e2a6a65fe400f75f40e Mon Sep 17 00:00:00 2001 From: Dirk de Visser Date: Sat, 18 May 2024 17:26:27 +0200 Subject: [PATCH] feat(eslint-config): enable the markdown processor This makes sure all markdown snippets are linted as well Signed-off-by: Dirk de Visser --- packages/eslint-config/README.md | 2 +- packages/eslint-config/src/globs.ts | 2 +- packages/eslint-config/src/markdown.ts | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config/README.md b/packages/eslint-config/README.md index 7df2783..252da0e 100644 --- a/packages/eslint-config/README.md +++ b/packages/eslint-config/README.md @@ -202,8 +202,8 @@ This enables environment-specific globals for all files. For a stricter setup, u configuration as explained below ```js -import { defineConfig } from "@lightbase/eslint-config"; import globals from "globals"; +import { defineConfig } from "@lightbase/eslint-config"; export default defineConfig( {}, diff --git a/packages/eslint-config/src/globs.ts b/packages/eslint-config/src/globs.ts index 962f14b..b869e9f 100644 --- a/packages/eslint-config/src/globs.ts +++ b/packages/eslint-config/src/globs.ts @@ -45,7 +45,7 @@ export function globAsFormat(glob: string) { * Apply custom rules to snippets in markdown files. */ export function globMarkdownSnippetFromGlob(glob: string) { - return `**/*.md/**/.${glob.split("/").pop() ?? ""}`; + return `**/*.md/**/${glob.split("/").pop() ?? ""}`; } /** diff --git a/packages/eslint-config/src/markdown.ts b/packages/eslint-config/src/markdown.ts index 10123de..c6a0aa5 100644 --- a/packages/eslint-config/src/markdown.ts +++ b/packages/eslint-config/src/markdown.ts @@ -1,5 +1,6 @@ import type { FlatConfig } from "@typescript-eslint/utils/ts-eslint"; import markdown from "eslint-plugin-markdown"; +import typescriptEslint from "typescript-eslint"; import { globMarkdownSnippetFromGlob, GLOBS, globUse } from "./globs.js"; /** @@ -12,6 +13,10 @@ export function markdownConfig() { markdown, }, }, + { + files: globUse([GLOBS.markdown]), + processor: "markdown/markdown", + }, ] satisfies Array; } @@ -19,9 +24,10 @@ export function markdownConfig() { * Load overrides for Markdown snippets. Is separate, to allow these rules to have priority. */ export function markdownSnippetOverrides(): Array { + // Disable rules in Markdown snippets + return [ { - // Disable rules in Markdown snippets files: globUse([ globMarkdownSnippetFromGlob(GLOBS.javascript), globMarkdownSnippetFromGlob(GLOBS.typescript), @@ -30,5 +36,12 @@ export function markdownSnippetOverrides(): Array { "unused-imports/no-unused-vars": "off", }, }, + { + files: globUse([ + globMarkdownSnippetFromGlob(GLOBS.javascript), + globMarkdownSnippetFromGlob(GLOBS.typescript), + ]), + ...typescriptEslint.configs.disableTypeChecked, + }, ] satisfies Array; }