Skip to content

Commit

Permalink
feat: more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Jun 10, 2024
1 parent 068ac99 commit 81678c8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
26 changes: 20 additions & 6 deletions src/configs/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ import {
type OptionsComponentExts,
type OptionsFiles,
type OptionsOverrides,
type OptionsTypeAwareEmbeddedLanguages,
} from "../types";
import { interopDefault, loadPackages, parserPlain } from "../utils";

export async function markdown(
options: Readonly<
Required<OptionsFiles & OptionsComponentExts & OptionsOverrides>
Required<
OptionsFiles &
OptionsComponentExts &
OptionsTypeAwareEmbeddedLanguages &
OptionsOverrides
>
>,
): Promise<FlatConfigItem[]> {
const { componentExts, files, overrides } = options;
const { componentExts, files, enableTypeAwareEmbeddedLanguages, overrides } =
options;

const [pluginMarkdown] = (await loadPackages(["eslint-plugin-markdown"])) as [
ESLint.Plugin,
Expand Down Expand Up @@ -67,16 +74,22 @@ export async function markdown(
],
languageOptions: {
parserOptions: {
project: false,
projectService: false,
program: null,
...(enableTypeAwareEmbeddedLanguages
? {}
: {
project: false,
projectService: false,
program: null,
}),
ecmaFeatures: {
impliedStrict: true,
},
},
},
rules: {
...pluginTs?.configs["disable-type-checked"]?.rules,
...(enableTypeAwareEmbeddedLanguages
? {}
: pluginTs?.configs["disable-type-checked"]?.rules),
...pluginFunctional?.configs.off.rules,

"dot-notation": "off",
Expand Down Expand Up @@ -123,6 +136,7 @@ export async function markdown(
"ts/consistent-type-definitions": "off",
"ts/consistent-type-imports": "off",
"ts/explicit-member-accessibility": "off",
"ts/naming-convention": "off",
"ts/no-empty-function": "off",
"ts/no-explicit-any": "off",
"ts/no-namespace": "off",
Expand Down
2 changes: 1 addition & 1 deletion src/configs/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export async function typescript(
"ts/restrict-plus-operands": [
"error",
{
allowAny: false,
allowAny: true,
allowBoolean: false,
allowNullish: false,
allowNumberAndString: false,
Expand Down
22 changes: 14 additions & 8 deletions src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,24 @@ export function rsEslint(

const hasTypeScript = Boolean(typeScriptOptions);

const { filesTypeAware, parserOptions, ...typeScriptSubOptions } =
resolveSubOptions(options, "typescript") as OptionsTypescript &
OptionsTypeScriptParserOptions;
const {
filesTypeAware,
parserOptions,
enableTypeAwareEmbeddedLanguages = false,
...typeScriptSubOptions
} = resolveSubOptions(options, "typescript") as OptionsTypescript &
OptionsTypeScriptParserOptions;

const typescriptConfigOptions: Required<OptionsTypeScriptParserOptions> = {
...typeScriptSubOptions,
filesTypeAware: filesTypeAware ?? defaultFilesTypesAware,
parserOptions: {
projectService: true,
// {
// maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING:
// Number.POSITIVE_INFINITY,
// },
projectService: enableTypeAwareEmbeddedLanguages
? {
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING:
Number.POSITIVE_INFINITY,
}
: true,
...parserOptions,
},
};
Expand Down Expand Up @@ -275,6 +280,7 @@ export function rsEslint(
markdown({
files: [GLOB_MARKDOWN],
componentExts,
enableTypeAwareEmbeddedLanguages,
overrides: getOverrides(options, "markdown"),
}),
);
Expand Down
10 changes: 9 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ export type OptionsVue = {

export type OptionsTypescript = OptionsTypeScriptParserOptions &
OptionsOverrides &
OptionsTypeScriptUnsafeSeverity;
OptionsTypeScriptUnsafeSeverity &
OptionsTypeAwareEmbeddedLanguages;

export type OptionsTypeAwareEmbeddedLanguages = {
/**
* Warning: Slow.
*/
enableTypeAwareEmbeddedLanguages?: boolean;
};

export type OptionsFormatters = {
js?: boolean;
Expand Down

0 comments on commit 81678c8

Please sign in to comment.