From 0b31fba6212f385960e1ff6a70efd0fd3b70d08f Mon Sep 17 00:00:00 2001 From: Azat S Date: Mon, 12 Jun 2023 00:13:52 +0300 Subject: [PATCH] Add support for Perfectionist --- package.json | 1 + pnpm-lock.yaml | 101 +++++++++++++++++- .../generate-rule-files/src/plugins-map.ts | 4 + src/rules/index.d.ts | 2 + src/rules/perfectionist/index.d.ts | 28 +++++ .../perfectionist/sort-array-includes.d.ts | 37 +++++++ src/rules/perfectionist/sort-classes.d.ts | 37 +++++++ src/rules/perfectionist/sort-enums.d.ts | 36 +++++++ src/rules/perfectionist/sort-imports.d.ts | 40 +++++++ src/rules/perfectionist/sort-interfaces.d.ts | 37 +++++++ src/rules/perfectionist/sort-jsx-props.d.ts | 40 +++++++ .../perfectionist/sort-map-elements.d.ts | 36 +++++++ .../perfectionist/sort-named-exports.d.ts | 36 +++++++ .../perfectionist/sort-named-imports.d.ts | 36 +++++++ .../perfectionist/sort-object-types.d.ts | 36 +++++++ src/rules/perfectionist/sort-objects.d.ts | 37 +++++++ src/rules/perfectionist/sort-union-types.d.ts | 36 +++++++ 17 files changed, 579 insertions(+), 1 deletion(-) create mode 100644 src/rules/perfectionist/index.d.ts create mode 100644 src/rules/perfectionist/sort-array-includes.d.ts create mode 100644 src/rules/perfectionist/sort-classes.d.ts create mode 100644 src/rules/perfectionist/sort-enums.d.ts create mode 100644 src/rules/perfectionist/sort-imports.d.ts create mode 100644 src/rules/perfectionist/sort-interfaces.d.ts create mode 100644 src/rules/perfectionist/sort-jsx-props.d.ts create mode 100644 src/rules/perfectionist/sort-map-elements.d.ts create mode 100644 src/rules/perfectionist/sort-named-exports.d.ts create mode 100644 src/rules/perfectionist/sort-named-imports.d.ts create mode 100644 src/rules/perfectionist/sort-object-types.d.ts create mode 100644 src/rules/perfectionist/sort-objects.d.ts create mode 100644 src/rules/perfectionist/sort-union-types.d.ts diff --git a/package.json b/package.json index 63e5b8ec..eb87d035 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "eslint-plugin-mdx": "~2.0.5", "eslint-plugin-n": "~15.7.0", "eslint-plugin-node": "~11.1.0", + "eslint-plugin-perfectionist": "~1.1.2", "eslint-plugin-prettier": "~4.2.1", "eslint-plugin-promise": "~6.1.1", "eslint-plugin-react": "~7.32.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fbef618f..3c17f1ba 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,8 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false devDependencies: '@graphql-eslint/eslint-plugin': @@ -70,6 +74,9 @@ devDependencies: eslint-plugin-node: specifier: ~11.1.0 version: 11.1.0(eslint@8.39.0) + eslint-plugin-perfectionist: + specifier: ~1.1.2 + version: 1.1.2(eslint@8.39.0)(typescript@5.0.4) eslint-plugin-prettier: specifier: ~4.2.1 version: 4.2.1(eslint-config-prettier@8.8.0)(eslint@8.39.0)(prettier@2.8.8) @@ -1241,6 +1248,14 @@ packages: '@typescript-eslint/visitor-keys': 5.59.1 dev: true + /@typescript-eslint/scope-manager@5.59.9: + resolution: {integrity: sha512-8RA+E+w78z1+2dzvK/tGZ2cpGigBZ58VMEHDZtpE1v+LLjzrYGc8mMaTONSxKyEkz3IuXFM0IqYiGHlCsmlZxQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dependencies: + '@typescript-eslint/types': 5.59.9 + '@typescript-eslint/visitor-keys': 5.59.9 + dev: true + /@typescript-eslint/type-utils@5.59.1(eslint@8.39.0)(typescript@5.0.4): resolution: {integrity: sha512-ZMWQ+Oh82jWqWzvM3xU+9y5U7MEMVv6GLioM3R5NJk6uvP47kZ7YvlgSHJ7ERD6bOY7Q4uxWm25c76HKEwIjZw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1266,6 +1281,11 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true + /@typescript-eslint/types@5.59.9: + resolution: {integrity: sha512-uW8H5NRgTVneSVTfiCVffBb8AbwWSKg7qcA4Ot3JI3MPCJGsB4Db4BhvAODIIYE5mNj7Q+VJkK7JxmRhk2Lyjw==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dev: true + /@typescript-eslint/typescript-estree@5.59.1(typescript@5.0.4): resolution: {integrity: sha512-lYLBBOCsFltFy7XVqzX0Ju+Lh3WPIAWxYpmH/Q7ZoqzbscLiCW00LeYCdsUnnfnj29/s1WovXKh2gwCoinHNGA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1287,6 +1307,27 @@ packages: - supports-color dev: true + /@typescript-eslint/typescript-estree@5.59.9(typescript@5.0.4): + resolution: {integrity: sha512-pmM0/VQ7kUhd1QyIxgS+aRvMgw+ZljB3eDb+jYyp6d2bC0mQWLzUDF+DLwCTkQ3tlNyVsvZRXjFyV0LkU/aXjA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/types': 5.59.9 + '@typescript-eslint/visitor-keys': 5.59.9 + debug: 4.3.4 + globby: 11.1.0 + is-glob: 4.0.3 + semver: 7.5.0 + tsutils: 3.21.0(typescript@5.0.4) + typescript: 5.0.4 + transitivePeerDependencies: + - supports-color + dev: true + /@typescript-eslint/utils@5.59.1(eslint@8.39.0)(typescript@5.0.4): resolution: {integrity: sha512-MkTe7FE+K1/GxZkP5gRj3rCztg45bEhsd8HYjczBuYm+qFHP5vtZmjx3B0yUCDotceQ4sHgTyz60Ycl225njmA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1307,6 +1348,26 @@ packages: - typescript dev: true + /@typescript-eslint/utils@5.59.9(eslint@8.39.0)(typescript@5.0.4): + resolution: {integrity: sha512-1PuMYsju/38I5Ggblaeb98TOoUvjhRvLpLa1DoTOFaLWqaXl/1iQ1eGurTXgBY58NUdtfTXKP5xBq7q9NDaLKg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.39.0) + '@types/json-schema': 7.0.11 + '@types/semver': 7.3.13 + '@typescript-eslint/scope-manager': 5.59.9 + '@typescript-eslint/types': 5.59.9 + '@typescript-eslint/typescript-estree': 5.59.9(typescript@5.0.4) + eslint: 8.39.0 + eslint-scope: 5.1.1 + semver: 7.5.0 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /@typescript-eslint/visitor-keys@5.59.1: resolution: {integrity: sha512-6waEYwBTCWryx0VJmP7JaM4FpipLsFl9CvYf2foAE8Qh/Y0s+bxWysciwOs0LTBED4JCaNxTZ5rGadB14M6dwA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1315,6 +1376,14 @@ packages: eslint-visitor-keys: 3.4.0 dev: true + /@typescript-eslint/visitor-keys@5.59.9: + resolution: {integrity: sha512-bT7s0td97KMaLwpEBckbzj/YohnvXtqbe2XgqNvTl6RJVakY5mvENOTPvw5u66nljfZxthESpDozs86U+oLY8Q==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dependencies: + '@typescript-eslint/types': 5.59.9 + eslint-visitor-keys: 3.4.0 + dev: true + /@vitest/expect@0.30.1: resolution: {integrity: sha512-c3kbEtN8XXJSeN81iDGq29bUzSjQhjES2WR3aColsS4lPGbivwLtas4DNUe0jD9gg/FYGIteqOenfU95EFituw==} dependencies: @@ -2490,6 +2559,23 @@ packages: semver: 6.3.0 dev: true + /eslint-plugin-perfectionist@1.1.2(eslint@8.39.0)(typescript@5.0.4): + resolution: {integrity: sha512-JG/rS7VnH6hXjWAGO83xCHTK+tgGRJyaDk5wGv2qTpnS8Iw+TpzSj/gQSJ2WAPaQJ9hEMN4OvrrUO1mzikUNEg==} + peerDependencies: + eslint: '>=8.0.0' + dependencies: + '@typescript-eslint/types': 5.59.9 + '@typescript-eslint/utils': 5.59.9(eslint@8.39.0)(typescript@5.0.4) + eslint: 8.39.0 + is-core-module: 2.12.1 + json5: 2.2.3 + minimatch: 9.0.1 + natural-compare-lite: 1.4.0 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /eslint-plugin-prettier@4.2.1(eslint-config-prettier@8.8.0)(eslint@8.39.0)(prettier@2.8.8): resolution: {integrity: sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==} engines: {node: '>=12.0.0'} @@ -3331,6 +3417,12 @@ packages: has: 1.0.3 dev: true + /is-core-module@2.12.1: + resolution: {integrity: sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==} + dependencies: + has: 1.0.3 + dev: true + /is-date-object@1.0.5: resolution: {integrity: sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==} engines: {node: '>= 0.4'} @@ -4227,6 +4319,13 @@ packages: brace-expansion: 2.0.1 dev: true + /minimatch@9.0.1: + resolution: {integrity: sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==} + engines: {node: '>=16 || 14 >=14.17'} + dependencies: + brace-expansion: 2.0.1 + dev: true + /minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} dev: true diff --git a/scripts/generate-rule-files/src/plugins-map.ts b/scripts/generate-rule-files/src/plugins-map.ts index 4b9b84c0..d2be3e6a 100644 --- a/scripts/generate-rule-files/src/plugins-map.ts +++ b/scripts/generate-rule-files/src/plugins-map.ts @@ -55,6 +55,10 @@ export const PLUGIN_REGISTRY: Readonly> = { name: 'Node', module: 'eslint-plugin-node', }, + perfectionist: { + name: 'Perfectionist', + module: 'eslint-plugin-perfectionist', + }, promise: { name: 'Promise', module: 'eslint-plugin-promise', diff --git a/src/rules/index.d.ts b/src/rules/index.d.ts index 70323bac..6744d282 100644 --- a/src/rules/index.d.ts +++ b/src/rules/index.d.ts @@ -8,6 +8,7 @@ import type { JsoncRules } from './jsonc'; import type { JsxA11yRules } from './jsx-a11y'; import type { NRules } from './n'; import type { NodeRules } from './node'; +import type { PerfectionistRules } from './perfectionist'; import type { PromiseRules } from './promise'; import type { ReactRules } from './react'; import type { ReactHooksRules } from './react-hooks'; @@ -38,6 +39,7 @@ export type Rules = Partial< JsxA11yRules & NodeRules & NRules & + PerfectionistRules & PromiseRules & ReactHooksRules & ReactRules & diff --git a/src/rules/perfectionist/index.d.ts b/src/rules/perfectionist/index.d.ts new file mode 100644 index 00000000..0c6c6e35 --- /dev/null +++ b/src/rules/perfectionist/index.d.ts @@ -0,0 +1,28 @@ +import type { SortArrayIncludesRule } from './sort-array-includes'; +import type { SortClassesRule } from './sort-classes'; +import type { SortEnumsRule } from './sort-enums'; +import type { SortImportsRule } from './sort-imports'; +import type { SortInterfacesRule } from './sort-interfaces'; +import type { SortJsxPropsRule } from './sort-jsx-props'; +import type { SortMapElementsRule } from './sort-map-elements'; +import type { SortNamedExportsRule } from './sort-named-exports'; +import type { SortNamedImportsRule } from './sort-named-imports'; +import type { SortObjectTypesRule } from './sort-object-types'; +import type { SortObjectsRule } from './sort-objects'; +import type { SortUnionTypesRule } from './sort-union-types'; + +/** + * All Perfectionist rules. + */ +export type PerfectionistRules = SortArrayIncludesRule & + SortClassesRule & + SortEnumsRule & + SortImportsRule & + SortInterfacesRule & + SortJsxPropsRule & + SortMapElementsRule & + SortNamedExportsRule & + SortNamedImportsRule & + SortObjectTypesRule & + SortObjectsRule & + SortUnionTypesRule; diff --git a/src/rules/perfectionist/sort-array-includes.d.ts b/src/rules/perfectionist/sort-array-includes.d.ts new file mode 100644 index 00000000..9ebecb8c --- /dev/null +++ b/src/rules/perfectionist/sort-array-includes.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortArrayIncludesOption { + type?: 'alphabetical' | 'natural' | 'line-length'; + order?: 'asc' | 'desc'; + 'ignore-case'?: boolean; + 'spread-last'?: boolean; +} + +/** + * Options. + */ +export type SortArrayIncludesOptions = [SortArrayIncludesOption?]; + +/** + * Enforce sorted arrays before include method. + * + * @see [sort-array-includes](https://eslint-plugin-perfectionist.azat.io/rules/sort-array-includes) + */ +export type SortArrayIncludesRuleConfig = RuleConfig; + +/** + * Enforce sorted arrays before include method. + * + * @see [sort-array-includes](https://eslint-plugin-perfectionist.azat.io/rules/sort-array-includes) + */ +export interface SortArrayIncludesRule { + /** + * Enforce sorted arrays before include method. + * + * @see [sort-array-includes](https://eslint-plugin-perfectionist.azat.io/rules/sort-array-includes) + */ + 'perfectionist/sort-array-includes': SortArrayIncludesRuleConfig; +} diff --git a/src/rules/perfectionist/sort-classes.d.ts b/src/rules/perfectionist/sort-classes.d.ts new file mode 100644 index 00000000..aa53b997 --- /dev/null +++ b/src/rules/perfectionist/sort-classes.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortClassesOption { + type?: 'alphabetical' | 'natural' | 'line-length'; + 'ignore-case'?: boolean; + order?: 'asc' | 'desc'; + groups?: any[]; +} + +/** + * Options. + */ +export type SortClassesOptions = [SortClassesOption?]; + +/** + * Enforce sorted classes. + * + * @see [sort-classes](https://eslint-plugin-perfectionist.azat.io/rules/sort-classes) + */ +export type SortClassesRuleConfig = RuleConfig; + +/** + * Enforce sorted classes. + * + * @see [sort-classes](https://eslint-plugin-perfectionist.azat.io/rules/sort-classes) + */ +export interface SortClassesRule { + /** + * Enforce sorted classes. + * + * @see [sort-classes](https://eslint-plugin-perfectionist.azat.io/rules/sort-classes) + */ + 'perfectionist/sort-classes': SortClassesRuleConfig; +} diff --git a/src/rules/perfectionist/sort-enums.d.ts b/src/rules/perfectionist/sort-enums.d.ts new file mode 100644 index 00000000..05933806 --- /dev/null +++ b/src/rules/perfectionist/sort-enums.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortEnumsOption { + type?: 'alphabetical' | 'natural' | 'line-length'; + 'ignore-case'?: boolean; + order?: 'asc' | 'desc'; +} + +/** + * Options. + */ +export type SortEnumsOptions = [SortEnumsOption?]; + +/** + * Enforce sorted TypeScript enums. + * + * @see [sort-enums](https://eslint-plugin-perfectionist.azat.io/rules/sort-enums) + */ +export type SortEnumsRuleConfig = RuleConfig; + +/** + * Enforce sorted TypeScript enums. + * + * @see [sort-enums](https://eslint-plugin-perfectionist.azat.io/rules/sort-enums) + */ +export interface SortEnumsRule { + /** + * Enforce sorted TypeScript enums. + * + * @see [sort-enums](https://eslint-plugin-perfectionist.azat.io/rules/sort-enums) + */ + 'perfectionist/sort-enums': SortEnumsRuleConfig; +} diff --git a/src/rules/perfectionist/sort-imports.d.ts b/src/rules/perfectionist/sort-imports.d.ts new file mode 100644 index 00000000..c45588e4 --- /dev/null +++ b/src/rules/perfectionist/sort-imports.d.ts @@ -0,0 +1,40 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortImportsOption { + type?: 'alphabetical' | 'natural' | 'line-length'; + order?: 'asc' | 'desc'; + 'ignore-case'?: boolean; + groups?: any[]; + 'internal-pattern'?: any[]; + 'newlines-between'?: 'ignore' | 'always' | 'never'; + 'read-tsconfig'?: boolean; +} + +/** + * Options. + */ +export type SortImportsOptions = [SortImportsOption?]; + +/** + * Enforce sorted imports. + * + * @see [sort-imports](https://eslint-plugin-perfectionist.azat.io/rules/sort-imports) + */ +export type SortImportsRuleConfig = RuleConfig; + +/** + * Enforce sorted imports. + * + * @see [sort-imports](https://eslint-plugin-perfectionist.azat.io/rules/sort-imports) + */ +export interface SortImportsRule { + /** + * Enforce sorted imports. + * + * @see [sort-imports](https://eslint-plugin-perfectionist.azat.io/rules/sort-imports) + */ + 'perfectionist/sort-imports': SortImportsRuleConfig; +} diff --git a/src/rules/perfectionist/sort-interfaces.d.ts b/src/rules/perfectionist/sort-interfaces.d.ts new file mode 100644 index 00000000..3bed9357 --- /dev/null +++ b/src/rules/perfectionist/sort-interfaces.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortInterfacesOption { + type?: 'alphabetical' | 'natural' | 'line-length'; + order?: 'asc' | 'desc'; + 'ignore-case'?: boolean; + 'ignore-pattern'?: any[]; +} + +/** + * Options. + */ +export type SortInterfacesOptions = [SortInterfacesOption?]; + +/** + * Enforce sorted interface properties. + * + * @see [sort-interfaces](https://eslint-plugin-perfectionist.azat.io/rules/sort-interfaces) + */ +export type SortInterfacesRuleConfig = RuleConfig; + +/** + * Enforce sorted interface properties. + * + * @see [sort-interfaces](https://eslint-plugin-perfectionist.azat.io/rules/sort-interfaces) + */ +export interface SortInterfacesRule { + /** + * Enforce sorted interface properties. + * + * @see [sort-interfaces](https://eslint-plugin-perfectionist.azat.io/rules/sort-interfaces) + */ + 'perfectionist/sort-interfaces': SortInterfacesRuleConfig; +} diff --git a/src/rules/perfectionist/sort-jsx-props.d.ts b/src/rules/perfectionist/sort-jsx-props.d.ts new file mode 100644 index 00000000..5762ccfb --- /dev/null +++ b/src/rules/perfectionist/sort-jsx-props.d.ts @@ -0,0 +1,40 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortJsxPropsOption { + type?: 'alphabetical' | 'natural' | 'line-length'; + order?: 'asc' | 'desc'; + 'always-on-top'?: any[]; + 'ignore-case'?: boolean; + shorthand?: 'first' | 'last' | 'ignore'; + callback?: 'first' | 'last' | 'ignore'; + multiline?: 'first' | 'last' | 'ignore'; +} + +/** + * Options. + */ +export type SortJsxPropsOptions = [SortJsxPropsOption?]; + +/** + * Enforce sorted JSX props. + * + * @see [sort-jsx-props](https://eslint-plugin-perfectionist.azat.io/rules/sort-jsx-props) + */ +export type SortJsxPropsRuleConfig = RuleConfig; + +/** + * Enforce sorted JSX props. + * + * @see [sort-jsx-props](https://eslint-plugin-perfectionist.azat.io/rules/sort-jsx-props) + */ +export interface SortJsxPropsRule { + /** + * Enforce sorted JSX props. + * + * @see [sort-jsx-props](https://eslint-plugin-perfectionist.azat.io/rules/sort-jsx-props) + */ + 'perfectionist/sort-jsx-props': SortJsxPropsRuleConfig; +} diff --git a/src/rules/perfectionist/sort-map-elements.d.ts b/src/rules/perfectionist/sort-map-elements.d.ts new file mode 100644 index 00000000..9e6b91b6 --- /dev/null +++ b/src/rules/perfectionist/sort-map-elements.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortMapElementsOption { + type?: 'alphabetical' | 'natural' | 'line-length'; + order?: 'asc' | 'desc'; + 'ignore-case'?: boolean; +} + +/** + * Options. + */ +export type SortMapElementsOptions = [SortMapElementsOption?]; + +/** + * Enforce sorted Map elements. + * + * @see [sort-map-elements](https://eslint-plugin-perfectionist.azat.io/rules/sort-map-elements) + */ +export type SortMapElementsRuleConfig = RuleConfig; + +/** + * Enforce sorted Map elements. + * + * @see [sort-map-elements](https://eslint-plugin-perfectionist.azat.io/rules/sort-map-elements) + */ +export interface SortMapElementsRule { + /** + * Enforce sorted Map elements. + * + * @see [sort-map-elements](https://eslint-plugin-perfectionist.azat.io/rules/sort-map-elements) + */ + 'perfectionist/sort-map-elements': SortMapElementsRuleConfig; +} diff --git a/src/rules/perfectionist/sort-named-exports.d.ts b/src/rules/perfectionist/sort-named-exports.d.ts new file mode 100644 index 00000000..e96cbca6 --- /dev/null +++ b/src/rules/perfectionist/sort-named-exports.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortNamedExportsOption { + type?: 'alphabetical' | 'natural' | 'line-length'; + order?: 'asc' | 'desc'; + 'ignore-case'?: boolean; +} + +/** + * Options. + */ +export type SortNamedExportsOptions = [SortNamedExportsOption?]; + +/** + * Enforce sorted named exports. + * + * @see [sort-named-exports](https://eslint-plugin-perfectionist.azat.io/rules/sort-named-exports) + */ +export type SortNamedExportsRuleConfig = RuleConfig; + +/** + * Enforce sorted named exports. + * + * @see [sort-named-exports](https://eslint-plugin-perfectionist.azat.io/rules/sort-named-exports) + */ +export interface SortNamedExportsRule { + /** + * Enforce sorted named exports. + * + * @see [sort-named-exports](https://eslint-plugin-perfectionist.azat.io/rules/sort-named-exports) + */ + 'perfectionist/sort-named-exports': SortNamedExportsRuleConfig; +} diff --git a/src/rules/perfectionist/sort-named-imports.d.ts b/src/rules/perfectionist/sort-named-imports.d.ts new file mode 100644 index 00000000..abce682c --- /dev/null +++ b/src/rules/perfectionist/sort-named-imports.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortNamedImportsOption { + type?: 'alphabetical' | 'natural' | 'line-length'; + order?: 'asc' | 'desc'; + 'ignore-case'?: boolean; +} + +/** + * Options. + */ +export type SortNamedImportsOptions = [SortNamedImportsOption?]; + +/** + * Enforce sorted named imports. + * + * @see [sort-named-imports](https://eslint-plugin-perfectionist.azat.io/rules/sort-named-imports) + */ +export type SortNamedImportsRuleConfig = RuleConfig; + +/** + * Enforce sorted named imports. + * + * @see [sort-named-imports](https://eslint-plugin-perfectionist.azat.io/rules/sort-named-imports) + */ +export interface SortNamedImportsRule { + /** + * Enforce sorted named imports. + * + * @see [sort-named-imports](https://eslint-plugin-perfectionist.azat.io/rules/sort-named-imports) + */ + 'perfectionist/sort-named-imports': SortNamedImportsRuleConfig; +} diff --git a/src/rules/perfectionist/sort-object-types.d.ts b/src/rules/perfectionist/sort-object-types.d.ts new file mode 100644 index 00000000..1bafdaee --- /dev/null +++ b/src/rules/perfectionist/sort-object-types.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortObjectTypesOption { + type?: 'alphabetical' | 'natural' | 'line-length'; + order?: 'asc' | 'desc'; + 'ignore-case'?: boolean; +} + +/** + * Options. + */ +export type SortObjectTypesOptions = [SortObjectTypesOption?]; + +/** + * Enforce sorted object types. + * + * @see [sort-object-types](https://eslint-plugin-perfectionist.azat.io/rules/sort-object-types) + */ +export type SortObjectTypesRuleConfig = RuleConfig; + +/** + * Enforce sorted object types. + * + * @see [sort-object-types](https://eslint-plugin-perfectionist.azat.io/rules/sort-object-types) + */ +export interface SortObjectTypesRule { + /** + * Enforce sorted object types. + * + * @see [sort-object-types](https://eslint-plugin-perfectionist.azat.io/rules/sort-object-types) + */ + 'perfectionist/sort-object-types': SortObjectTypesRuleConfig; +} diff --git a/src/rules/perfectionist/sort-objects.d.ts b/src/rules/perfectionist/sort-objects.d.ts new file mode 100644 index 00000000..24a3bfe1 --- /dev/null +++ b/src/rules/perfectionist/sort-objects.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortObjectsOption { + type?: 'alphabetical' | 'natural' | 'line-length'; + order?: 'asc' | 'desc'; + 'ignore-case'?: boolean; + 'always-on-top'?: any[]; +} + +/** + * Options. + */ +export type SortObjectsOptions = [SortObjectsOption?]; + +/** + * Enforce sorted objects. + * + * @see [sort-objects](https://eslint-plugin-perfectionist.azat.io/rules/sort-objects) + */ +export type SortObjectsRuleConfig = RuleConfig; + +/** + * Enforce sorted objects. + * + * @see [sort-objects](https://eslint-plugin-perfectionist.azat.io/rules/sort-objects) + */ +export interface SortObjectsRule { + /** + * Enforce sorted objects. + * + * @see [sort-objects](https://eslint-plugin-perfectionist.azat.io/rules/sort-objects) + */ + 'perfectionist/sort-objects': SortObjectsRuleConfig; +} diff --git a/src/rules/perfectionist/sort-union-types.d.ts b/src/rules/perfectionist/sort-union-types.d.ts new file mode 100644 index 00000000..0f0bf496 --- /dev/null +++ b/src/rules/perfectionist/sort-union-types.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface SortUnionTypesOption { + type?: 'alphabetical' | 'natural' | 'line-length'; + order?: 'asc' | 'desc'; + 'ignore-case'?: boolean; +} + +/** + * Options. + */ +export type SortUnionTypesOptions = [SortUnionTypesOption?]; + +/** + * Enforce sorted union types. + * + * @see [sort-union-types](https://eslint-plugin-perfectionist.azat.io/rules/sort-union-types) + */ +export type SortUnionTypesRuleConfig = RuleConfig; + +/** + * Enforce sorted union types. + * + * @see [sort-union-types](https://eslint-plugin-perfectionist.azat.io/rules/sort-union-types) + */ +export interface SortUnionTypesRule { + /** + * Enforce sorted union types. + * + * @see [sort-union-types](https://eslint-plugin-perfectionist.azat.io/rules/sort-union-types) + */ + 'perfectionist/sort-union-types': SortUnionTypesRuleConfig; +}