Skip to content

chore: export all Options and MessageIds types from rule files #10556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/array-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ function typeNeedsParentheses(node: TSESTree.Node): boolean {
}

export type OptionString = 'array' | 'array-simple' | 'generic';
type Options = [
export type Options = [
{
default: OptionString;
readonly?: OptionString;
},
];
type MessageIds =
export type MessageIds =
| 'errorStringArray'
| 'errorStringArrayReadonly'
| 'errorStringArraySimple'
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/await-thenable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '../util';
import { getForStatementHeadLoc } from '../util/getForStatementHeadLoc';

type MessageId =
export type MessageId =
| 'await'
| 'awaitUsingOfNonAsyncDisposable'
| 'convertToOrdinaryFor'
Expand Down
14 changes: 8 additions & 6 deletions packages/eslint-plugin/src/rules/ban-ts-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ import { AST_TOKEN_TYPES } from '@typescript-eslint/utils';

import { createRule, getStringLength, nullThrows } from '../util';

type DirectiveConfig =
const defaultMinimumDescriptionLength = 3;

export type DirectiveConfig =
| boolean
| 'allow-with-description'
| { descriptionFormat: string };

interface Options {
export interface OptionsShape {
minimumDescriptionLength?: number;
'ts-check'?: DirectiveConfig;
'ts-expect-error'?: DirectiveConfig;
'ts-ignore'?: DirectiveConfig;
'ts-nocheck'?: DirectiveConfig;
}

const defaultMinimumDescriptionLength = 3;
export type Options = [OptionsShape];

type MessageIds =
export type MessageIds =
| 'replaceTsIgnoreWithTsExpectError'
| 'tsDirectiveComment'
| 'tsDirectiveCommentDescriptionNotMatchPattern'
Expand All @@ -31,7 +33,7 @@ interface MatchedTSDirective {
directive: string;
}

export default createRule<[Options], MessageIds>({
export default createRule<Options, MessageIds>({
name: 'ban-ts-comment',
meta: {
type: 'problem',
Expand Down Expand Up @@ -203,7 +205,7 @@ export default createRule<[Options], MessageIds>({
return;
}

const fullDirective = `ts-${directive}` as keyof Options;
const fullDirective = `ts-${directive}` as keyof OptionsShape;

const option = options[fullDirective];
if (option === true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
nullThrows,
} from '../util';

type Options = ['fields' | 'getters'];
type MessageIds =
export type Options = ['fields' | 'getters'];
export type MessageIds =
| 'preferFieldStyle'
| 'preferFieldStyleSuggestion'
| 'preferGetterStyle'
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/class-methods-use-this.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import {
getStaticMemberAccessValue,
} from '../util';

type Options = [
export type Options = [
{
enforceForClassFields?: boolean;
exceptMethods?: string[];
ignoreClassesThatImplementAnInterface?: boolean | 'public-fields';
ignoreOverrideMethods?: boolean;
},
];
type MessageIds = 'missingThis';
export type MessageIds = 'missingThis';

export default createRule<Options, MessageIds>({
name: 'class-methods-use-this',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils';

import { createRule, nullThrows, NullThrowsReasons } from '../util';

type MessageIds = 'preferConstructor' | 'preferTypeAnnotation';
type Options = ['constructor' | 'type-annotation'];
export type MessageIds = 'preferConstructor' | 'preferTypeAnnotation';
export type Options = ['constructor' | 'type-annotation'];

export default createRule<Options, MessageIds>({
name: 'consistent-generic-constructors',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
nullThrows,
} from '../util';

type MessageIds =
export type MessageIds =
| 'preferIndexSignature'
| 'preferIndexSignatureSuggestion'
| 'preferRecord';
type Options = ['index-signature' | 'record'];
export type Options = ['index-signature' | 'record'];

export default createRule<Options, MessageIds>({
name: 'consistent-indexed-object-style',
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/consistent-return.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { getESLintCoreRule } from '../util/getESLintCoreRule';

const baseRule = getESLintCoreRule('consistent-return');

type Options = InferOptionsTypeFromRule<typeof baseRule>;
type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
export type Options = InferOptionsTypeFromRule<typeof baseRule>;
export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;

type FunctionNode =
| TSESTree.ArrowFunctionExpression
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/consistent-type-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
NullThrowsReasons,
} from '../util';

type Options = [
export type Options = [
{
fixMixedExportsWithInlineTypeSpecifier: boolean;
},
Expand All @@ -34,7 +34,7 @@ interface ReportValueExport {
valueSpecifiers: TSESTree.ExportSpecifier[];
}

type MessageIds =
export type MessageIds =
| 'multipleExportsAreTypes'
| 'singleExportIsType'
| 'typeOverValue';
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/consistent-type-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
type Prefer = 'no-type-imports' | 'type-imports';
type FixStyle = 'inline-type-imports' | 'separate-type-imports';

type Options = [
export type Options = [
{
disallowTypeAnnotations?: boolean;
fixStyle?: FixStyle;
Expand All @@ -45,7 +45,7 @@ interface ReportValueImport {
valueSpecifiers: TSESTree.ImportClause[];
}

type MessageIds =
export type MessageIds =
| 'avoidImportType'
| 'noImportTypeAnnotations'
| 'someImportsAreOnlyTypes'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
isValidFunctionExpressionReturnType,
} from '../util/explicitReturnTypeUtils';

type Options = [
export type Options = [
{
allowConciseArrowFunctionExpressionsStartingWithVoid?: boolean;
allowDirectConstAssertionInArrowFunctions?: boolean;
Expand All @@ -23,7 +23,7 @@ type Options = [
allowTypedFunctionExpressions?: boolean;
},
];
type MessageIds = 'missingReturnType';
export type MessageIds = 'missingReturnType';

type FunctionNode =
| TSESTree.ArrowFunctionExpression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ interface Config {
};
}

type Options = [Config];
export type Options = [Config];

type MessageIds =
export type MessageIds =
| 'addExplicitAccessibility'
| 'missingAccessibility'
| 'unwantedPublicAccessibility';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
isTypedFunctionExpression,
} from '../util/explicitReturnTypeUtils';

type Options = [
export type Options = [
{
allowArgumentsExplicitlyTypedAsAny?: boolean;
allowDirectConstAssertionInArrowFunctions?: boolean;
Expand All @@ -27,7 +27,7 @@ type Options = [
allowTypedFunctionExpressions?: boolean;
},
];
type MessageIds =
export type MessageIds =
| 'anyTypedArg'
| 'anyTypedArgUnnamed'
| 'missingArgType'
Expand Down
6 changes: 2 additions & 4 deletions packages/eslint-plugin/src/rules/naming-convention.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '../util';
import { Modifiers, parseOptions, SCHEMA } from './naming-convention-utils';

type MessageIds =
export type MessageIds =
| 'doesNotMatchFormat'
| 'doesNotMatchFormatTrimmed'
| 'missingAffix'
Expand All @@ -32,7 +32,7 @@ type MessageIds =
// Note that this intentionally does not strictly type the modifiers/types properties.
// This is because doing so creates a huge headache, as the rule's code doesn't need to care.
// The JSON Schema strictly types these properties, so we know the user won't input invalid config.
type Options = Selector[];
export type Options = Selector[];

// This essentially mirrors ESLint's `camelcase` rule
// note that that rule ignores leading and trailing underscores and only checks those in the middle of a variable name
Expand Down Expand Up @@ -789,5 +789,3 @@ function requiresQuoting(
: `${node.value}`;
return _requiresQuoting(name, target);
}

export type { MessageIds, Options };
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-array-delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
getParserServices,
} from '../util';

type MessageId = 'noArrayDelete' | 'useSplice';
export type MessageId = 'noArrayDelete' | 'useSplice';

export default createRule<[], MessageId>({
name: 'no-array-delete',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AST_NODE_TYPES, AST_TOKEN_TYPES } from '@typescript-eslint/utils';

import { createRule } from '../util';

type MessageId =
export type MessageId =
| 'confusingAssign'
| 'confusingEqual'
| 'confusingOperator'
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/no-dupe-class-members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { getESLintCoreRule } from '../util/getESLintCoreRule';

const baseRule = getESLintCoreRule('no-dupe-class-members');

type Options = InferOptionsTypeFromRule<typeof baseRule>;
type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
export type Options = InferOptionsTypeFromRule<typeof baseRule>;
export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;

export default createRule<Options, MessageIds>({
name: 'no-dupe-class-members',
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/no-empty-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { getESLintCoreRule } from '../util/getESLintCoreRule';

const baseRule = getESLintCoreRule('no-empty-function');

type Options = InferOptionsTypeFromRule<typeof baseRule>;
type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
export type Options = InferOptionsTypeFromRule<typeof baseRule>;
export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;

const defaultOptions: Options = [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/no-empty-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils';

import { createRule, isDefinitionFile } from '../util';

type Options = [
export type Options = [
{
allowSingleExtends?: boolean;
},
];
type MessageIds = 'noEmpty' | 'noEmptyWithSuper';
export type MessageIds = 'noEmpty' | 'noEmptyWithSuper';

export default createRule<Options, MessageIds>({
name: 'no-empty-interface',
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/no-extraneous-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils';

import { createRule } from '../util';

type Options = [
export type Options = [
{
allowConstructorOnly?: boolean;
allowEmpty?: boolean;
allowStaticOnly?: boolean;
allowWithDecorator?: boolean;
},
];
type MessageIds = 'empty' | 'onlyConstructor' | 'onlyStatic';
export type MessageIds = 'empty' | 'onlyConstructor' | 'onlyStatic';

export default createRule<Options, MessageIds>({
name: 'no-extraneous-class',
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/no-floating-promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
typeMatchesSomeSpecifier,
} from '../util';

type Options = [
export type Options = [
{
allowForKnownSafeCalls?: TypeOrValueSpecifier[];
allowForKnownSafePromises?: TypeOrValueSpecifier[];
Expand All @@ -28,7 +28,7 @@ type Options = [
},
];

type MessageId =
export type MessageId =
| 'floating'
| 'floatingFixAwait'
| 'floatingFixVoid'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
NullThrowsReasons,
} from '../util';

type Options = [];
type MessageIds = 'useTopLevelQualifier';
export type Options = [];
export type MessageIds = 'useTopLevelQualifier';

export default createRule<Options, MessageIds>({
name: 'no-import-type-side-effects',
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/no-inferrable-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils';

import { createRule, nullThrows, NullThrowsReasons } from '../util';

type Options = [
export type Options = [
{
ignoreParameters?: boolean;
ignoreProperties?: boolean;
},
];
type MessageIds = 'noInferrableType';
export type MessageIds = 'noInferrableType';

export default createRule<Options, MessageIds>({
name: 'no-inferrable-types',
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-invalid-void-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Options {
allowInGenericTypeArguments?: boolean | [string, ...string[]];
}

type MessageIds =
export type MessageIds =
| 'invalidVoidForGeneric'
| 'invalidVoidNotReturn'
| 'invalidVoidNotReturnOrGeneric'
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/no-loop-func.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { getESLintCoreRule } from '../util/getESLintCoreRule';

const baseRule = getESLintCoreRule('no-loop-func');

type Options = InferOptionsTypeFromRule<typeof baseRule>;
type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
export type Options = InferOptionsTypeFromRule<typeof baseRule>;
export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;

export default createRule<Options, MessageIds>({
name: 'no-loop-func',
Expand Down
6 changes: 4 additions & 2 deletions packages/eslint-plugin/src/rules/no-loss-of-precision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { getESLintCoreRule } from '../util/getESLintCoreRule';

const baseRule = getESLintCoreRule('no-loss-of-precision');

type Options = InferOptionsTypeFromRule<NonNullable<typeof baseRule>>;
type MessageIds = InferMessageIdsTypeFromRule<NonNullable<typeof baseRule>>;
export type Options = InferOptionsTypeFromRule<NonNullable<typeof baseRule>>;
export type MessageIds = InferMessageIdsTypeFromRule<
NonNullable<typeof baseRule>
>;

export default createRule<Options, MessageIds>({
name: 'no-loss-of-precision',
Expand Down
Loading
Loading