Skip to content

Commit 8d35958

Browse files
chore: enable eslint-plugin-perfectionist on typescript-estree package (typescript-eslint#9852)
* chore: enable eslint-plugin-perfectionist on typescript-estree package * fix: convert.ts ordering * Thanks Kirk, moved keywords to beginning
1 parent ba12b14 commit 8d35958

File tree

82 files changed

+1785
-1751
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1785
-1751
lines changed

eslint.config.mjs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ export default tseslint.config(
614614
'packages/type-utils/{src,tests,typings}/**/*.ts',
615615
'packages/types/{src,tools}/**/*.ts',
616616
'packages/typescript-eslint/{src,tests}/**/*.ts',
617+
'packages/typescript-estree/{src,tests,typings}/**/*.ts',
617618
'packages/utils/src/**/*.ts',
618619
'packages/visitor-keys/src/**/*.ts',
619620
'packages/website*/src/**/*.ts',
@@ -626,7 +627,7 @@ export default tseslint.config(
626627
'perfectionist/sort-union-types': [
627628
'error',
628629
{
629-
groups: ['unknown', 'keyword', 'nullish'],
630+
groups: ['keyword', 'unknown', 'nullish'],
630631
type: 'natural',
631632
},
632633
],
@@ -683,4 +684,19 @@ export default tseslint.config(
683684
],
684685
},
685686
},
687+
{
688+
files: ['packages/typescript-estree/src/**/*.ts'],
689+
rules: {
690+
'perfectionist/sort-objects': [
691+
'error',
692+
{
693+
customGroups: {
694+
first: ['type'],
695+
second: ['loc', 'range'],
696+
},
697+
groups: ['first', 'second'],
698+
},
699+
],
700+
},
701+
},
686702
);

packages/ast-spec/src/base/LiteralBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import type { BaseNode } from './BaseNode';
44
export interface LiteralBase extends BaseNode {
55
type: AST_NODE_TYPES.Literal;
66
raw: string;
7-
value: RegExp | bigint | boolean | number | string | null;
7+
value: bigint | boolean | number | string | RegExp | null;
88
}

packages/ast-spec/src/type/TSMappedType/spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export interface TSMappedType extends BaseNode {
99
constraint: TypeNode;
1010
key: Identifier;
1111
nameType: TypeNode | null;
12-
optional: '+' | '-' | boolean | undefined;
13-
readonly: '+' | '-' | boolean | undefined;
12+
optional: boolean | '+' | '-' | undefined;
13+
readonly: boolean | '+' | '-' | undefined;
1414
typeAnnotation: TypeNode | undefined;
1515
/** @deprecated Use {@link `constraint`} and {@link `key`} instead. */
1616
typeParameter: TSTypeParameter;

packages/eslint-plugin/src/rules/ban-ts-comment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { AST_TOKEN_TYPES } from '@typescript-eslint/utils';
55
import { createRule, getStringLength, nullThrows } from '../util';
66

77
type DirectiveConfig =
8+
| boolean
89
| 'allow-with-description'
9-
| { descriptionFormat: string }
10-
| boolean;
10+
| { descriptionFormat: string };
1111

1212
interface Options {
1313
minimumDescriptionLength?: number;

packages/eslint-plugin/src/rules/class-methods-use-this.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type Options = [
1313
{
1414
enforceForClassFields?: boolean;
1515
exceptMethods?: string[];
16-
ignoreClassesThatImplementAnInterface?: 'public-fields' | boolean;
16+
ignoreClassesThatImplementAnInterface?: boolean | 'public-fields';
1717
ignoreOverrideMethods?: boolean;
1818
},
1919
];

packages/eslint-plugin/src/rules/member-ordering.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ export default createRule<Options, MessageIds>({
995995

996996
// Standardize config
997997
let order: Order | undefined;
998-
let memberTypes: MemberType[] | string | undefined;
998+
let memberTypes: string | MemberType[] | undefined;
999999
let optionalityOrder: OptionalityOrder | undefined;
10001000

10011001
/**

packages/eslint-plugin/src/rules/naming-convention-utils/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface MatchRegex {
2323

2424
interface Selector {
2525
custom?: MatchRegex;
26-
filter?: MatchRegex | string;
26+
filter?: string | MatchRegex;
2727
// format options
2828
format: PredefinedFormatsString[] | null;
2929
leadingUnderscore?: UnderscoreOptionsString;

packages/eslint-plugin/src/rules/no-invalid-void-type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { createRule } from '../util';
66

77
interface Options {
88
allowAsThisParameter?: boolean;
9-
allowInGenericTypeArguments?: [string, ...string[]] | boolean;
9+
allowInGenericTypeArguments?: boolean | [string, ...string[]];
1010
}
1111

1212
type MessageIds =

packages/eslint-plugin/src/rules/no-misused-promises.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Options = [
1818
{
1919
checksConditionals?: boolean;
2020
checksSpreads?: boolean;
21-
checksVoidReturn?: ChecksVoidReturnOptions | boolean;
21+
checksVoidReturn?: boolean | ChecksVoidReturnOptions;
2222
},
2323
];
2424

@@ -43,7 +43,7 @@ type MessageId =
4343
| 'voidReturnVariable';
4444

4545
function parseChecksVoidReturn(
46-
checksVoidReturn: ChecksVoidReturnOptions | boolean | undefined,
46+
checksVoidReturn: boolean | ChecksVoidReturnOptions | undefined,
4747
): ChecksVoidReturnOptions | false {
4848
switch (checksVoidReturn) {
4949
case false:

packages/eslint-plugin/src/rules/no-restricted-types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { createRule, objectReduceKey } from '../util';
66

77
type Types = Record<
88
string,
9+
| boolean
10+
| string
911
| {
1012
fixWith?: string;
1113
message: string;
1214
suggest?: readonly string[];
1315
}
14-
| boolean
15-
| string
1616
| null
1717
>;
1818

@@ -37,7 +37,7 @@ function stringifyNode(
3737
}
3838

3939
function getCustomMessage(
40-
bannedType: { fixWith?: string; message?: string } | true | string | null,
40+
bannedType: string | { fixWith?: string; message?: string } | true | null,
4141
): string {
4242
if (!bannedType || bannedType === true) {
4343
return '';

0 commit comments

Comments
 (0)