Skip to content

Commit 77897e2

Browse files
feat: more tweaks
1 parent 1fb3566 commit 77897e2

File tree

5 files changed

+37
-20
lines changed

5 files changed

+37
-20
lines changed

rollup.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { rollupPlugin as rollupPluginDeassert } from "deassert";
22
import { type RollupOptions } from "rollup";
33
import rollupPluginTs from "rollup-plugin-ts";
44

5-
import pkg from "./package.json" assert { type: "json" };
5+
import pkg from "./package.json" with { type: "json" };
66

77
const treeshake = {
88
annotations: true,

scripts/typegen.ts

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const configs = (await combine(
6767
}),
6868
markdown({
6969
files: [],
70+
enableTypeRequiredRules: false,
7071
componentExts: [],
7172
overrides: undefined,
7273
}),
@@ -107,6 +108,8 @@ const configs = (await combine(
107108
unsafe: "off",
108109
functionalEnforcement: "none",
109110
ignoreNamePattern: [],
111+
projectRoot: process.cwd(),
112+
mode: "none",
110113
}),
111114
unicorn(),
112115
unocss({
@@ -122,6 +125,8 @@ const configs = (await combine(
122125
typescript: false,
123126
stylistic: false,
124127
files: [],
128+
filesTypeAware: [],
129+
parserOptions: {},
125130
}),
126131
yaml({
127132
overrides: undefined,

src/configs/markdown.ts

+17-14
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@ import {
1111
type OptionsComponentExts,
1212
type OptionsFiles,
1313
type OptionsOverrides,
14+
type OptionsTypeRequiredRules,
1415
} from "../types";
1516
import { interopDefault, loadPackages, parserPlain } from "../utils";
1617

1718
export async function markdown(
1819
options: Readonly<
19-
Required<OptionsFiles & OptionsComponentExts & OptionsOverrides>
20+
Required<
21+
OptionsFiles &
22+
OptionsComponentExts &
23+
OptionsTypeRequiredRules &
24+
OptionsOverrides
25+
>
2026
>,
2127
): Promise<FlatConfigItem[]> {
22-
const { componentExts, files, overrides } = options;
23-
const enableTypeRequiredRules = false as boolean; // TODO: finish setting up.
28+
const { componentExts, files, overrides, enableTypeRequiredRules } = options;
2429

2530
const [pluginMarkdown] = (await loadPackages(["eslint-plugin-markdown"])) as [
2631
ESLint.Plugin,
@@ -61,30 +66,28 @@ export async function markdown(
6166
},
6267
},
6368
{
64-
name: "rs:markdown:disables",
69+
name: "rs:markdown:code",
6570
files: [
6671
GLOB_MARKDOWN_CODE,
67-
...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`),
72+
...componentExts.map((ext) => `${GLOB_MARKDOWN}/*.${ext}`),
6873
],
6974
languageOptions: {
7075
parserOptions: {
7176
...(enableTypeRequiredRules
72-
? {}
73-
: {
74-
project: false,
75-
projectService: false,
76-
program: null,
77-
}),
77+
? undefined
78+
: { project: false, projectService: false, program: null }),
7879
ecmaFeatures: {
7980
impliedStrict: true,
8081
},
8182
},
8283
},
8384
rules: {
8485
...(enableTypeRequiredRules
85-
? {}
86-
: pluginTs?.configs["disable-type-checked"]?.rules),
87-
...pluginFunctional?.configs.off.rules,
86+
? undefined
87+
: {
88+
...pluginTs?.configs["disable-type-checked"]?.rules,
89+
...pluginFunctional?.configs.off.rules,
90+
}),
8891

8992
"dot-notation": "off",
9093
"init-declarations": "off",

src/factory.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,12 @@ export function rsEslint(
137137
OptionsTypeScriptParserOptions &
138138
OptionsTypeScriptShorthands;
139139

140-
const projectServiceUserConfig =
141-
typeof parserOptions?.projectService === "object"
140+
const projectServiceUserConfig = {
141+
defaultProject: "./tsconfig.json",
142+
...(typeof parserOptions?.projectService === "object"
142143
? parserOptions.projectService
143-
: {};
144+
: undefined),
145+
};
144146

145147
const typescriptConfigOptions: Required<OptionsTypeScriptParserOptions> = {
146148
...typeScriptSubOptions,
@@ -154,7 +156,6 @@ export function rsEslint(
154156
: useDefaultDefaultProject === false
155157
? projectServiceUserConfig
156158
: {
157-
defaultProject: "./tsconfig.json",
158159
allowDefaultProject: [
159160
path.join(projectRoot, GLOB_ROOT_JS),
160161
path.join(projectRoot, GLOB_ROOT_JSX),
@@ -310,6 +311,10 @@ export function rsEslint(
310311
if (markdownOptions !== false) {
311312
m_configs.push(
312313
markdown({
314+
enableTypeRequiredRules: !(
315+
markdownOptions === true ||
316+
markdownOptions.enableTypeRequiredRules === false
317+
),
313318
files: [GLOB_MARKDOWN],
314319
componentExts,
315320
overrides: getOverrides(options, "markdown"),

src/types.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ export type OptionsHasTypeScript = {
133133
typescript?: boolean;
134134
};
135135

136+
export type OptionsTypeRequiredRules = {
137+
enableTypeRequiredRules?: boolean;
138+
};
139+
136140
export type OptionsStylistic = {
137141
stylistic?: StylisticConfig | false;
138142
};
@@ -257,7 +261,7 @@ export type OptionsConfig = {
257261
*
258262
* For formatting Markdown content, enable also `formatters.markdown`.
259263
*/
260-
markdown?: boolean | OptionsOverrides;
264+
markdown?: boolean | (OptionsOverrides & OptionsTypeRequiredRules);
261265

262266
/**
263267
* Enable stylistic rules.

0 commit comments

Comments
 (0)