Skip to content

Commit ffe461a

Browse files
authored
chore(site): enable eslint-plugin-eslint-comments (#4799)
* chore(site): enable eslint-plugin-eslint-comments * chore: add descriptions to eslint-disable comments * chore: update eslint-disable comments in main.go
1 parent 506a81e commit ffe461a

File tree

11 files changed

+29
-15
lines changed

11 files changed

+29
-15
lines changed

scripts/apitypings/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
624624
ValueType: "any",
625625
AboveTypeLine: fmt.Sprintf("%s\n%s",
626626
indentedComment("Embedded anonymous struct, please fix by naming it"),
627-
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any"),
627+
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed"),
628628
),
629629
}, nil
630630
case *types.Map:
@@ -736,7 +736,7 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
736736
if _, ok := n.Underlying().(*types.Struct); ok {
737737
return TypescriptType{ValueType: "any", AboveTypeLine: fmt.Sprintf("%s\n%s",
738738
indentedComment(fmt.Sprintf("Named type %q unknown, using \"any\"", n.String())),
739-
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any"),
739+
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed"),
740740
)}, nil
741741
}
742742

@@ -761,7 +761,7 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
761761
intf := ty
762762
if intf.Empty() {
763763
return TypescriptType{ValueType: "any",
764-
AboveTypeLine: indentedComment("eslint-disable-next-line")}, nil
764+
AboveTypeLine: indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed")}, nil
765765
}
766766
return TypescriptType{}, xerrors.New("only empty interface types are supported")
767767
case *types.TypeParam:

site/.eslintrc.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ env:
88
extends:
99
- eslint:recommended
1010
- plugin:@typescript-eslint/recommended
11+
- plugin:eslint-comments/recommended
1112
- plugin:import/recommended
1213
- plugin:import/typescript
1314
- plugin:react/recommended
@@ -60,6 +61,7 @@ rules:
6061
"@typescript-eslint/triple-slash-reference": "off"
6162
"brace-style": "off"
6263
"curly": ["error", "all"]
64+
"eslint-comments/require-description": "error"
6365
eqeqeq: error
6466
import/default: "off"
6567
import/namespace: "off"

site/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
"eslint-import-resolver-alias": "1.1.2",
104104
"eslint-import-resolver-typescript": "3.5.0",
105105
"eslint-plugin-compat": "4.0.2",
106+
"eslint-plugin-eslint-comments": "^3.2.0",
106107
"eslint-plugin-import": "2.26.0",
107108
"eslint-plugin-jest": "27.0.1",
108109
"eslint-plugin-jsx-a11y": "6.6.1",

site/src/api/typesGenerated.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ export type AuditDiff = Record<string, AuditDiffField>
4141

