prettier / prettier-regression-testing

Automates the prettier/prettier regression checks with GitHub Actions.
11 stars 9 forks source link

3.2 #434

Closed sosukesuzuki closed 7 months ago

sosukesuzuki commented 7 months ago

run prettier/prettier#main vs 3.1.1

github-actions[bot] commented 7 months ago

prettier/prettier@main VS prettier/prettier@3.1.1

Diff (627 lines) ````diff diff --git ORI/babel/packages/babel-parser/src/parse-error/pipeline-operator-errors.ts ALT/babel/packages/babel-parser/src/parse-error/pipeline-operator-errors.ts index b7f21ad0..fa9e4fcf 100644 --- ORI/babel/packages/babel-parser/src/parse-error/pipeline-operator-errors.ts +++ ALT/babel/packages/babel-parser/src/parse-error/pipeline-operator-errors.ts @@ -7,9 +7,8 @@ export const UnparenthesizedPipeBodyDescriptions = new Set([ "YieldExpression", ] as const); -type GetSetMemberType> = T extends Set - ? M - : unknown; +type GetSetMemberType> = + T extends Set ? M : unknown; type UnparenthesizedPipeBodyTypes = GetSetMemberType< typeof UnparenthesizedPipeBodyDescriptions diff --git ORI/babel/packages/babel-traverse/src/path/family.ts ALT/babel/packages/babel-traverse/src/path/family.ts index 0c6f2ab6..be6f6b2f 100644 --- ORI/babel/packages/babel-traverse/src/path/family.ts +++ ALT/babel/packages/babel-traverse/src/path/family.ts @@ -335,9 +335,10 @@ type MaybeToIndex = T extends `${bigint}` ? number : T; type Pattern = `${Obj}.${Prop}`; // split "body.body.1" to ["body", "body", 1] -type Split

= P extends Pattern - ? [MaybeToIndex, ...Split] - : [MaybeToIndex

]; +type Split

