Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1c3dc83

Browse files
authored
chore: remove dangling eslint-ignore comments (#14334)
1 parentfa59b30 commit1c3dc83

File tree

20 files changed

+1220
-1256
lines changed

20 files changed

+1220
-1256
lines changed

‎scripts/apitypings/main.go‎

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ func (g *Generator) buildStruct(obj types.Object, st *types.Struct) (string, err
646646
// Just append these as fields. We should fix this later.
647647
state.Fields=append(state.Fields,tsType.AboveTypeLine)
648648
}
649-
state.Fields=append(state.Fields,fmt.Sprintf("%sreadonly %s%s: %s",indent,jsonName,optional,valueType))
649+
state.Fields=append(state.Fields,fmt.Sprintf("%sreadonly %s%s: %s;",indent,jsonName,optional,valueType))
650650
}
651651

652652
// This is implemented to ensure the correct order of generics on the
@@ -759,12 +759,8 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
759759
// }
760760
// }
761761
returnTypescriptType{
762-
ValueType:"any",
763-
AboveTypeLine:fmt.Sprintf("%s\n%s",
764-
indentedComment("Embedded anonymous struct, please fix by naming it"),
765-
// Linter needs to be disabled here, or else it will complain about the "any" type.
766-
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- Anonymously embedded struct"),
767-
),
762+
AboveTypeLine:indentedComment("Embedded anonymous struct, please fix by naming it"),
763+
ValueType:"unknown",
768764
},nil
769765
case*types.Map:
770766
// map[string][string] -> Record<string, string>
@@ -815,16 +811,11 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
815811
}
816812
genValue:=""
817813

818-
// Always wrap in parentheses for proper scoped types.
819-
// Running prettier on this output will remove redundant parenthesis,
820-
// so this makes our decision-making easier.
821-
// The example that breaks without this is:
822-
//readonly readonly string[][]
823814
ifunderlying.GenericValue!="" {
824-
genValue="(readonly"+underlying.GenericValue+"[])"
815+
genValue="Readonly<Array<"+underlying.GenericValue+">>"
825816
}
826817
returnTypescriptType{
827-
ValueType:"(readonly"+underlying.ValueType+"[])",
818+
ValueType:"Readonly<Array<"+underlying.ValueType+">>",
828819
GenericValue:genValue,
829820
AboveTypeLine:underlying.AboveTypeLine,
830821
GenericTypes:underlying.GenericTypes,
@@ -858,6 +849,8 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
858849
returnTypescriptType{ValueType:"boolean"},nil
859850
case"github.com/coder/serpent.Duration":
860851
returnTypescriptType{ValueType:"number"},nil
852+
case"net/netip.Addr":
853+
returnTypescriptType{ValueType:"string"},nil
861854
case"net/url.URL":
862855
returnTypescriptType{ValueType:"string"},nil
863856
case"time.Time":
@@ -889,6 +882,14 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
889882
returnTypescriptType{ValueType:"HealthSection"},nil
890883
case"github.com/coder/coder/v2/codersdk.ProvisionerDaemon":
891884
returnTypescriptType{ValueType:"ProvisionerDaemon"},nil
885+
886+
// Some very unfortunate `any` types that leaked into the frontend.
887+
case"tailscale.com/tailcfg.DERPNode",
888+
"tailscale.com/derp.ServerInfoMessage",
889+
"tailscale.com/tailcfg.DERPRegion",
890+
"tailscale.com/net/netcheck.Report",
891+
"github.com/spf13/pflag.Value":
892+
returnTypescriptType{AboveTypeLine:indentedComment("TODO: narrow this type"),ValueType:"any"},nil
892893
}
893894

894895
// Some hard codes are a bit trickier.
@@ -965,15 +966,15 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
965966

966967
// If it's a struct, just use the name of the struct type
967968
if_,ok:=n.Underlying().(*types.Struct);ok {
968-
// External structs cannot be introspected, as we only parse the codersdk package.
969-
// You can handle your type manually in the switch list above, otherwise "any" will be used.
970-
// An easy way to fix this is to pull your external type into `codersdk` package, then it will
971-
// be known by the generator.
972-
returnTypescriptType{ValueType:"any",AboveTypeLine:fmt.Sprintf("%s\n%s",
973-
indentedComment(fmt.Sprintf("Named type %q unknown, using\"any\"",n.String())),
974-
// Linter needs to be disabled here, or else it will complain about the "any" type.
975-
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- External type"),
976-
)},nil
969+
// External structs cannot be introspected, as we only parse the codersdk
970+
//package.You can handle your type manually in the switch list above,
971+
//otherwise `unknown` will be used.An easy way to fix this is to pull
972+
//your external type into codersdk, then it willbe known by the
973+
// generator.
974+
returnTypescriptType{
975+
AboveTypeLine:indentedComment(fmt.Sprintf("external type %q, using\"unknown\"",n.String())),
976+
ValueType:"unknown",
977+
},nil
977978
}
978979