4242
// From codersdk/audit.go
4343
export interface AuditDiffField {
44-
// eslint-disable-next-line
44+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed
4545
readonly old?: any
46-
// eslint-disable-next-line
46+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed
4747
readonly new?: any
4848
readonly secret: boolean
4949
}
@@ -55,7 +55,7 @@ export interface AuditLog {
5555
readonly time: string
5656
readonly organization_id: string
5757
// Named type "net/netip.Addr" unknown, using "any"
58-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
58+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed
5959
readonly ip: any
6060
readonly user_agent: string
6161
readonly resource_type: ResourceType
@@ -384,7 +384,7 @@ export interface Healthcheck {
384384
export interface License {
385385
readonly id: number
386386
readonly uploaded_at: string
387-
// eslint-disable-next-line
387+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed
388388
readonly claims: Record<string, any>
389389
}
390390

@@ -577,7 +577,7 @@ export interface Role {
577577
// From codersdk/sse.go
578578
export interface ServerSentEvent {
579579
readonly type: ServerSentEventType
580-
// eslint-disable-next-line
580+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed
581581
readonly data: any
582582
}
583583

site/src/components/BuildsTable/BuildsTable.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ const groupBuildsByDate = (builds?: TypesGen.WorkspaceBuild[]) => {
3434
builds.forEach((build) => {
3535
const dateKey = new Date(build.created_at).toDateString()
3636

37-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
37+
// Unsure why this is here but we probably need to fix it.
38+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- see above
3839
if (buildsByDate[dateKey]) {
3940
buildsByDate[dateKey].push(build)
4041
} else {

site/src/components/SearchBarWithFilter/SearchBarWithFilter.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const SearchBarWithFilter: React.FC<
3939
// debounce query string entry by user
4040
// we want the dependency array empty here
4141
// as we don't need to redefine the function
42-
// eslint-disable-next-line react-hooks/exhaustive-deps
42+
// eslint-disable-next-line react-hooks/exhaustive-deps -- see above
4343
const debouncedOnFilter = useCallback(
4444
debounce((debouncedQueryString: string) => {
4545
onFilter(debouncedQueryString)

site/src/components/UserAutocomplete/UserAutocomplete.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const UserAutocomplete: FC<UserAutocompleteProps> = ({
4141
if (value) {
4242
sendSearch("SEARCH", { query: value.email })
4343
}
44-
// eslint-disable-next-line react-hooks/exhaustive-deps
44+
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO look into this
4545
}, [])
4646

4747
const handleFilterChange = debounce(

site/src/pages/AuditPage/AuditPageView.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const groupAuditLogsByDate = (auditLogs?: AuditLog[]) => {
4747
auditLogs.forEach((auditLog) => {
4848
const dateKey = new Date(auditLog.time).toDateString()
4949

50-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
50+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- TODO look into this
5151
if (auditLogsByDate[dateKey]) {
5252
auditLogsByDate[dateKey].push(auditLog)
5353
} else {

site/src/pages/CreateWorkspacePage/CreateWorkspacePage.test.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/no-floating-promises */
1+
/* eslint-disable @typescript-eslint/no-floating-promises -- TODO figure out why this is*/
22
import { fireEvent, screen, waitFor } from "@testing-library/react"
33
import userEvent from "@testing-library/user-event"
44
import * as API from "api/api"
@@ -62,3 +62,4 @@ describe("CreateWorkspacePage", () => {
6262
)
6363
})
6464
})
65+
/* eslint-enable @typescript-eslint/no-floating-promises -- TODO figure out why this is*/

site/src/pages/WorkspacePage/WorkspacePage.test.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/no-floating-promises */
1+
/* eslint-disable @typescript-eslint/no-floating-promises -- TODO look into this */
22
import { fireEvent, screen, waitFor, within } from "@testing-library/react"
33
import userEvent from "@testing-library/user-event"
44
import EventSourceMock from "eventsourcemock"
@@ -349,3 +349,4 @@ describe("WorkspacePage", () => {
349349
})
350350
})
351351
})
352+
/* eslint-enable @typescript-eslint/no-floating-promises -- TODO look into this */

site/yarn.lock

+9-1
Original file line numberDiff line numberDiff line change
@@ -6346,6 +6346,14 @@ eslint-plugin-compat@4.0.2:
63466346
lodash.memoize "4.1.2"
63476347
semver "7.3.5"
63486348

6349+
eslint-plugin-eslint-comments@^3.2.0:
6350+
version "3.2.0"
6351+
resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.2.0.tgz#9e1cd7b4413526abb313933071d7aba05ca12ffa"
6352+
integrity sha512-0jkOl0hfojIHHmEHgmNdqv4fmh7300NdpA9FFpF7zaoLvB/QeXOGNLIo86oAveJFrfB1p05kC8hpEMHM8DwWVQ==
6353+
dependencies:
6354+
escape-string-regexp "^1.0.5"
6355+
ignore "^5.0.5"
6356+
63496357
eslint-plugin-import@2.26.0:
63506358
version "2.26.0"
63516359
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz#f812dc47be4f2b72b478a021605a59fc6fe8b88b"
@@ -7762,7 +7770,7 @@ ignore@^4.0.3:
77627770
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
77637771
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==
77647772

7765-
ignore@^5.2.0:
7773+
ignore@^5.0.5, ignore@^5.2.0:
77667774
version "5.2.0"
77677775
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
77687776
integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==

0 commit comments

Comments
 (0)