Skip to content

Commit

Permalink
fix: more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Apr 17, 2024
1 parent 9d188ec commit 14d0426
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
5 changes: 3 additions & 2 deletions scripts/typegen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from "node:fs/promises";

import { type Linter } from "eslint";
import { flatConfigsToRulesDTS } from "eslint-typegen/core";

import {
Expand Down Expand Up @@ -30,7 +31,7 @@ import {
} from "../src/configs";
import { combine } from "../src/utils";

const configs = await combine(
const configs = (await combine(
comments(),
formatters({}, {}),
functional({}),
Expand All @@ -55,7 +56,7 @@ const configs = await combine(
unocss({}),
vue({}),
yaml({}),
);
)) as Linter.FlatConfig[];

const dts = await flatConfigsToRulesDTS(configs, {
includeAugmentation: false,
Expand Down
15 changes: 6 additions & 9 deletions src/configs/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ export async function comments(): Promise<FlatConfigItem[]> {
{
name: "rs:comments",
plugins: {
"eslint-comments": pluginComments,
comments: pluginComments,
},
rules: {
"eslint-comments/no-aggregating-enable": "error",
"eslint-comments/no-duplicate-disable": "error",
"eslint-comments/no-unlimited-disable": "error",
"eslint-comments/no-unused-enable": "error",
"eslint-comments/disable-enable-pair": [
"error",
{ allowWholeFile: true },
],
"comments/no-aggregating-enable": "error",
"comments/no-duplicate-disable": "error",
"comments/no-unlimited-disable": "error",
"comments/no-unused-enable": "error",
"comments/disable-enable-pair": ["error", { allowWholeFile: true }],
},
},
];
Expand Down
5 changes: 3 additions & 2 deletions src/configs/functional.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { GLOB_TS } from "../globs";
import {
type FlatConfigItem,
type OptionsFunctional,
Expand All @@ -8,6 +7,8 @@ import {
} from "../types";
import { loadPackages } from "../utils";

import { defaultFilesTypesAware } from "./typescript";

export async function functional(
options: Readonly<
OptionsFunctional &
Expand All @@ -19,7 +20,7 @@ export async function functional(
const {
overrides = {},
stylistic = true,
filesTypeAware = [GLOB_TS],
filesTypeAware = defaultFilesTypesAware,
functionalEnforcement = "none",
} = options;

Expand Down
20 changes: 9 additions & 11 deletions src/configs/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
} from "../types";
import { loadPackages, toArray } from "../utils";

export const defaultFilesTypesAware = [GLOB_TS, GLOB_TSX, GLOB_DTS];

export async function typescript(
options: Readonly<
OptionsFiles &
Expand All @@ -44,11 +46,7 @@ export async function typescript(
...componentExts.map((ext) => `**/*.${ext}`),
];

const filesTypeAware = options.filesTypeAware ?? [
GLOB_TS,
GLOB_TSX,
GLOB_DTS,
];
const filesTypeAware = options.filesTypeAware ?? defaultFilesTypesAware;
const tsconfigPath =
options.tsconfig === undefined
? undefined
Expand All @@ -64,13 +62,13 @@ export async function typescript(

function makeParser(
typeAware: boolean,
files: Readonly<string[]>,
ignores?: Readonly<string[]>,
files: string[],
ignores: string[] = [],
): FlatConfigItem {
return {
name: `rs:typescript:${typeAware ? "type-aware-parser" : "parser"}`,
files: [...files],
...(ignores === undefined ? {} : { ignores: [...ignores] }),
files,
ignores,
languageOptions: {
parser: parserTs,
parserOptions: {
Expand Down Expand Up @@ -450,15 +448,15 @@ export async function typescript(
},
},
{
name: "rs:typescript:rules-non-type-aware",
files,
ignores: filesTypeAware,
name: "rs:typescript:rules-non-type-aware",
rules: ((pluginTs.configs?.["disable-type-checked"] as Linter.FlatConfig)
.rules ?? {}) as NonNullable<FlatConfigItem["rules"]>,
},
{
files: GLOB_TESTS,
name: "rs:typescript:tests-overrides",
files: GLOB_TESTS,
rules: {
"ts/no-unused-expressions": "off",
"ts/consistent-type-definitions": "off",
Expand Down

0 comments on commit 14d0426

Please sign in to comment.