979980
// Defer to the underlying type.
@@ -1002,20 +1003,16 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
10021003
// This field is 'interface{}'. We can't infer any type from 'interface{}'
10031004
// so just use "any" as the type.
10041005
returnTypescriptType{
1005-
ValueType:"any",
1006-
AboveTypeLine:fmt.Sprintf("%s\n%s",
1007-
indentedComment("Empty interface{} type, cannot resolve the type."),
1008-
// Linter needs to be disabled here, or else it will complain about the "any" type.
1009-
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- interface{}"),
1010-
),
1006+
AboveTypeLine:indentedComment("empty interface{} type, falling back to unknown"),
1007+
ValueType:"unknown",
10111008
},nil
10121009
}
10131010

10141011
// Interfaces are difficult to determine the JSON type, so just return
1015-
// an 'any'.
1012+
// an 'unknown'.
10161013
returnTypescriptType{
1017-
ValueType:"any",
1018-
AboveTypeLine:indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- Golang interface, unable to resolve type."),
1014+
AboveTypeLine:indentedComment("interface type, falling back to unknown"),
1015+
ValueType:"unknown",
10191016
Optional:false,
10201017
},nil
10211018
case*types.TypeParam:
@@ -1040,13 +1037,13 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
10401037
// If we don't have the type constraint defined somewhere in the package,
10411038
// then we have to resort to using any.
10421039
returnTypescriptType{
1040+
AboveTypeLine:fmt.Sprintf("// %q is an external type, falling back to unknown",name),
10431041
GenericTypes:map[string]string{
1044-
ty.Obj().Name():"any",
1042+
ty.Obj().Name():"unknown",
10451043
},
1046-
GenericValue:ty.Obj().Name(),
1047-
ValueType:"any",
1048-
AboveTypeLine:fmt.Sprintf("// %q is an external type, so we use any",name),
1049-
Optional:false,
1044+
GenericValue:ty.Obj().Name(),
1045+
ValueType:"unknown",
1046+
Optional:false,
10501047
},nil
10511048
}
10521049
// Include the builtin for this type to reference
@@ -1097,7 +1094,7 @@ func (Generator) isBuiltIn(name string) (bool, string) {
10971094
case"comparable":
10981095
// To be complete, we include "any". Kinda sucks :(
10991096
returntrue,"export type comparable = boolean | number | string | any"
1100-
case"any":
1097+
case"any","unknown":
11011098
// This is supported in typescript, we don't need to write anything
11021099
returntrue,""
11031100
default:

‎scripts/apitypings/main_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestGeneration(t *testing.T) {
4343
output=strings.TrimSpace(output)
4444
if*updateGoldenFiles {
4545
// nolint:gosec
46-
err:=os.WriteFile(golden, []byte(output),0o644)
46+
err:=os.WriteFile(golden, []byte(output+"\n"),0o644)
4747
require.NoError(t,err,"write golden file")
4848
}else {
4949
require.Equal(t,expectedString,output,"matched output")

‎scripts/apitypings/testdata/enums/enums.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// From codersdk/enums.go
2-
exporttypeEnumSliceType=(readonlyEnum[])
2+
exporttypeEnumSliceType=Readonly<Array<Enum>>
33

44
// From codersdk/enums.go
55
exporttypeEnum="bar"|"baz"|"foo"|"qux"
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// From codersdk/genericmap.go
22
exportinterfaceBuzz{
3-
readonlyfoo:Foo
4-
readonlybazz:string
3+
readonlyfoo:Foo;
4+
readonlybazz:string;
55
}
66

77
// From codersdk/genericmap.go
88
exportinterfaceFoo{
9-
readonlybar:string
9+
readonlybar:string;
1010
}
1111

1212
// From codersdk/genericmap.go
1313
exportinterfaceFooBuzz<RextendsCustom>{
14-
readonlysomething:(readonlyR[])
14+
readonlysomething:Readonly<Array<R>>;
1515
}
1616

1717
// From codersdk/genericmap.go
18-
exporttypeCustom=Foo|Buzz
18+
exporttypeCustom=Foo|Buzz
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
// From codersdk/generics.go
22
exportinterfaceComplex<Cextendscomparable,SextendsSingle,TextendsCustom>{
3-
readonlydynamic:Fields<C,boolean,string,S>
4-
readonlyorder:FieldsDiffOrder<C,string,S,T>
5-
readonlycomparable:C
6-
readonlysingle:S
7-
readonlystatic:Static
3+
readonlydynamic:Fields<C,boolean,string,S>;
4+
readonlyorder:FieldsDiffOrder<C,string,S,T>;
5+
readonlycomparable:C;
6+
readonlysingle:S;
7+
readonlystatic:Static;
88
}
99

1010
// From codersdk/generics.go
1111
exportinterfaceDynamic<Aextendsany,SextendsSingle>{
12-
readonlydynamic:Fields<boolean,A,string,S>
13-
readonlycomparable:boolean
12+
readonlydynamic:Fields<boolean,A,string,S>;
13+
readonlycomparable:boolean;
1414
}
1515

1616
// From codersdk/generics.go
1717
exportinterfaceFields<Cextendscomparable,Aextendsany,TextendsCustom,SextendsSingle>{
18-
readonlycomparable:C
19-
readonlyany:A
20-
readonlycustom:T
21-
readonlyagain:T
22-
readonlysingle_constraint:S
18+
readonlycomparable:C;
19+
readonlyany:A;
20+
readonlycustom:T;
21+
readonlyagain:T;
22+
readonlysingle_constraint:S;
2323
}
2424

2525
// From codersdk/generics.go
2626
exportinterfaceFieldsDiffOrder<Aextendsany,Cextendscomparable,SextendsSingle,TextendsCustom>{
27-
readonlyFields:Fields<C,A,T,S>
27+
readonlyFields:Fields<C,A,T,S>;
2828
}
2929

3030
// From codersdk/generics.go
3131
exportinterfaceStatic{
32-
readonlystatic:Fields<string,number,number,string>
32+
readonlystatic:Fields<string,number,number,string>;
3333
}
3434

3535
// From codersdk/generics.go
36-
exporttypeCustom=string|boolean|number|(readonlystring[])|null
36+
exporttypeCustom=string|boolean|number|Readonly<Array<string>>|null
3737

3838
// From codersdk/generics.go
3939
exporttypeSingle=string
4040

41-
exporttypecomparable=boolean|number|string|any
41+
exporttypecomparable=boolean|number|string|any
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// From codersdk/genericslice.go
22
exportinterfaceBar{
3-
readonlyBar:string
3+
readonlyBar:string;
44
}
55

66
// From codersdk/genericslice.go
77
exportinterfaceFoo<Rextendsany>{
8-
readonlySlice:(readonlyR[])
9-
readonlyTwoD:(readonly(readonlyR[])[])
10-
}
8+
readonlySlice:Readonly<Array<R>>;
9+
readonlyTwoD:Readonly<Array<Readonly<Array<R>>>>;
10+
}

‎site/e2e/helpers.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ export const sshIntoWorkspace = async (
241241
},
242242
write:cp.stdin.write.bind(cp.stdin),
243243
});
244-
// eslint-disable-next-line no-console -- Helpful for debugging
245-
cp.stderr.on("data",(data)=>console.log(data.toString()));
244+
cp.stderr.on("data",(data)=>console.info(data.toString()));
246245
cp.stdout.on("readable",(...args)=>{
247246
proxyStream.emit("readable", ...args);
248247
if(cp.stdout.readableLength>0){
@@ -355,10 +354,8 @@ export const downloadCoderVersion = async (
355354
},
356355
},
357356
);
358-
// eslint-disable-next-line no-console -- Needed for debugging
359357
cp.stderr.on("data",(data)=>console.error(data.toString()));
360-
// eslint-disable-next-line no-console -- Needed for debugging
361-
cp.stdout.on("data",(data)=>console.log(data.toString()));
358+
cp.stdout.on("data",(data)=>console.info(data.toString()));
362359
cp.on("close",(code)=>{
363360
if(code===0){
364361
resolve();

‎site/e2e/reporter.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import*asfsfrom"node:fs/promises";
22
importtype{Writable}from"node:stream";
3-
/* eslint-disable no-console -- Logging is sort of the whole point here */
43
importtype{
54
FullConfig,
65
FullResult,
@@ -170,5 +169,4 @@ const reportError = (error: TestError) => {
170169
}
171170
};
172171

173-
// eslint-disable-next-line no-unused-vars -- Playwright config uses it
174172
exportdefaultCoderReporter;

‎site/e2e/tests/webTerminal.spec.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ test("web terminal", async ({ context, page }) => {
6262
);
6363
}catch(error){
6464
constpageContent=awaitterminal.content();
65-
// eslint-disable-next-line no-console -- Let's see what is inside of xterm-rows
6665
console.error("Unable to find echoed text:",pageContent);
6766
throwerror;
6867
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp