Skip to content

Commit

Permalink
Add support for Perfectionist
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Jun 11, 2023
1 parent 7a3e663 commit 0b31fba
Show file tree
Hide file tree
Showing 17 changed files with 579 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
101 changes: 100 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions scripts/generate-rule-files/src/plugins-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export const PLUGIN_REGISTRY: Readonly<Record<string, Plugin>> = {
name: 'Node',
module: 'eslint-plugin-node',
},
perfectionist: {
name: 'Perfectionist',
module: 'eslint-plugin-perfectionist',
},
promise: {
name: 'Promise',
module: 'eslint-plugin-promise',
Expand Down
2 changes: 2 additions & 0 deletions src/rules/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -38,6 +39,7 @@ export type Rules = Partial<
JsxA11yRules &
NodeRules &
NRules &
PerfectionistRules &
PromiseRules &
ReactHooksRules &
ReactRules &
Expand Down
28 changes: 28 additions & 0 deletions src/rules/perfectionist/index.d.ts
Original file line number Diff line number Diff line change
@@ -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;
37 changes: 37 additions & 0 deletions src/rules/perfectionist/sort-array-includes.d.ts
Original file line number Diff line number Diff line change
@@ -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<SortArrayIncludesOptions>;

/**
* 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;
}
37 changes: 37 additions & 0 deletions src/rules/perfectionist/sort-classes.d.ts
Original file line number Diff line number Diff line change
@@ -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<SortClassesOptions>;

/**
* 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;
}
36 changes: 36 additions & 0 deletions src/rules/perfectionist/sort-enums.d.ts
Original file line number Diff line number Diff line change
@@ -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<SortEnumsOptions>;

/**
* 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;
}
40 changes: 40 additions & 0 deletions src/rules/perfectionist/sort-imports.d.ts
Original file line number Diff line number Diff line change
@@ -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<SortImportsOptions>;

/**
* 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;
}
Loading

0 comments on commit 0b31fba

Please sign in to comment.