Skip to content

Commit

Permalink
Fix single schema generation (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Oct 24, 2023
1 parent 802538a commit ae924f2
Show file tree
Hide file tree
Showing 25 changed files with 34 additions and 27 deletions.
13 changes: 10 additions & 3 deletions scripts/generate-eslint-dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@ for (const [ruleName, ruleDefinition] of Object.entries(rules ?? {})) {
}),
);

const optionTypes = options.map((_, index) => `Schema${index}?`);
const ruleOptionTypeValue = Array.isArray(meta.schema)
? `[${optionTypes.join(', ')}]`
: meta.schema
? 'Schema0'
: '[]';

await writeFile(
join(__dirname, '..', 'src', 'rules', 'eslint', `${ruleName}.d.ts`),
`${options.join('\n')}
export type ${pascalCase(ruleName)}RuleOptions = [${options
.map((_, index) => `Schema${index}?`)
.join(', ')}]
export type ${pascalCase(ruleName)}RuleOptions = ${
ruleName === 'no-constructor-return' ? '[Schema0?]' : ruleOptionTypeValue
};
`,
{
encoding: 'utf8',
Expand Down
2 changes: 1 addition & 1 deletion src/rules/eslint/array-element-newline.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export type BasicConfig =
minItems?: number | null;
};

export type ArrayElementNewlineRuleOptions = [Schema0?];
export type ArrayElementNewlineRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/arrow-body-style.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export type Schema0 =
},
];

export type ArrowBodyStyleRuleOptions = [Schema0?];
export type ArrowBodyStyleRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/comma-dangle.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ export type ValueWithIgnore =
| 'never'
| 'only-multiline';

export type CommaDangleRuleOptions = [Schema0?];
export type CommaDangleRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/consistent-this.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export type Schema0 = string[];

export type ConsistentThisRuleOptions = [Schema0?];
export type ConsistentThisRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/curly.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export type Schema0 =
| ['multi' | 'multi-line' | 'multi-or-nest']
| ['multi' | 'multi-line' | 'multi-or-nest', 'consistent'];

export type CurlyRuleOptions = [Schema0?];
export type CurlyRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/eqeqeq.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export type Schema0 =
| []
| ['smart' | 'allow-null'];

export type EqeqeqRuleOptions = [Schema0?];
export type EqeqeqRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/func-call-spacing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export type Schema0 =
},
];

export type FuncCallSpacingRuleOptions = [Schema0?];
export type FuncCallSpacingRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/func-name-matching.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ export type Schema0 =
},
];

export type FuncNameMatchingRuleOptions = [Schema0?];
export type FuncNameMatchingRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/func-names.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export type Schema0 =
];
export type Value = 'always' | 'as-needed' | 'never';

export type FuncNamesRuleOptions = [Schema0?];
export type FuncNamesRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/id-blacklist.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export type Schema0 = string[];

export type IdBlacklistRuleOptions = [Schema0?];
export type IdBlacklistRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/id-denylist.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export type Schema0 = string[];

export type IdDenylistRuleOptions = [Schema0?];
export type IdDenylistRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/init-declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export type Schema0 =
},
];

export type InitDeclarationsRuleOptions = [Schema0?];
export type InitDeclarationsRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/logical-assignment-operators.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export type Schema0 = (
) &
unknown[];

export type LogicalAssignmentOperatorsRuleOptions = [Schema0?];
export type LogicalAssignmentOperatorsRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/multiline-comment-style.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export type Schema0 =
},
];

export type MultilineCommentStyleRuleOptions = [Schema0?];
export type MultilineCommentStyleRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/no-extra-parens.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ export type Schema0 =
},
];

export type NoExtraParensRuleOptions = [Schema0?];
export type NoExtraParensRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/no-restricted-globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export type Schema0 = (
}
)[];

export type NoRestrictedGlobalsRuleOptions = [Schema0?];
export type NoRestrictedGlobalsRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/no-restricted-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ export type Schema0 =
},
];

export type NoRestrictedImportsRuleOptions = [Schema0?];
export type NoRestrictedImportsRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/no-restricted-modules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export type Schema0 =
patterns?: string[];
}[];

export type NoRestrictedModulesRuleOptions = [Schema0?];
export type NoRestrictedModulesRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/no-restricted-properties.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export type Schema0 = (
}
)[];

export type NoRestrictedPropertiesRuleOptions = [Schema0?];
export type NoRestrictedPropertiesRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/no-restricted-syntax.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export type Schema0 = (
}
)[];

export type NoRestrictedSyntaxRuleOptions = [Schema0?];
export type NoRestrictedSyntaxRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/object-shorthand.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ export type Schema0 =
},
];

export type ObjectShorthandRuleOptions = [Schema0?];
export type ObjectShorthandRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/padding-line-between-statements.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ export type Schema0 = {
next: StatementType;
}[];

export type PaddingLineBetweenStatementsRuleOptions = [Schema0?];
export type PaddingLineBetweenStatementsRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/quote-props.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export type Schema0 =
},
];

export type QuotePropsRuleOptions = [Schema0?];
export type QuotePropsRuleOptions = Schema0;
2 changes: 1 addition & 1 deletion src/rules/eslint/semi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export type Schema0 =
},
];

export type SemiRuleOptions = [Schema0?];
export type SemiRuleOptions = Schema0;

0 comments on commit ae924f2

Please sign in to comment.