From ba17b198bc9cbf70c1593678ad9231ddf73496d7 Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Sat, 13 Apr 2024 00:28:39 +0900 Subject: [PATCH 1/3] add test for compatibility Issue: #40 --- bun.lockb | Bin 52572 -> 53325 bytes package.json | 1 + tests/format/__snapshots__/index.test.ts.snap | 3 ++ tests/format/index.test.ts | 30 ++++++++++++++++++ tests/format/testdata/interface.ts | 1 + 5 files changed, 35 insertions(+) diff --git a/bun.lockb b/bun.lockb index 834615cccc39dcbdf84bab7c8ea4bba6013bd819..d8611b696dc2c0da976d2029d3dafe7b6ea8e033 100755 GIT binary patch delta 7129 zcmeHMeNLONmf#|v5n@LM2)pCwkuWB*u=QefHVs+&gEkbOfE>9n@;KeKz*fA9`jLhMfMZ`_=bH?D^`Yk5B#b)TG|^ zxBqzMFU{|E&HniXNlTmC9!qY#vPl>8XQCwe+L28LM+ix}2fPk)Jh%Zo1e|7)q@myt z@JR3tw6lVjqdpw$sjKv^sF$Q7vo6mx_%{aU8{8BkNioIfQ0ZB<0)3^YP{0c28(aof zAeVbQ)fwJ8$$^g1kki02xG7AR{b25Q85{*pL_Hh&B^3(G0)Mbx>aEMDs9aelStIn; zAE6vspSNPg%36;kU4qP7xlw6loir6HSbooFx753$Jfopn3X9bH-JxF!i|vjf9Yd=a zw0<52ur0OTs@l?}lB5lZxjjh2G{&0)^LfnWo;9m@##hmW<)xLS_4S@|=^(W53_W!X z^INcjhmeyrp)QTd=Y{3|dBw;GPRU`)`D`u=Wy7_LPGy&{|eq?6)EEJryHROhK$<*AjV(W!d-HKmo6 z-nx3}n*gHJ;N-?d2x8V2I!f45D!>bs~^?|@B_tt8WHGH&Q z{s{E3OOL}U8053T8s;bN)A!LiFi-Co80#44%SQ%N_Q4HW#q}}ZzPE!P36A;e>SqT& z8QrDiEi#?>;Ll;dr+9g;c!RvMDw3#2R?U^zd{e1Pc8gxJg{xvBdGY)a_2Ai0emo1w z7NLp`^5VIOdb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<74mO^QW_|k(m3YoBptAs5ngVn>ingH|t*e@pNfOmo2$F57$ANjrG#BbF_W4 zE+oCZ*{5RDl7hA@6<^cxEhew0+YhJ1_g{GS+9!HC#&R;kMf>S=Z^GyuKP|bJsI00i z-%XKQ^*H-U_3MasdiV<+Q`Jb-k6a(P^K)agqcIwo)HO;&j z?(?xUVOts;rENYuQq9_>UzFmg}&Xz2iyxoUK%5~cd5rli&b?<*T zy2yB(ryV}WPwi>ij#Rwn)b7yZ?049{-yc8pK}`BI`0h71=1vDXzr%yszue&yq10xl z?YZ(952Y?@NfkSt!d#V)w(iuu_H%5=u=&rHbopkWL-2ix7;5%PV{x8CcKL8RGf|ss z!-FZ>C+Wy8-D^GIR-XPcZQtyJm;PZpl&T%0>xjd@$1vB5xw&3@wv{t0LjV8( diff --git a/package.json b/package.json index 36cf2ce..593bcb8 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "check": "bun test && tsc && eslint ." }, "devDependencies": { + "@types/eslint": "^8.56.9", "@typescript-eslint/eslint-plugin": "^7.1.0", "@typescript-eslint/parser": "^7.1.0", "bun-types": "latest", diff --git a/tests/format/__snapshots__/index.test.ts.snap b/tests/format/__snapshots__/index.test.ts.snap index 2262aa6..4053e33 100644 --- a/tests/format/__snapshots__/index.test.ts.snap +++ b/tests/format/__snapshots__/index.test.ts.snap @@ -194,6 +194,7 @@ interface F { set h(_: 0); a(): 0; [\`g\`](): 0; + j: () => 0; } interface G { @@ -438,6 +439,7 @@ interface F { get i(): 0; set h(_: 0); a(): 0; + j: () => 0; [\`g\`](): 0; } @@ -684,6 +686,7 @@ interface F { set h(_: 0); a(): 0; [\`g\`](): 0; + j: () => 0; } interface G { diff --git a/tests/format/index.test.ts b/tests/format/index.test.ts index cbe0fae..320e980 100644 --- a/tests/format/index.test.ts +++ b/tests/format/index.test.ts @@ -2,6 +2,7 @@ import { describe, test, expect } from "bun:test"; import { readdir, readFile } from "node:fs/promises"; import { join } from "node:path"; import { format } from "prettier"; +import { ESLint } from "eslint"; const plugins = ["./index.ts"]; @@ -72,5 +73,34 @@ describe("format", () => { }); }); }); + + describe("compatible with eslint-typescript", () => { + const eslint = new ESLint({ + overrideConfig: { + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], + extends: [], + rules: { + "@typescript-eslint/member-ordering": "error", + }, + }, + useEslintrc: false, + }); + + test.each(filenames)("%s", async (name) => { + const path = join(dir, name); + const code = await readFile(path, "utf-8"); + const result = await format(code, { + ...opts, + filepath: path, + plugins, + }); + + const lintResults = await eslint.lintText(result); + + expect(lintResults).toHaveLength(1); + expect(lintResults[0].messages).toBeEmpty(); + }); + }); }); }); diff --git a/tests/format/testdata/interface.ts b/tests/format/testdata/interface.ts index ede1b94..14faffe 100644 --- a/tests/format/testdata/interface.ts +++ b/tests/format/testdata/interface.ts @@ -61,6 +61,7 @@ interface F { [`g`](): 0; set h(_: 0); get i(): 0; + j: () => 0; } interface G { From d8a21ea048ba55b43a77a0093aae8655a4803802 Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Sun, 14 Apr 2024 10:15:46 +0900 Subject: [PATCH 2/3] add test case --- tests/format/__snapshots__/index.test.ts.snap | 81 +++++++++++++++++++ .../testdata/issue-40-function-member.ts | 23 ++++++ 2 files changed, 104 insertions(+) create mode 100644 tests/format/testdata/issue-40-function-member.ts diff --git a/tests/format/__snapshots__/index.test.ts.snap b/tests/format/__snapshots__/index.test.ts.snap index 4053e33..509f551 100644 --- a/tests/format/__snapshots__/index.test.ts.snap +++ b/tests/format/__snapshots__/index.test.ts.snap @@ -119,6 +119,33 @@ function deco(a: unknown, b: unknown): void {} " `; +exports[`format {} issue-40-function-member.ts 1`] = ` +"type Link = { + text: string; + foo: () => void; + onClick: () => void; +}; + +type Literal = { + value: number; + method(): void; + func: () => void; +}; + +interface Interface { + value: number; + method(): void; + func: () => void; +} + +class Class { + value = 0; + method(): void {} + func = () => 0; +} +" +`; + exports[`format {} issue-34-literal-keys.js 1`] = ` "class A { [fruit] = 1; @@ -365,6 +392,33 @@ function deco(a: unknown, b: unknown): void {} " `; +exports[`format {"sortMembersAlphabetically":true} issue-40-function-member.ts 1`] = ` +"type Link = { + text: string; + foo: () => void; + onClick: () => void; +}; + +type Literal = { + value: number; + func: () => void; + method(): void; +}; + +interface Interface { + value: number; + func: () => void; + method(): void; +} + +class Class { + value = 0; + func = () => 0; + method(): void {} +} +" +`; + exports[`format {"sortMembersAlphabetically":true} issue-34-literal-keys.js 1`] = ` "class A { ["apple"] = 1; @@ -611,6 +665,33 @@ function deco(a: unknown, b: unknown): void {} " `; +exports[`format {"sortMembersAlphabetically":false} issue-40-function-member.ts 1`] = ` +"type Link = { + text: string; + foo: () => void; + onClick: () => void; +}; + +type Literal = { + value: number; + method(): void; + func: () => void; +}; + +interface Interface { + value: number; + method(): void; + func: () => void; +} + +class Class { + value = 0; + method(): void {} + func = () => 0; +} +" +`; + exports[`format {"sortMembersAlphabetically":false} issue-34-literal-keys.js 1`] = ` "class A { [fruit] = 1; diff --git a/tests/format/testdata/issue-40-function-member.ts b/tests/format/testdata/issue-40-function-member.ts new file mode 100644 index 0000000..f796ece --- /dev/null +++ b/tests/format/testdata/issue-40-function-member.ts @@ -0,0 +1,23 @@ +type Link = { + foo: () => void; + text: string; + onClick: () => void; +}; + +type Literal = { + method(): void; + func: () => void; + value: number; +} + +interface Interface { + method(): void; + func: () => void; + value: number; +} + +class Class { + method(): void {} + func = () => 0; + value = 0; +} \ No newline at end of file From 1cb9324046160cd7467841b28c454fc2ed86162b Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Sun, 14 Apr 2024 10:37:49 +0900 Subject: [PATCH 3/3] fix #40 --- lib/comparator/index.ts | 51 +++++------------- tests/format/__snapshots__/index.test.ts.snap | 52 +++++++++---------- 2 files changed, 40 insertions(+), 63 deletions(-) diff --git a/lib/comparator/index.ts b/lib/comparator/index.ts index 0453b6d..7691d6a 100644 --- a/lib/comparator/index.ts +++ b/lib/comparator/index.ts @@ -1,4 +1,3 @@ -import { AST_NODE_TYPES } from "@typescript-eslint/types"; import bt from "@babel/types"; import { C, Comparator } from "./comparator"; import { select } from "./select"; @@ -19,34 +18,24 @@ export function comparator(options: Partial): Comparator { const alpha = options.sortMembersAlphabetically === true; return C.chain( // signature - C.capture( - node(MemberTypes.TSIndexSignature), - C.by(functionSignature, C.defer), - ), + C.capture(node(MemberTypes.TSIndexSignature), C.nop), // field C.capture( - select - .or( - select.and( - node(MemberTypes.TSPropertySignature), - select.not(functionSignature), - ), - ) - .or( - select.and( - select - .or(node(MemberTypes.PropertyDefinition)) - .or(node(MemberTypes.TSAbstractPropertyDefinition)) - .or( - select.and( - bt.isNode, - select.or(bt.isClassProperty).or(bt.isClassPrivateProperty), - ), + select.or(node(MemberTypes.TSPropertySignature)).or( + select.and( + select + .or(node(MemberTypes.PropertyDefinition)) + .or(node(MemberTypes.TSAbstractPropertyDefinition)) + .or( + select.and( + bt.isNode, + select.or(bt.isClassProperty).or(bt.isClassPrivateProperty), ), - ($) => !($.value && functionExpressions.includes($.value.type)), - ), + ), + ($) => !($.value && functionExpressions.includes($.value.type)), ), + ), C.chain( classMember(), C.by(decorated, C.prefer), @@ -103,9 +92,7 @@ export function comparator(options: Partial): Comparator { $.value != null && functionExpressions.includes($.value.type), ), ) - .or( - select.and(node(MemberTypes.TSPropertySignature), functionSignature), - ), + .or(node(MemberTypes.TSPropertySignature)), C.chain( methodKind(), classMember(), @@ -118,16 +105,6 @@ export function comparator(options: Partial): Comparator { ); } -function functionSignature( - node: MemberNode< - AST_NODE_TYPES.TSPropertySignature | AST_NODE_TYPES.TSIndexSignature - >, -): boolean { - return ( - node.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES.TSFunctionType - ); -} - function node(key: K) { return function (node: MemberNode): node is MemberNode { return node.type === key; diff --git a/tests/format/__snapshots__/index.test.ts.snap b/tests/format/__snapshots__/index.test.ts.snap index 509f551..3322dc2 100644 --- a/tests/format/__snapshots__/index.test.ts.snap +++ b/tests/format/__snapshots__/index.test.ts.snap @@ -27,11 +27,11 @@ type Y = { }; type Z = { + edge: () => void; dog: unknown; + "change-value": () => void; "big-value": number; "another-one": 0; - edge: () => void; - "change-value": () => void; }; interface A { @@ -121,21 +121,21 @@ function deco(a: unknown, b: unknown): void {} exports[`format {} issue-40-function-member.ts 1`] = ` "type Link = { - text: string; foo: () => void; + text: string; onClick: () => void; }; type Literal = { + func: () => void; value: number; method(): void; - func: () => void; }; interface Interface { + func: () => void; value: number; method(): void; - func: () => void; } class Class { @@ -214,6 +214,7 @@ interface F { b: 0; [\`e\`]: 0; [\`f\`]: 0; + j: () => 0; new (): F; new (a: 0): F; new (a: 0, b: 0): F; @@ -221,12 +222,11 @@ interface F { set h(_: 0); a(): 0; [\`g\`](): 0; - j: () => 0; } interface G { - [d: symbol]: 0; [c: number]: () => 0; + [d: symbol]: 0; a: 0; } " @@ -234,15 +234,15 @@ interface G { exports[`format {} type-alias.ts 1`] = ` "type A = { - [t: string]: unknown; [u: number]: () => number; + [t: string]: unknown; y: number; + x: () => () => number; [\`s\`]: number; r?: number; new (a: 0, b: 1): A; get w(): number; z(): number; - x: () => () => number; v?(): number; }; " @@ -302,8 +302,8 @@ type Y = { type Z = { "another-one": 0; "big-value": number; - dog: unknown; "change-value": () => void; + dog: unknown; edge: () => void; }; @@ -394,20 +394,20 @@ function deco(a: unknown, b: unknown): void {} exports[`format {"sortMembersAlphabetically":true} issue-40-function-member.ts 1`] = ` "type Link = { - text: string; foo: () => void; onClick: () => void; + text: string; }; type Literal = { - value: number; func: () => void; + value: number; method(): void; }; interface Interface { - value: number; func: () => void; + value: number; method(): void; } @@ -485,6 +485,7 @@ interface F { [c: number]: 0; [d: symbol]: 0; b: 0; + j: () => 0; [\`e\`]: 0; [\`f\`]: 0; new (): F; @@ -493,13 +494,12 @@ interface F { get i(): 0; set h(_: 0); a(): 0; - j: () => 0; [\`g\`](): 0; } interface G { - [d: symbol]: 0; [c: number]: () => 0; + [d: symbol]: 0; a: 0; } " @@ -507,15 +507,15 @@ interface G { exports[`format {"sortMembersAlphabetically":true} type-alias.ts 1`] = ` "type A = { - [t: string]: unknown; [u: number]: () => number; + [t: string]: unknown; r?: number; + x: () => () => number; y: number; [\`s\`]: number; new (a: 0, b: 1): A; get w(): number; v?(): number; - x: () => () => number; z(): number; }; " @@ -573,11 +573,11 @@ type Y = { }; type Z = { + edge: () => void; dog: unknown; + "change-value": () => void; "big-value": number; "another-one": 0; - edge: () => void; - "change-value": () => void; }; interface A { @@ -667,21 +667,21 @@ function deco(a: unknown, b: unknown): void {} exports[`format {"sortMembersAlphabetically":false} issue-40-function-member.ts 1`] = ` "type Link = { - text: string; foo: () => void; + text: string; onClick: () => void; }; type Literal = { + func: () => void; value: number; method(): void; - func: () => void; }; interface Interface { + func: () => void; value: number; method(): void; - func: () => void; } class Class { @@ -760,6 +760,7 @@ interface F { b: 0; [\`e\`]: 0; [\`f\`]: 0; + j: () => 0; new (): F; new (a: 0): F; new (a: 0, b: 0): F; @@ -767,12 +768,11 @@ interface F { set h(_: 0); a(): 0; [\`g\`](): 0; - j: () => 0; } interface G { - [d: symbol]: 0; [c: number]: () => 0; + [d: symbol]: 0; a: 0; } " @@ -780,15 +780,15 @@ interface G { exports[`format {"sortMembersAlphabetically":false} type-alias.ts 1`] = ` "type A = { - [t: string]: unknown; [u: number]: () => number; + [t: string]: unknown; y: number; + x: () => () => number; [\`s\`]: number; r?: number; new (a: 0, b: 1): A; get w(): number; z(): number; - x: () => () => number; v?(): number; }; "