Skip to content

chore(site): enable eslint-plugin-eslint-comments #4799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/apitypings/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
ValueType: "any",
AboveTypeLine: fmt.Sprintf("%s\n%s",
indentedComment("Embedded anonymous struct, please fix by naming it"),
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any"),
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed"),
),
}, nil
case *types.Map:
Expand Down Expand Up @@ -736,7 +736,7 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
if _, ok := n.Underlying().(*types.Struct); ok {
return TypescriptType{ValueType: "any", AboveTypeLine: fmt.Sprintf("%s\n%s",
indentedComment(fmt.Sprintf("Named type %q unknown, using \"any\"", n.String())),
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any"),
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed"),
)}, nil
}

Expand All @@ -761,7 +761,7 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
intf := ty
if intf.Empty() {
return TypescriptType{ValueType: "any",
AboveTypeLine: indentedComment("eslint-disable-next-line")}, nil
AboveTypeLine: indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed")}, nil
}
return TypescriptType{}, xerrors.New("only empty interface types are supported")
case *types.TypeParam:
Expand Down
2 changes: 2 additions & 0 deletions site/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
extends:
- eslint:recommended
- plugin:@typescript-eslint/recommended
- plugin:eslint-comments/recommended
- plugin:import/recommended
- plugin:import/typescript
- plugin:react/recommended
Expand Down Expand Up @@ -60,6 +61,7 @@ rules:
"@typescript-eslint/triple-slash-reference": "off"
"brace-style": "off"
"curly": ["error", "all"]
"eslint-comments/require-description": "error"
eqeqeq: error
import/default: "off"
import/namespace: "off"
Expand Down
1 change: 1 addition & 0 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"eslint-import-resolver-alias": "1.1.2",
"eslint-import-resolver-typescript": "3.5.0",
"eslint-plugin-compat": "4.0.2",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jest": "27.0.1",
"eslint-plugin-jsx-a11y": "6.6.1",
Expand Down
10 changes: 5 additions & 5 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export type AuditDiff = Record<string, AuditDiffField>

// From codersdk/audit.go
export interface AuditDiffField {
// eslint-disable-next-line
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed
readonly old?: any
// eslint-disable-next-line
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed
readonly new?: any
readonly secret: boolean
}
Expand All @@ -55,7 +55,7 @@ export interface AuditLog {
readonly time: string
readonly organization_id: string
// Named type "net/netip.Addr" unknown, using "any"
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed
readonly ip: any
readonly user_agent: string
readonly resource_type: ResourceType
Expand Down Expand Up @@ -384,7 +384,7 @@ export interface Healthcheck {
export interface License {
readonly id: number
readonly uploaded_at: string
// eslint-disable-next-line
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed
readonly claims: Record<string, any>
}

Expand Down Expand Up @@ -577,7 +577,7 @@ export interface Role {
// From codersdk/sse.go
export interface ServerSentEvent {
readonly type: ServerSentEventType
// eslint-disable-next-line
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO explain why this is needed
readonly data: any
}

Expand Down
3 changes: 2 additions & 1 deletion site/src/components/BuildsTable/BuildsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const groupBuildsByDate = (builds?: TypesGen.WorkspaceBuild[]) => {
builds.forEach((build) => {
const dateKey = new Date(build.created_at).toDateString()

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
// Unsure why this is here but we probably need to fix it.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- see above
if (buildsByDate[dateKey]) {
buildsByDate[dateKey].push(build)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const SearchBarWithFilter: React.FC<
// debounce query string entry by user
// we want the dependency array empty here
// as we don't need to redefine the function
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps -- see above
const debouncedOnFilter = useCallback(
debounce((debouncedQueryString: string) => {
onFilter(debouncedQueryString)
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/UserAutocomplete/UserAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const UserAutocomplete: FC<UserAutocompleteProps> = ({
if (value) {
sendSearch("SEARCH", { query: value.email })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO look into this
}, [])

const handleFilterChange = debounce(
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/AuditPage/AuditPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const groupAuditLogsByDate = (auditLogs?: AuditLog[]) => {
auditLogs.forEach((auditLog) => {
const dateKey = new Date(auditLog.time).toDateString()

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- TODO look into this
if (auditLogsByDate[dateKey]) {
auditLogsByDate[dateKey].push(auditLog)
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
/* eslint-disable @typescript-eslint/no-floating-promises -- TODO figure out why this is*/
import { fireEvent, screen, waitFor } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import * as API from "api/api"
Expand Down Expand Up @@ -62,3 +62,4 @@ describe("CreateWorkspacePage", () => {
)
})
})
/* eslint-enable @typescript-eslint/no-floating-promises -- TODO figure out why this is*/
3 changes: 2 additions & 1 deletion site/src/pages/WorkspacePage/WorkspacePage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
/* eslint-disable @typescript-eslint/no-floating-promises -- TODO look into this */
import { fireEvent, screen, waitFor, within } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import EventSourceMock from "eventsourcemock"
Expand Down Expand Up @@ -349,3 +349,4 @@ describe("WorkspacePage", () => {
})
})
})
/* eslint-enable @typescript-eslint/no-floating-promises -- TODO look into this */
10 changes: 9 additions & 1 deletion site/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6346,6 +6346,14 @@ eslint-plugin-compat@4.0.2:
lodash.memoize "4.1.2"
semver "7.3.5"

eslint-plugin-eslint-comments@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.2.0.tgz#9e1cd7b4413526abb313933071d7aba05ca12ffa"
integrity sha512-0jkOl0hfojIHHmEHgmNdqv4fmh7300NdpA9FFpF7zaoLvB/QeXOGNLIo86oAveJFrfB1p05kC8hpEMHM8DwWVQ==
dependencies:
escape-string-regexp "^1.0.5"
ignore "^5.0.5"

eslint-plugin-import@2.26.0:
version "2.26.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz#f812dc47be4f2b72b478a021605a59fc6fe8b88b"
Expand Down Expand Up @@ -7762,7 +7770,7 @@ ignore@^4.0.3:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==

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