Skip to content

Commit

Permalink
refactor(plugin-eslint): update to renamed config types
Browse files Browse the repository at this point in the history
  • Loading branch information
matejchalk committed Dec 17, 2024
1 parent 2e7ca9c commit 03f5e61
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('eslint').Linter.FlatConfig[]} */
/** @type {import('eslint').Linter.Config[]} */
module.exports = [
{
ignores: ['code-pushup.config.ts'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('loadRulesForFlatConfig', () => {
});

it('should load built-in rules from implicit flat config location', async () => {
const config: Linter.FlatConfig = {
const config: Linter.Config = {
rules: {
'no-unused-vars': 'error',
'prefer-const': 'warn',
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('loadRulesForFlatConfig', () => {
} as Rule.RuleModule,
},
} as ESLint.Plugin;
const config: Linter.FlatConfig[] = [
const config: Linter.Config[] = [
{
plugins: {
'@typescript-eslint': tseslint,
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('loadRulesForFlatConfig', () => {
});

it('should load custom rule options', async () => {
const config: Linter.FlatConfig[] = [
const config: Linter.Config[] = [
{
rules: {
complexity: ['warn', 30],
Expand Down Expand Up @@ -171,7 +171,7 @@ describe('loadRulesForFlatConfig', () => {
});

it('should create multiple rule instances when different options used', async () => {
const config: Linter.FlatConfig[] = [
const config: Linter.Config[] = [
{
rules: {
'max-lines': ['warn', { max: 300 }],
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-eslint/src/lib/meta/versions/flat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function loadRulesForFlatConfig({
.filter(exists);
}

type FlatConfig = Linter.FlatConfig | Linter.FlatConfig[];
type FlatConfig = Linter.Config | Linter.Config[];

async function loadConfigByDefaultLocation(): Promise<FlatConfig> {
const flatConfigFileNames = [
Expand Down Expand Up @@ -63,7 +63,7 @@ async function loadConfigByPath(configPath: string): Promise<FlatConfig> {
}

function findEnabledRulesWithOptions(
configs: Linter.FlatConfig[],
configs: Linter.Config[],
): Omit<RuleData, 'meta'>[] {
const enabledRules = configs
.flatMap(({ rules }) => Object.entries(rules ?? {}))
Expand All @@ -83,7 +83,7 @@ function findEnabledRulesWithOptions(

function findRuleMeta(
ruleId: string,
configs: Linter.FlatConfig[],
configs: Linter.Config[],
): Rule.RuleMetaData | undefined {
const { plugin, name } = parseRuleId(ruleId);
if (!plugin) {
Expand All @@ -100,7 +100,7 @@ function findBuiltinRuleMeta(name: string): Rule.RuleMetaData | undefined {
function findPluginRuleMeta(
plugin: string,
name: string,
configs: Linter.FlatConfig[],
configs: Linter.Config[],
): Rule.RuleMetaData | undefined {
const config = configs.find(({ plugins = {} }) => plugin in plugins);
const rule = config?.plugins?.[plugin]?.rules?.[name];
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-eslint/src/lib/meta/versions/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export async function loadRulesForLegacyConfig({
const configs = await toArray(patterns).reduce(
async (acc, pattern) => [
...(await acc),
(await eslint.calculateConfigForFile(pattern)) as Linter.Config,
(await eslint.calculateConfigForFile(pattern)) as Linter.LegacyConfig,
],
Promise.resolve<Linter.Config[]>([]),
Promise.resolve<Linter.LegacyConfig[]>([]),
);

const rulesIds = distinct(
Expand Down

0 comments on commit 03f5e61

Please sign in to comment.