8000 chore: update `eslint-plugin-perfectionist` to `v4` (#11185) · aryaemami59/typescript-eslint@220c38c · GitHub
[go: up one dir, main page]

Skip to content

Commit 220c38c

Browse files
chore: update eslint-plugin-perfectionist to v4 (typescript-eslint#11185)
* chore: update dependencies * chore: update eslint config - `perfectionist` v4 uses RegExp to match, and `type` will match `typeSomething`, unlike in v3 which used `minimatch` by default. * chore: `sort-classes` fixes - The default `groups` option was updated in v4 (azat-io/eslint-plugin-perfectionist#320). Forcing back to v3 default option. * chore: `sort-imports` fixes * chore: `sort-objects` fixes * chore: `sort-union-types` fixes - This is where most of the changes are. * chore: update dependencies --------- Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
1 parent d2dfe73 commit 220c38c

File tree

19 files changed

+89
-74
lines changed

19 files changed

+89
-74
lines changed

eslint.config.mjs

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// @ts-check
22

3+
import eslintCommentsPlugin from '@eslint-community/eslint-plugin-eslint-comments/configs';
34
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
45
import { FlatCompat } from '@eslint/eslintrc';
56
import eslint from '@eslint/js';
6-
import eslintCommentsPlugin from '@eslint-community/eslint-plugin-eslint-comments/configs';
77
import tseslintInternalPlugin from '@typescript-eslint/eslint-plugin-internal';
88
import vitestPlugin from '@vitest/eslint-plugin';
99
import eslintPluginPlugin from 'eslint-plugin-eslint-plugin';
@@ -594,10 +594,10 @@ export default tseslint.config(
594594
rules: {
595595
'@typescript-eslint/internal/prefer-ast-types-enum': 'off',
596596
'import/no-default-export': 'off',
597+
'react-hooks/exhaustive-deps': 'warn', // TODO: enable it later
597598
'react/jsx-no-target-blank': 'off',
598599
'react/no-unescaped-entities': 'off',
599600
'react/prop-types': 'off',
600-
'react-hooks/exhaustive-deps': 'warn', // TODO: enable it later
601601
},
602602
settings: {
603603
react: {
@@ -632,7 +632,26 @@ export default tseslint.config(
632632
name: 'all-files',
633633
rules: {
634634
'@typescript-eslint/sort-type-constituents': 'off',
635-
'perfectionist/sort-classes': 'error',
635+
'perfectionist/sort-classes': [
636+
'error',
637+
{
638+
groups: [
639+
'index-signature',
640+
'static-property',
641+
'static-block',
642+
['protected-property', 'protected-accessor-property'],
643+
['private-property', 'private-accessor-property'],
644+
['property', 'accessor-property'],
645+
'constructor',
646+
'static-method',
647+
'protected-method',
648+
'private-method',
649+
'method',
650+
['get-method', 'set-method'],
651+
'unknown',
652+
],
653+
},
654+
],
636655
'perfectionist/sort-enums': 'off',
637656
'perfectionist/sort-objects': 'error',
638657
'perfectionist/sort-union-types': [
@@ -644,6 +663,20 @@ export default tseslint.config(
644663
],
645664
},
646665
},
666+
{
667+
files: ['packages/ast-spec/src/**/*.ts'],
668+
rules: {
669+
'perfectionist/sort-interfaces': [
670+
'error',
671+
{
672+
customGroups: {
673+
first: ['^type$'],
674+
},
675+
groups: ['first', 'unknown'],
676+
},
677+
],
678+
},
679+
},
647680
{
648681
files: [
649682
'packages/eslint-plugin/src/rules/*.ts',
@@ -655,10 +688,10 @@ export default tseslint.config(
655688
'error',
656689
{
657690
customGroups: {
658-
first: ['loc', 'name', 'node', 'type'],
659-
fourth: ['fix'],
660-
second: ['meta', 'messageId', 'start'],
661-
third: ['defaultOptions', 'data', 'end'],
691+
first: ['^loc$', '^name$', '^node$', '^type$'],
692+
fourth: ['^fix$'],
693+
second: ['^meta$', '^messageId$', '^start$'],
694+
third: ['^defaultOptions$', '^data$', '^end$'],
662695
},
663696
groups: ['first', 'second', 'third', 'fourth', 'unknown'],
664697
},
@@ -672,7 +705,7 @@ export default tseslint.config(
672705
'perfectionist/sort-objects': [
673706
'error',
674707
{
675-
customGroups: { top: ['valid'] },
708+
customGroups: { top: ['^valid$'] },
676709
groups: ['top', 'unknown'],
677710
},
678711
],
@@ -686,8 +719,8 @@ export default tseslint.config(
686719
'error',
687720
{
688721
customGroups: {
689-
first: ['type'],
690-
second: ['loc', 'range'],
722+
first: ['^type$'],
723+
second: ['^loc$', '^range$'],
691724
},
692725
groups: ['first', 'second'],
693726
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"eslint-plugin-import": "^2.31.0",
8585
"eslint-plugin-jsdoc": "^50.5.0",
8686
"eslint-plugin-jsx-a11y": "^6.10.2",
87-
"eslint-plugin-perfectionist": "^3.9.1",
87+
"eslint-plugin-perfectionist": "^4.12.3",
8888
"eslint-plugin-react": "^7.37.3",
8989
"eslint-plugin-react-hooks": "^5.0.0",
9090
"eslint-plugin-regexp": "^2.7.0",

packages/ast-spec/src/expression/UnaryExpression/spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import type { UnaryExpressionBase } from '../../base/UnaryExpressionBase';
33

44
export interface UnaryExpression extends UnaryExpressionBase {
55
type: AST_NODE_TYPES.UnaryExpression;
6-
operator: '!' | '+' | '~' | '-' | 'delete' | 'typeof' | 'void';
6+
operator: '!' | '+' | '-' | 'delete' | 'typeof' | 'void' | '~';
77
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function stringifyNode(
3636
}
3737

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

packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ export type Options = [
4747
ignoreIfStatements?: boolean;
4848
ignoreMixedLogicalExpressions?: boolean;
4949
ignorePrimitives?:
50+
| true
5051
| {
5152
bigint?: boolean;
5253
boolean?: boolean;
5354
number?: boolean;
5455
string?: boolean;
55-
}
56-
| true;
56+
};
5757
ignoreTernaryTests?: boolean;
5858
},
5959
];

packages/eslint-plugin/src/util/collectUnusedVariables.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,7 @@ class UnusedVarsVisitor extends Visitor {
230230
private markVariableAsUsed(
231231
variableOrIdentifier: ScopeVariable | TSESTree.Identifier,
232232
): void;
233-
234233
private markVariableAsUsed(name: string, parent: TSESTree.Node): void;
235-
236234
private markVariableAsUsed(
237235
variableOrIdentifierOrName: string | ScopeVariable | TSESTree.Identifier,
238236
parent?: TSESTree.Node,

packages/eslint-plugin/tests/RuleTester.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ export function batchedSingleLineTests<
4646
Options extends readonly unknown[],
4747
>(
4848
options:
49+
| ValidTestCase<Options>
4950
| ({
5051
output?: string | null;
51-
} & Omit<InvalidTestCase<MessageIds, Options>, 'output'>)
52-
| ValidTestCase<Options>,
52+
} & Omit<InvalidTestCase<MessageIds, Options>, 'output'>),
5353
): (InvalidTestCase<MessageIds, Options> | ValidTestCase<Options>)[] {
5454
// -- eslint counts lines from 1
5555
const lineOffset = options.code.startsWith('\n') ? 2 : 1;

packages/eslint-plugin/typings/eslint-rules.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,11 @@ declare module 'eslint/lib/rules/prefer-destructuring' {
520520
object?: boolean;
521521
}
522522
type Option0 =
523+
| DestructuringTypeConfig
523524
| {
524525
AssignmentExpression?: DestructuringTypeConfig;
525526
VariableDeclarator?: DestructuringTypeConfig;
526-
}
527-
| DestructuringTypeConfig;
527+
};
528528
export interface Option1 {
529529
enforceForRenamedProperties?: boolean;
530530
}
@@ -554,22 +554,22 @@ declare module 'eslint/lib/rules/no-restricted-imports' {
554554
}
555555
)[];
556556
export type ArrayOfSt 10000 ringOrObjectPatterns =
557+
| string[]
557558
| {
558559
// extended
559560
allowTypeImports?: boolean;
560561
caseSensitive?: boolean;
561562
group?: string[];
562563
regex?: string;
563564
message?: string;
564-
}[]
565-
| string[];
565+
}[];
566566
export type RuleListener =
567+
| Record<string, never>
567568
| {
568569
ExportAllDeclaration(node: TSESTree.ExportAllDeclaration): void;
569570
ExportNamedDeclaration(node: TSESTree.ExportNamedDeclaration): void;
570571
ImportDeclaration(node: TSESTree.ImportDeclaration): void;
571-
}
572-
| Record<string, never>;
572+
};
573573
}
574574

575575
export interface ObjectOfPathsAndPatterns {

packages/rule-tester/src/types/DependencyConstraint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export interface SemverVersionConstraint {
1010
readonly range: string;
1111
}
1212
export type AtLeastVersionConstraint =
13-
| `${number}.${number}.${number}`
1413
| `${number}.${number}.${number}-${string}`
14+
| `${number}.${number}.${number}`
1515
| `${number}.${number}`
1616
| `${number}`;
1717
export type VersionConstraint =

packages/scope-manager/src/referencer/Referencer.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ export class Referencer extends Visitor {
9090
}
9191
}
9292
public currentScope(): Scope;
93-
9493
public currentScope(throwOnNull: true): Scope | null;
95-
9694
public currentScope(dontThrowOnNull?: true): Scope | null {
9795
if (!dontThrowOnNull) {
9896
assert(this.scopeManager.currentScope, 'aaa');

0 commit comments

Comments
 (0)
0