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
This commit is contained in:
Joe Previte
2022-10-28 13:46:51 -07:00
committed by GitHub
parent 506a81e3dc
commit ffe461ae58
11 changed files with 29 additions and 15 deletions

View File

@ -624,7 +624,7 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
ValueType: "any", ValueType: "any",
AboveTypeLine: fmt.Sprintf("%s\n%s", AboveTypeLine: fmt.Sprintf("%s\n%s",
indentedComment("Embedded anonymous struct, please fix by naming it"), 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 }, nil
case *types.Map: case *types.Map:
@ -736,7 +736,7 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
if _, ok := n.Underlying().(*types.Struct); ok { if _, ok := n.Underlying().(*types.Struct); ok {
return TypescriptType{ValueType: "any", AboveTypeLine: fmt.Sprintf("%s\n%s", return TypescriptType{ValueType: "any", AboveTypeLine: fmt.Sprintf("%s\n%s",
indentedComment(fmt.Sprintf("Named type %q unknown, using \"any\"", n.String())), 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 )}, nil
} }
@ -761,7 +761,7 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
intf := ty intf := ty
if intf.Empty() { if intf.Empty() {
return TypescriptType{ValueType: "any", 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") return TypescriptType{}, xerrors.New("only empty interface types are supported")
case *types.TypeParam: case *types.TypeParam:

View File

@ -8,6 +8,7 @@ env:
extends: extends:
- eslint:recommended - eslint:recommended
- plugin:@typescript-eslint/recommended - plugin:@typescript-eslint/recommended
- plugin:eslint-comments/recommended
- plugin:import/recommended - plugin:import/recommended
- plugin:import/typescript - plugin:import/typescript
- plugin:react/recommended - plugin:react/recommended
@ -60,6 +61,7 @@ rules:
"@typescript-eslint/triple-slash-reference": "off" "@typescript-eslint/triple-slash-reference": "off"
"brace-style": "off" "brace-style": "off"
"curly": ["error", "all"] "curly": ["error", "all"]
"eslint-comments/require-description": "error"
eqeqeq: error eqeqeq: error
import/default: "off" import/default: "off"
import/namespace: "off" import/namespace: "off"

View File

@ -103,6 +103,7 @@
"eslint-import-resolver-alias": "1.1.2", "eslint-import-resolver-alias": "1.1.2",
"eslint-import-resolver-typescript": "3.5.0", "eslint-import-resolver-typescript": "3.5.0",
"eslint-plugin-compat": "4.0.2", "eslint-plugin-compat": "4.0.2",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "2.26.0", "eslint-plugin-import": "2.26.0",
"eslint-plugin-jest": "27.0.1", "eslint-plugin-jest": "27.0.1",
"eslint-plugin-jsx-a11y": "6.6.1", "eslint-plugin-jsx-a11y": "6.6.1",

View File

@ -41,9 +41,9 @@ export type AuditDiff = Record<string, AuditDiffField>
// From codersdk/audit.go // From codersdk/audit.go
export interface AuditDiffField { 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 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 new?: any
readonly secret: boolean readonly secret: boolean
} }
@ -55,7 +55,7 @@ export interface AuditLog {
readonly time: string readonly time: string
readonly organization_id: string readonly organization_id: string
// Named type "net/netip.Addr" unknown, using "any" // 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 ip: any
readonly user_agent: string readonly user_agent: string
readonly resource_type: ResourceType readonly resource_type: ResourceType
@ -384,7 +384,7 @@ export interface Healthcheck {
export interface License { export interface License {
readonly id: number readonly id: number
readonly uploaded_at: string 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> readonly claims: Record<string, any>
} }
@ -577,7 +577,7 @@ export interface Role {
// From codersdk/sse.go // From codersdk/sse.go
export interface ServerSentEvent { export interface ServerSentEvent {
readonly type: ServerSentEventType 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 readonly data: any
} }

View File

@ -34,7 +34,8 @@ const groupBuildsByDate = (builds?: TypesGen.WorkspaceBuild[]) => {
builds.forEach((build) => { builds.forEach((build) => {
const dateKey = new Date(build.created_at).toDateString() 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]) { if (buildsByDate[dateKey]) {
buildsByDate[dateKey].push(build) buildsByDate[dateKey].push(build)
} else { } else {

View File

@ -39,7 +39,7 @@ export const SearchBarWithFilter: React.FC<
// debounce query string entry by user // debounce query string entry by user
// we want the dependency array empty here // we want the dependency array empty here
// as we don't need to redefine the function // 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( const debouncedOnFilter = useCallback(
debounce((debouncedQueryString: string) => { debounce((debouncedQueryString: string) => {
onFilter(debouncedQueryString) onFilter(debouncedQueryString)

View File

@ -41,7 +41,7 @@ export const UserAutocomplete: FC<UserAutocompleteProps> = ({
if (value) { if (value) {
sendSearch("SEARCH", { query: value.email }) 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( const handleFilterChange = debounce(

View File

@ -47,7 +47,7 @@ const groupAuditLogsByDate = (auditLogs?: AuditLog[]) => {
auditLogs.forEach((auditLog) => { auditLogs.forEach((auditLog) => {
const dateKey = new Date(auditLog.time).toDateString() 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]) { if (auditLogsByDate[dateKey]) {
auditLogsByDate[dateKey].push(auditLog) auditLogsByDate[dateKey].push(auditLog)
} else { } else {

View File

@ -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 { fireEvent, screen, waitFor } from "@testing-library/react"
import userEvent from "@testing-library/user-event" import userEvent from "@testing-library/user-event"
import * as API from "api/api" import * as API from "api/api"
@ -62,3 +62,4 @@ describe("CreateWorkspacePage", () => {
) )
}) })
}) })
/* eslint-enable @typescript-eslint/no-floating-promises -- TODO figure out why this is*/

View File

@ -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 { fireEvent, screen, waitFor, within } from "@testing-library/react"
import userEvent from "@testing-library/user-event" import userEvent from "@testing-library/user-event"
import EventSourceMock from "eventsourcemock" import EventSourceMock from "eventsourcemock"
@ -349,3 +349,4 @@ describe("WorkspacePage", () => {
}) })
}) })
}) })
/* eslint-enable @typescript-eslint/no-floating-promises -- TODO look into this */

View File

@ -6346,6 +6346,14 @@ eslint-plugin-compat@4.0.2:
lodash.memoize "4.1.2" lodash.memoize "4.1.2"
semver "7.3.5" 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: eslint-plugin-import@2.26.0:
version "2.26.0" version "2.26.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz#f812dc47be4f2b72b478a021605a59fc6fe8b88b" resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz#f812dc47be4f2b72b478a021605a59fc6fe8b88b"
@ -7762,7 +7770,7 @@ ignore@^4.0.3:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==
ignore@^5.2.0: ignore@^5.0.5, ignore@^5.2.0:
version "5.2.0" version "5.2.0"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==