diff --git a/rollup.config.ts b/rollup.config.ts index f364e6ea..c0838a06 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -2,7 +2,7 @@ import { rollupPlugin as rollupPluginDeassert } from "deassert"; import { type RollupOptions } from "rollup"; import rollupPluginTs from "rollup-plugin-ts"; -import pkg from "./package.json" assert { type: "json" }; +import pkg from "./package.json" with { type: "json" }; const treeshake = { annotations: true, diff --git a/scripts/typegen.ts b/scripts/typegen.ts index 1a59517f..0973629f 100644 --- a/scripts/typegen.ts +++ b/scripts/typegen.ts @@ -67,6 +67,7 @@ const configs = (await combine( }), markdown({ files: [], + enableTypeRequiredRules: false, componentExts: [], overrides: undefined, }), @@ -107,6 +108,8 @@ const configs = (await combine( unsafe: "off", functionalEnforcement: "none", ignoreNamePattern: [], + projectRoot: process.cwd(), + mode: "none", }), unicorn(), unocss({ @@ -122,6 +125,8 @@ const configs = (await combine( typescript: false, stylistic: false, files: [], + filesTypeAware: [], + parserOptions: {}, }), yaml({ overrides: undefined, diff --git a/src/configs/markdown.ts b/src/configs/markdown.ts index ef049843..7b891100 100644 --- a/src/configs/markdown.ts +++ b/src/configs/markdown.ts @@ -11,16 +11,21 @@ import { type OptionsComponentExts, type OptionsFiles, type OptionsOverrides, + type OptionsTypeRequiredRules, } from "../types"; import { interopDefault, loadPackages, parserPlain } from "../utils"; export async function markdown( options: Readonly< - Required + Required< + OptionsFiles & + OptionsComponentExts & + OptionsTypeRequiredRules & + OptionsOverrides + > >, ): Promise { - const { componentExts, files, overrides } = options; - const enableTypeRequiredRules = false as boolean; // TODO: finish setting up. + const { componentExts, files, overrides, enableTypeRequiredRules } = options; const [pluginMarkdown] = (await loadPackages(["eslint-plugin-markdown"])) as [ ESLint.Plugin, @@ -61,20 +66,16 @@ export async function markdown( }, }, { - name: "rs:markdown:disables", + name: "rs:markdown:code", files: [ GLOB_MARKDOWN_CODE, - ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`), + ...componentExts.map((ext) => `${GLOB_MARKDOWN}/*.${ext}`), ], languageOptions: { parserOptions: { ...(enableTypeRequiredRules - ? {} - : { - project: false, - projectService: false, - program: null, - }), + ? undefined + : { project: false, projectService: false, program: null }), ecmaFeatures: { impliedStrict: true, }, @@ -82,9 +83,11 @@ export async function markdown( }, rules: { ...(enableTypeRequiredRules - ? {} - : pluginTs?.configs["disable-type-checked"]?.rules), - ...pluginFunctional?.configs.off.rules, + ? undefined + : { + ...pluginTs?.configs["disable-type-checked"]?.rules, + ...pluginFunctional?.configs.off.rules, + }), "dot-notation": "off", "init-declarations": "off", diff --git a/src/factory.ts b/src/factory.ts index b828cc78..71d2aec5 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -137,10 +137,12 @@ export function rsEslint( OptionsTypeScriptParserOptions & OptionsTypeScriptShorthands; - const projectServiceUserConfig = - typeof parserOptions?.projectService === "object" + const projectServiceUserConfig = { + defaultProject: "./tsconfig.json", + ...(typeof parserOptions?.projectService === "object" ? parserOptions.projectService - : {}; + : undefined), + }; const typescriptConfigOptions: Required = { ...typeScriptSubOptions, @@ -154,7 +156,6 @@ export function rsEslint( : useDefaultDefaultProject === false ? projectServiceUserConfig : { - defaultProject: "./tsconfig.json", allowDefaultProject: [ path.join(projectRoot, GLOB_ROOT_JS), path.join(projectRoot, GLOB_ROOT_JSX), @@ -310,6 +311,10 @@ export function rsEslint( if (markdownOptions !== false) { m_configs.push( markdown({ + enableTypeRequiredRules: + typeof options.markdown === "boolean" + ? options.markdown + : (options.markdown?.enableTypeRequiredRules ?? false), files: [GLOB_MARKDOWN], componentExts, overrides: getOverrides(options, "markdown"), diff --git a/src/types.ts b/src/types.ts index 9eb30797..665e0e2c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -133,6 +133,10 @@ export type OptionsHasTypeScript = { typescript?: boolean; }; +export type OptionsTypeRequiredRules = { + enableTypeRequiredRules?: boolean; +}; + export type OptionsStylistic = { stylistic?: StylisticConfig | false; }; @@ -257,7 +261,7 @@ export type OptionsConfig = { * * For formatting Markdown content, enable also `formatters.markdown`. */ - markdown?: boolean | OptionsOverrides; + markdown?: boolean | (OptionsOverrides & OptionsTypeRequiredRules); /** * Enable stylistic rules.