diff --git a/rules/sort-intersection-types.ts b/rules/sort-intersection-types.ts index befe9c550..1c57690de 100644 --- a/rules/sort-intersection-types.ts +++ b/rules/sort-intersection-types.ts @@ -1,19 +1,11 @@ -import type { Options as SortUnionTypesOptions } from './sort-union-types' +import type {Options as SortUnionTypesOptions} from './sort-union-types'; -import { - partitionByCommentJsonSchema, - partitionByNewLineJsonSchema, - specialCharactersJsonSchema, - newlinesBetweenJsonSchema, - ignoreCaseJsonSchema, - buildTypeJsonSchema, - alphabetJsonSchema, - localesJsonSchema, - groupsJsonSchema, - orderJsonSchema, -} from '../utils/common-json-schemas' import { sortUnionOrIntersectionTypes } from './sort-union-types' import { createEslintRule } from '../utils/create-eslint-rule' +import { + + jsonSchema +} from './sort-union-types' type MESSAGE_ID = | 'missedSpacingBetweenIntersectionTypes' @@ -38,28 +30,6 @@ let defaultOptions: Required = { export default createEslintRule({ meta: { - schema: [ - { - properties: { - partitionByComment: { - ...partitionByCommentJsonSchema, - description: - 'Allows you to use comments to separate the intersection types members into logical groups.', - }, - partitionByNewLine: partitionByNewLineJsonSchema, - specialCharacters: specialCharactersJsonSchema, - newlinesBetween: newlinesBetweenJsonSchema, - ignoreCase: ignoreCaseJsonSchema, - alphabet: alphabetJsonSchema, - type: buildTypeJsonSchema(), - locales: localesJsonSchema, - groups: groupsJsonSchema, - order: orderJsonSchema, - }, - additionalProperties: false, - type: 'object', - }, - ], messages: { unexpectedIntersectionTypesGroupOrder: 'Expected "{{right}}" ({{rightGroup}}) to come before "{{left}}" ({{leftGroup}}).', @@ -75,6 +45,7 @@ export default createEslintRule({ description: 'Enforce sorted intersection types.', recommended: true, }, + schema: [jsonSchema], type: 'suggestion', fixable: 'code', }, diff --git a/rules/sort-union-types.ts b/rules/sort-union-types.ts index 271a72a72..492b1f2ee 100644 --- a/rules/sort-union-types.ts +++ b/rules/sort-union-types.ts @@ -1,3 +1,4 @@ +import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema' import type { RuleContext } from '@typescript-eslint/utils/ts-eslint' import type { TSESTree } from '@typescript-eslint/types' @@ -98,30 +99,29 @@ let defaultOptions: Required = { groups: [], } +export let jsonSchema: JSONSchema4 = { + properties: { + partitionByComment: { + ...partitionByCommentJsonSchema, + description: + 'Allows you to use comments to separate the union types into logical groups.', + }, + partitionByNewLine: partitionByNewLineJsonSchema, + specialCharacters: specialCharactersJsonSchema, + newlinesBetween: newlinesBetweenJsonSchema, + ignoreCase: ignoreCaseJsonSchema, + alphabet: alphabetJsonSchema, + type: buildTypeJsonSchema(), + locales: localesJsonSchema, + groups: groupsJsonSchema, + order: orderJsonSchema, + }, + additionalProperties: false, + type: 'object', +} + export default createEslintRule({ meta: { - schema: [ - { - properties: { - partitionByComment: { - ...partitionByCommentJsonSchema, - description: - 'Allows you to use comments to separate the union types into logical groups.', - }, - partitionByNewLine: partitionByNewLineJsonSchema, - specialCharacters: specialCharactersJsonSchema, - newlinesBetween: newlinesBetweenJsonSchema, - ignoreCase: ignoreCaseJsonSchema, - alphabet: alphabetJsonSchema, - type: buildTypeJsonSchema(), - locales: localesJsonSchema, - groups: groupsJsonSchema, - order: orderJsonSchema, - }, - additionalProperties: false, - type: 'object', - }, - ], messages: { unexpectedUnionTypesGroupOrder: 'Expected "{{right}}" ({{rightGroup}}) to come before "{{left}}" ({{leftGroup}}).', @@ -137,6 +137,7 @@ export default createEslintRule({ description: 'Enforce sorted union types.', recommended: true, }, + schema: [jsonSchema], type: 'suggestion', fixable: 'code', },