= + P extends Pattern + ? [MaybeToIndex, ...Split] + : [MaybeToIndex

]; // get all K with Node[K] is t.Node | t.Node[] type NodeKeyOf = keyof Pick< @@ -361,11 +362,12 @@ type Trav< : never : never; -type ToNodePath = T extends Array - ? Array> - : T extends t.Node | null | undefined - ? NodePath - : never; +type ToNodePath = + T extends Array + ? Array> + : T extends t.Node | null | undefined + ? NodePath + : never; function get( this: NodePath, diff --git ORI/excalidraw/src/tests/binding.test.tsx ALT/excalidraw/src/tests/binding.test.tsx index 07af365..b23a549 100644 --- ORI/excalidraw/src/tests/binding.test.tsx +++ ALT/excalidraw/src/tests/binding.test.tsx @@ -36,8 +36,11 @@ describe("element binding", () => { expect(arrow.startBinding?.elementId).toBe(rectLeft.id); expect(arrow.endBinding?.elementId).toBe(rectRight.id); - const rotation = getTransformHandles(arrow, h.state.zoom, "mouse") - .rotation!; + const rotation = getTransformHandles( + arrow, + h.state.zoom, + "mouse", + ).rotation!; const rotationHandleX = rotation[0] + rotation[2] / 2; const rotationHandleY = rotation[1] + rotation[3] / 2; mouse.down(rotationHandleX, rotationHandleY); diff --git ORI/excalidraw/src/utility-types.ts ALT/excalidraw/src/utility-types.ts index b84eb19..e24f11c 100644 --- ORI/excalidraw/src/utility-types.ts +++ ALT/excalidraw/src/utility-types.ts @@ -44,6 +44,5 @@ export type ForwardRef = Parameters< CallableType> >[1]; -export type ExtractSetType> = T extends Set - ? U - : never; +export type ExtractSetType> = + T extends Set ? U : never; diff --git ORI/prettier/src/index.d.ts ALT/prettier/src/index.d.ts index 628825d..255d2e3 100644 --- ORI/prettier/src/index.d.ts +++ ALT/prettier/src/index.d.ts @@ -39,9 +39,8 @@ type ArrayProperties = { // A union of the properties of the given array T that can be used to index it. // If the array is a tuple, then that's going to be the explicit indices of the // array, otherwise it's going to just be number. -type IndexProperties = IsTuple extends true - ? Exclude["length"], T["length"]> - : number; +type IndexProperties = + IsTuple extends true ? Exclude["length"], T["length"]> : number; // Effectively performing T[P], except that it's telling TypeScript that it's // safe to do this for tuples, arrays, or objects. diff --git ORI/prettier/src/utils/infer-parser.js ALT/prettier/src/utils/infer-parser.js index 2002360..090ca4a 100644 --- ORI/prettier/src/utils/infer-parser.js +++ ALT/prettier/src/utils/infer-parser.js @@ -44,8 +44,8 @@ function getLanguageByInterpreter(languages, file) { return; } - return languages.find( - (language) => language.interpreters?.includes(interpreter), + return languages.find((language) => + language.interpreters?.includes(interpreter), ); } diff --git ORI/react-admin/packages/ra-data-localstorage/src/index.ts ALT/react-admin/packages/ra-data-localstorage/src/index.ts index d2f9225..1a91949 100644 --- ORI/react-admin/packages/ra-data-localstorage/src/index.ts +++ ALT/react-admin/packages/ra-data-localstorage/src/index.ts @@ -151,8 +151,8 @@ export default (params?: LocalStorageDataProviderParams): DataProvider => { }, deleteMany: (resource, params) => { updateLocalStorage(() => { - const indexes = params.ids.map( - id => data[resource]?.findIndex(record => record.id == id) + const indexes = params.ids.map(id => + data[resource]?.findIndex(record => record.id == id) ); pullAt(data[resource], indexes); }); diff --git ORI/typescript-eslint/packages/eslint-plugin/docs/rules/ban-types.md ALT/typescript-eslint/packages/eslint-plugin/docs/rules/ban-types.md index 7109e24..fdaf9a8 100644 --- ORI/typescript-eslint/packages/eslint-plugin/docs/rules/ban-types.md +++ ALT/typescript-eslint/packages/eslint-plugin/docs/rules/ban-types.md @@ -170,14 +170,14 @@ Example configuration: // add a custom message, AND tell the plugin how to fix it "OldAPI": { "message": "Use NewAPI instead", - "fixWith": "NewAPI" + "fixWith": "NewAPI", }, // un-ban a type that's banned by default - "{}": false + "{}": false, }, - "extendDefaults": true - } - ] + "extendDefaults": true, + }, + ], } ``` diff --git ORI/typescript-eslint/packages/eslint-plugin/docs/rules/explicit-function-return-type.md ALT/typescript-eslint/packages/eslint-plugin/docs/rules/explicit-function-return-type.md index 01e998f..a170296 100644 --- ORI/typescript-eslint/packages/eslint-plugin/docs/rules/explicit-function-return-type.md +++ ALT/typescript-eslint/packages/eslint-plugin/docs/rules/explicit-function-return-type.md @@ -76,17 +76,17 @@ If you are working on a codebase within which you lint non-TypeScript code (i.e. { "rules": { // disable the rule for all files - "@typescript-eslint/explicit-function-return-type": "off" + "@typescript-eslint/explicit-function-return-type": "off", }, "overrides": [ { // enable the rule specifically for TypeScript files "files": ["*.ts", "*.mts", "*.cts", "*.tsx"], "rules": { - "@typescript-eslint/explicit-function-return-type": "error" - } - } - ] + "@typescript-eslint/explicit-function-return-type": "error", + }, + }, + ], } ``` diff --git ORI/typescript-eslint/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md ALT/typescript-eslint/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md index 43cd4fe..a7c5e63 100644 --- ORI/typescript-eslint/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md +++ ALT/typescript-eslint/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md @@ -30,17 +30,17 @@ If you are working on a codebase within which you lint non-TypeScript code (i.e. { "rules": { // disable the rule for all files - "@typescript-eslint/explicit-member-accessibility": "off" + "@typescript-eslint/explicit-member-accessibility": "off", }, "overrides": [ { // enable the rule specifically for TypeScript files "files": ["*.ts", "*.mts", "*.cts", "*.tsx"], "rules": { - "@typescript-eslint/explicit-member-accessibility": "error" - } - } - ] + "@typescript-eslint/explicit-member-accessibility": "error", + }, + }, + ], } ``` diff --git ORI/typescript-eslint/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md ALT/typescript-eslint/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md index d10515e..ff0007b 100644 --- ORI/typescript-eslint/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md +++ ALT/typescript-eslint/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md @@ -80,17 +80,17 @@ If you are working on a codebase within which you lint non-TypeScript code (i.e. { "rules": { // disable the rule for all files - "@typescript-eslint/explicit-module-boundary-types": "off" + "@typescript-eslint/explicit-module-boundary-types": "off", }, "overrides": [ { // enable the rule specifically for TypeScript files "files": ["*.ts", "*.mts", "*.cts", "*.tsx"], "rules": { - "@typescript-eslint/explicit-module-boundary-types": "error" - } - } - ] + "@typescript-eslint/explicit-module-boundary-types": "error", + }, + }, + ], } ``` diff --git ORI/typescript-eslint/packages/eslint-plugin/docs/rules/lines-around-comment.md ALT/typescript-eslint/packages/eslint-plugin/docs/rules/lines-around-comment.md index 68d912e..2a56c08 100644 --- ORI/typescript-eslint/packages/eslint-plugin/docs/rules/lines-around-comment.md +++ ALT/typescript-eslint/packages/eslint-plugin/docs/rules/lines-around-comment.md @@ -19,7 +19,7 @@ See the [ESLint documentation](https://eslint.org/docs/rules/lines-around-commen { // note you must disable the base rule as it can report incorrect errors "lines-around-comment": "off", - "@typescript-eslint/lines-around-comment": ["error"] + "@typescript-eslint/lines-around-comment": ["error"], } ``` diff --git ORI/typescript-eslint/packages/eslint-plugin/docs/rules/member-ordering.md ALT/typescript-eslint/packages/eslint-plugin/docs/rules/member-ordering.md index b4d1e21..49a170b 100644 --- ORI/typescript-eslint/packages/eslint-plugin/docs/rules/member-ordering.md +++ ALT/typescript-eslint/packages/eslint-plugin/docs/rules/member-ordering.md @@ -217,8 +217,8 @@ The default configuration looks as follows: "decorated-method", - "method" - ] + "method", + ], } ``` @@ -246,9 +246,9 @@ It also ignores accessibility and scope. "rules": { "@typescript-eslint/member-ordering": [ "error", - { "default": ["signature", "method", "constructor", "field"] } - ] - } + { "default": ["signature", "method", "constructor", "field"] }, + ], + }, } ``` @@ -381,9 +381,9 @@ It doesn't apply to interfaces or type literals as accessibility and scope are n "rules": { "@typescript-eslint/member-ordering": [ "error", - { "default": ["public-instance-method", "public-static-field"] } - ] - } + { "default": ["public-instance-method", "public-static-field"] }, + ], + }, } ``` @@ -475,9 +475,9 @@ It doesn't apply to interfaces or type literals as accessibility and scope are n "rules": { "@typescript-eslint/member-ordering": [ "error", - { "default": ["public-static-field", "static-field", "instance-field"] } - ] - } + { "default": ["public-static-field", "static-field", "instance-field"] }, + ], + }, } ``` @@ -564,9 +564,9 @@ Default settings will be used for class declarations and all other syntax constr "rules": { "@typescript-eslint/member-ordering": [ "error", - { "classes": ["method", "constructor", "field"] } - ] - } + { "classes": ["method", "constructor", "field"] }, + ], + }, } ``` @@ -614,9 +614,9 @@ Default settings will be used for class declarations and all other syntax constr "rules": { "@typescript-eslint/member-ordering": [ "error", - { "classExpressions": ["method", "constructor", "field"] } - ] - } + { "classExpressions": ["method", "constructor", "field"] }, + ], + }, } ``` @@ -668,9 +668,9 @@ These member types are the only ones allowed for `interfaces`. "rules": { "@typescript-eslint/member-ordering": [ "error", - { "interfaces": ["signature", "method", "constructor", "field"] } - ] - } + { "interfaces": ["signature", "method", "constructor", "field"] }, + ], + }, } ``` @@ -720,9 +720,9 @@ These member types are the only ones allowed for `typeLiterals`. "rules": { "@typescript-eslint/member-ordering": [ "error", - { "typeLiterals": ["signature", "method", "constructor", "field"] } - ] - } + { "typeLiterals": ["signature", "method", "constructor", "field"] }, + ], + }, } ``` @@ -774,11 +774,11 @@ You can copy and paste the default order from [Default Configuration](#default-c "memberTypes": [ /* */ ], - "order": "alphabetically" - } - } - ] - } + "order": "alphabetically", + }, + }, + ], + }, } ``` @@ -828,11 +828,11 @@ You can copy and paste the default order from [Default Configuration](#default-c "memberTypes": [ /* */ ], - "order": "alphabetically-case-insensitive" - } - } - ] - } + "order": "alphabetically-case-insensitive", + }, + }, + ], + }, } ``` @@ -877,9 +877,9 @@ It ignores any member group types completely by specifying `"never"` for `member "rules": { "@typescript-eslint/member-ordering": [ "error", - { "default": { "memberTypes": "never", "order": "alphabetically" } } - ] - } + { "default": { "memberTypes": "never", "order": "alphabetically" } }, + ], + }, } ``` @@ -928,11 +928,11 @@ This config places all optional members before all required members: { "default": { "optionalityOrder": "optional-first", - "order": "alphabetically" - } - } - ] - } + "order": "alphabetically", + }, + }, + ], + }, } ``` @@ -971,11 +971,11 @@ This config places all required members before all optional members: { "default": { "optionalityOrder": "required-first", - "order": "alphabetically" - } - } - ] - } + "order": "alphabetically", + }, + }, + ], + }, } ``` @@ -1193,7 +1193,7 @@ It is also possible to group member types by their accessibility (`static`, `ins // Methods "public-method", // = ["public-static-method", "public-instance-method"] "protected-method", // = ["protected-static-method", "protected-instance-method"] - "private-method" // = ["private-static-method", "private-instance-method"] + "private-method", // = ["private-static-method", "private-instance-method"] ] ``` @@ -1239,7 +1239,7 @@ their accessibility. "protected-decorated-method", "private-decorated-method", - "decorated-method" // = ["public-decorated-method", "protected-decorated-method", "private-decorated-method"] + "decorated-method", // = ["public-decorated-method", "protected-decorated-method", "private-decorated-method"] ] ``` @@ -1276,7 +1276,7 @@ Another option is to group the member types by their scope (`public`, `protected // Methods "static-method", // = ["public-static-method", "protected-static-method", "private-static-method"] "instance-method", // = ["public-instance-method", "protected-instance-method", "private-instance-method"] - "abstract-method" // = ["public-abstract-method", "protected-abstract-method"] + "abstract-method", // = ["public-abstract-method", "protected-abstract-method"] ] ``` @@ -1308,7 +1308,7 @@ The third grouping option is to ignore both scope and accessibility. // "public-abstract-set", "protected-abstract-set"] // Methods - "method" // = ["public-static-method", "protected-static-method", "private-static-method", "public-instance-method", "protected-instance-method", "private-instance-method", + "method", // = ["public-static-method", "protected-static-method", "private-static-method", "public-instance-method", "protected-instance-method", "private-instance-method", // "public-abstract-method", "protected-abstract-method"] ] ``` @@ -1325,7 +1325,7 @@ It is possible to group fields by their `readonly` modifiers. // Fields "readonly-field", // = ["public-static-readonly-field", "protected-static-readonly-field", "private-static-readonly-field", "public-instance-readonly-field", "protected-instance-readonly-field", "private-instance-readonly-field", "public-abstract-readonly-field", "protected-abstract-readonly-field"] - "field" // = ["public-static-field", "protected-static-field", "private-static-field", "public-instance-field", "protected-instance-field", "private-instance-field", "public-abstract-field", "protected-abstract-field"] + "field", // = ["public-static-field", "protected-static-field", "private-static-field", "public-instance-field", "protected-instance-field", "private-instance-field", "public-abstract-field", "protected-abstract-field"] ] ``` @@ -1351,7 +1351,7 @@ It is also possible to group different member types at the same rank. ["get", "set"], // Methods - "method" + "method", ] ``` diff --git ORI/typescript-eslint/packages/eslint-plugin/docs/rules/naming-convention.md ALT/typescript-eslint/packages/eslint-plugin/docs/rules/naming-convention.md index 53c381c..ad34775 100644 --- ORI/typescript-eslint/packages/eslint-plugin/docs/rules/naming-convention.md +++ ALT/typescript-eslint/packages/eslint-plugin/docs/rules/naming-convention.md @@ -594,12 +594,12 @@ If you simply want to allow all property names that require quotes, you can use "objectLiteralMethod", "typeMethod", "accessor", - "enumMember" + "enumMember", ], "format": null, - "modifiers": ["requiresQuotes"] - } - ] + "modifiers": ["requiresQuotes"], + }, + ], } ``` @@ -615,10 +615,10 @@ If you have a small and known list of exceptions, you can use the `filter` optio "filter": { // you can expand this regex to add more allowed names "regex": "^(Property-Name-One|Property-Name-Two)$", - "match": false - } - } - ] + "match": false, + }, + }, + ], } ``` @@ -634,10 +634,10 @@ You can use the `filter` option to ignore names with specific characters: "filter": { // you can expand this regex as you find more cases that require quoting that you want to allow "regex": "[- ]", - "match": false - } - } - ] + "match": false, + }, + }, + ], } ``` @@ -658,9 +658,9 @@ You can use the `destructured` modifier to match these names, and explicitly set { "selector": "variable", "modifiers": ["destructured"], - "format": null - } - ] + "format": null, + }, + ], } ``` diff --git ORI/typescript-eslint/packages/eslint-plugin/docs/rules/padding-line-between-statements.md ALT/typescript-eslint/packages/eslint-plugin/docs/rules/padding-line-between-statements.md index 5387cac..12740f7 100644 --- ORI/typescript-eslint/packages/eslint-plugin/docs/rules/padding-line-between-statements.md +++ ALT/typescript-eslint/packages/eslint-plugin/docs/rules/padding-line-between-statements.md @@ -26,9 +26,9 @@ For example, to add blank lines before interfaces and type definitions: { "blankLine": "always", "prev": "*", - "next": ["interface", "type"] - } - ] + "next": ["interface", "type"], + }, + ], } ``` diff --git ORI/typescript-eslint/packages/eslint-plugin/docs/rules/prefer-readonly.md ALT/typescript-eslint/packages/eslint-plugin/docs/rules/prefer-readonly.md index 774b55b..e22caa5 100644 --- ORI/typescript-eslint/packages/eslint-plugin/docs/rules/prefer-readonly.md +++ ALT/typescript-eslint/packages/eslint-plugin/docs/rules/prefer-readonly.md @@ -60,7 +60,10 @@ You may pass `"onlyInlineLambdas": true` as a rule option within an object to re ```jsonc { - "@typescript-eslint/prefer-readonly": ["error", { "onlyInlineLambdas": true }] + "@typescript-eslint/prefer-readonly": [ + "error", + { "onlyInlineLambdas": true }, + ], } ``` diff --git ORI/typescript-eslint/packages/utils/src/eslint-utils/InferTypesFromRule.ts ALT/typescript-eslint/packages/utils/src/eslint-utils/InferTypesFromRule.ts index 4aca4b0..215a869 100644 --- ORI/typescript-eslint/packages/utils/src/eslint-utils/InferTypesFromRule.ts +++ ALT/typescript-eslint/packages/utils/src/eslint-utils/InferTypesFromRule.ts @@ -3,25 +3,21 @@ import type { RuleCreateFunction, RuleModule } from '../ts-eslint'; /** * Uses type inference to fetch the TOptions type from the given RuleModule */ -type InferOptionsTypeFromRule = T extends RuleModule< - infer _TMessageIds, - infer TOptions -> - ? TOptions - : T extends RuleCreateFunction +type InferOptionsTypeFromRule = + T extends RuleModule ? TOptions - : unknown; + : T extends RuleCreateFunction + ? TOptions + : unknown; /** * Uses type inference to fetch the TMessageIds type from the given RuleModule */ -type InferMessageIdsTypeFromRule = T extends RuleModule< - infer TMessageIds, - infer _TOptions -> - ? TMessageIds - : T extends RuleCreateFunction +type InferMessageIdsTypeFromRule = + T extends RuleModule ? TMessageIds - : unknown; + : T extends RuleCreateFunction + ? TMessageIds + : unknown; export { InferOptionsTypeFromRule, InferMessageIdsTypeFromRule }; ````