Skip to content

Commit 81678c8

Browse files
feat: more tweaks
1 parent 068ac99 commit 81678c8

File tree

4 files changed

+44
-16
lines changed

4 files changed

+44
-16
lines changed

src/configs/markdown.ts

+20-6
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@ import {
1111
type OptionsComponentExts,
1212
type OptionsFiles,
1313
type OptionsOverrides,
14+
type OptionsTypeAwareEmbeddedLanguages,
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+
OptionsTypeAwareEmbeddedLanguages &
24+
OptionsOverrides
25+
>
2026
>,
2127
): Promise<FlatConfigItem[]> {
22-
const { componentExts, files, overrides } = options;
28+
const { componentExts, files, enableTypeAwareEmbeddedLanguages, overrides } =
29+
options;
2330

2431
const [pluginMarkdown] = (await loadPackages(["eslint-plugin-markdown"])) as [
2532
ESLint.Plugin,
@@ -67,16 +74,22 @@ export async function markdown(
6774
],
6875
languageOptions: {
6976
parserOptions: {
70-
project: false,
71-
projectService: false,
72-
program: null,
77+
...(enableTypeAwareEmbeddedLanguages
78+
? {}
79+
: {
80+
project: false,
81+
projectService: false,
82+
program: null,
83+
}),
7384
ecmaFeatures: {
7485
impliedStrict: true,
7586
},
7687
},
7788
},
7889
rules: {
79-
...pluginTs?.configs["disable-type-checked"]?.rules,
90+
...(enableTypeAwareEmbeddedLanguages
91+
? {}
92+
: pluginTs?.configs["disable-type-checked"]?.rules),
8093
...pluginFunctional?.configs.off.rules,
8194

8295
"dot-notation": "off",
@@ -123,6 +136,7 @@ export async function markdown(
123136
"ts/consistent-type-definitions": "off",
124137
"ts/consistent-type-imports": "off",
125138
"ts/explicit-member-accessibility": "off",
139+
"ts/naming-convention": "off",
126140
"ts/no-empty-function": "off",
127141
"ts/no-explicit-any": "off",
128142
"ts/no-namespace": "off",

src/configs/typescript.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export async function typescript(
191191
"ts/restrict-plus-operands": [
192192
"error",
193193
{
194-
allowAny: false,
194+
allowAny: true,
195195
allowBoolean: false,
196196
allowNullish: false,
197197
allowNumberAndString: false,

src/factory.ts

+14-8
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,24 @@ export function rsEslint(
118118

119119
const hasTypeScript = Boolean(typeScriptOptions);
120120

121-
const { filesTypeAware, parserOptions, ...typeScriptSubOptions } =
122-
resolveSubOptions(options, "typescript") as OptionsTypescript &
123-
OptionsTypeScriptParserOptions;
121+
const {
122+
filesTypeAware,
123+
parserOptions,
124+
enableTypeAwareEmbeddedLanguages = false,
125+
...typeScriptSubOptions
126+
} = resolveSubOptions(options, "typescript") as OptionsTypescript &
127+
OptionsTypeScriptParserOptions;
124128

125129
const typescriptConfigOptions: Required<OptionsTypeScriptParserOptions> = {
126130
...typeScriptSubOptions,
127131
filesTypeAware: filesTypeAware ?? defaultFilesTypesAware,
128132
parserOptions: {
129-
projectService: true,
130-
// {
131-
// maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING:
132-
// Number.POSITIVE_INFINITY,
133-
// },
133+
projectService: enableTypeAwareEmbeddedLanguages
134+
? {
135+
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING:
136+
Number.POSITIVE_INFINITY,
137+
}
138+
: true,
134139
...parserOptions,
135140
},
136141
};
@@ -275,6 +280,7 @@ export function rsEslint(
275280
markdown({
276281
files: [GLOB_MARKDOWN],
277282
componentExts,
283+
enableTypeAwareEmbeddedLanguages,
278284
overrides: getOverrides(options, "markdown"),
279285
}),
280286
);

src/types.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ export type OptionsVue = {
6969

7070
export type OptionsTypescript = OptionsTypeScriptParserOptions &
7171
OptionsOverrides &
72-
OptionsTypeScriptUnsafeSeverity;
72+
OptionsTypeScriptUnsafeSeverity &
73+
OptionsTypeAwareEmbeddedLanguages;
74+
75+
export type OptionsTypeAwareEmbeddedLanguages = {
76+
/**
77+
* Warning: Slow.
78+
*/
79+
enableTypeAwareEmbeddedLanguages?: boolean;
80+
};
7381

7482
export type OptionsFormatters = {
7583
js?: boolean;

0 commit comments

Comments
 (0)