Skip to content

Commit

Permalink
refactor: adds customGroups JSON schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
hugop95 committed Oct 25, 2024
1 parent 9471944 commit 011b00c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 85 deletions.
19 changes: 2 additions & 17 deletions rules/sort-decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { SortingNode } from '../typings'
import {
partitionByCommentJsonSchema,
specialCharactersJsonSchema,
customGroupsJsonSchema,
ignoreCaseJsonSchema,
matcherJsonSchema,
groupsJsonSchema,
Expand Down Expand Up @@ -116,23 +117,7 @@ export default createEslintRule<Options<string[]>, MESSAGE_ID>({
'Allows you to use comments to separate the decorators into logical groups.',
},
groups: groupsJsonSchema,
customGroups: {
description: 'Specifies custom groups.',
type: 'object',
additionalProperties: {
oneOf: [
{
type: 'string',
},
{
type: 'array',
items: {
type: 'string',
},
},
],
},
},
customGroups: customGroupsJsonSchema,
},
additionalProperties: false,
},
Expand Down
19 changes: 2 additions & 17 deletions rules/sort-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { SortingNode } from '../typings'
import {
partitionByCommentJsonSchema,
specialCharactersJsonSchema,
customGroupsJsonSchema,
ignoreCaseJsonSchema,
matcherJsonSchema,
groupsJsonSchema,
Expand Down Expand Up @@ -116,23 +117,7 @@ export default createEslintRule<Options<string[]>, MESSAGE_ID>({
type: 'string',
},
groups: groupsJsonSchema,
customGroups: {
description: 'Specifies custom groups.',
type: 'object',
additionalProperties: {
oneOf: [
{
type: 'string',
},
{
type: 'array',
items: {
type: 'string',
},
},
],
},
},
customGroups: customGroupsJsonSchema,
},
additionalProperties: false,
},
Expand Down
19 changes: 2 additions & 17 deletions rules/sort-jsx-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { SortingNode } from '../typings'

import {
specialCharactersJsonSchema,
customGroupsJsonSchema,
ignoreCaseJsonSchema,
matcherJsonSchema,
groupsJsonSchema,
Expand Down Expand Up @@ -81,23 +82,7 @@ export default createEslintRule<Options<string[]>, MESSAGE_ID>({
type: 'array',
},
groups: groupsJsonSchema,
customGroups: {
description: 'Specifies custom groups.',
type: 'object',
additionalProperties: {
oneOf: [
{
type: 'string',
},
{
type: 'array',
items: {
type: 'string',
},
},
],
},
},
customGroups: customGroupsJsonSchema,
},
additionalProperties: false,
},
Expand Down
19 changes: 2 additions & 17 deletions rules/sort-object-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { SortingNode } from '../typings'
import {
partitionByCommentJsonSchema,
specialCharactersJsonSchema,
customGroupsJsonSchema,
ignoreCaseJsonSchema,
matcherJsonSchema,
groupsJsonSchema,
Expand Down Expand Up @@ -109,23 +110,7 @@ export default createEslintRule<Options<string[]>, MESSAGE_ID>({
enum: ['mixed', 'required-first', 'optional-first'],
},
groups: groupsJsonSchema,
customGroups: {
description: 'Specifies custom groups.',
type: 'object',
additionalProperties: {
oneOf: [
{
type: 'string',
},
{
type: 'array',
items: {
type: 'string',
},
},
],
},
},
customGroups: customGroupsJsonSchema,
},
additionalProperties: false,
},
Expand Down
19 changes: 2 additions & 17 deletions rules/sort-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { SortingNodeWithDependencies } from '../utils/sort-nodes-by-depende
import {
partitionByCommentJsonSchema,
specialCharactersJsonSchema,
customGroupsJsonSchema,
ignoreCaseJsonSchema,
matcherJsonSchema,
groupsJsonSchema,
Expand Down Expand Up @@ -128,23 +129,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
type: 'array',
},
groups: groupsJsonSchema,
customGroups: {
description: 'Specifies custom groups.',
type: 'object',
additionalProperties: {
oneOf: [
{
type: 'string',
},
{
type: 'array',
items: {
type: 'string',
},
},
],
},
},
customGroups: customGroupsJsonSchema,
},
additionalProperties: false,
},
Expand Down
18 changes: 18 additions & 0 deletions utils/common-json-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ export let groupsJsonSchema: JSONSchema4 = {
type: 'array',
}

export let customGroupsJsonSchema: JSONSchema4 = {
additionalProperties: {
oneOf: [
{
type: 'string',
},
{
items: {
type: 'string',
},
type: 'array',
},
],
},
description: 'Specifies custom groups.',
type: 'object',
}

export let partitionByCommentJsonSchema: JSONSchema4 = {
anyOf: [
{
Expand Down

0 comments on commit 011b00c

Please sign in to comment.