mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
chore(site): align ESLint config to typescript-eslint's recommended-requiring-type-checking (#5797)
This commit is contained in:
@ -8,6 +8,7 @@ env:
|
|||||||
extends:
|
extends:
|
||||||
- eslint:recommended
|
- eslint:recommended
|
||||||
- plugin:@typescript-eslint/recommended
|
- plugin:@typescript-eslint/recommended
|
||||||
|
- plugin:@typescript-eslint/recommended-requiring-type-checking
|
||||||
- plugin:eslint-comments/recommended
|
- plugin:eslint-comments/recommended
|
||||||
- plugin:import/recommended
|
- plugin:import/recommended
|
||||||
- plugin:import/typescript
|
- plugin:import/typescript
|
||||||
@ -35,28 +36,38 @@ root: true
|
|||||||
rules:
|
rules:
|
||||||
"@typescript-eslint/brace-style":
|
"@typescript-eslint/brace-style":
|
||||||
["error", "1tbs", { "allowSingleLine": false }]
|
["error", "1tbs", { "allowSingleLine": false }]
|
||||||
"@typescript-eslint/camelcase": "off"
|
|
||||||
"@typescript-eslint/explicit-function-return-type": "off"
|
|
||||||
"@typescript-eslint/method-signature-style": ["error", "property"]
|
"@typescript-eslint/method-signature-style": ["error", "property"]
|
||||||
"@typescript-eslint/no-floating-promises": error
|
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
|
||||||
"@typescript-eslint/no-invalid-void-type": error
|
"@typescript-eslint/no-misused-promises": "off"
|
||||||
|
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
|
||||||
|
"@typescript-eslint/no-unsafe-argument": "off"
|
||||||
|
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
|
||||||
|
"@typescript-eslint/no-unsafe-assignment": "off"
|
||||||
|
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
|
||||||
|
"@typescript-eslint/no-unsafe-call": "off"
|
||||||
|
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
|
||||||
|
"@typescript-eslint/no-unsafe-member-access": "off"
|
||||||
|
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
|
||||||
|
"@typescript-eslint/no-unsafe-return": "off"
|
||||||
|
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
|
||||||
|
"@typescript-eslint/require-await": "off"
|
||||||
|
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
|
||||||
|
"@typescript-eslint/restrict-plus-operands": "off"
|
||||||
|
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
|
||||||
|
"@typescript-eslint/restrict-template-expressions": "off"
|
||||||
|
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
|
||||||
|
"@typescript-eslint/unbound-method": "off"
|
||||||
# We're disabling the `no-namespace` rule to use a pattern of defining an interface,
|
# We're disabling the `no-namespace` rule to use a pattern of defining an interface,
|
||||||
# and then defining functions that operate on that data via namespace. This is helpful for
|
# and then defining functions that operate on that data via namespace. This is helpful for
|
||||||
# dealing with immutable objects. This is a common pattern that shows up in some other
|
# dealing with immutable objects. This is a common pattern that shows up in some other
|
||||||
# large TypeScript projects, like VSCode.
|
# large TypeScript projects, like VSCode.
|
||||||
# More details: https://github.com/coder/m/pull/9720#discussion_r697609528
|
# More details: https://github.com/coder/m/pull/9720#discussion_r697609528
|
||||||
"@typescript-eslint/no-namespace": "off"
|
"@typescript-eslint/no-namespace": "off"
|
||||||
"@typescript-eslint/no-unnecessary-boolean-literal-compare": error
|
|
||||||
"@typescript-eslint/no-unnecessary-condition": warn
|
|
||||||
"@typescript-eslint/no-unnecessary-type-assertion": warn
|
|
||||||
"@typescript-eslint/no-unused-vars":
|
"@typescript-eslint/no-unused-vars":
|
||||||
- error
|
- error
|
||||||
- argsIgnorePattern: "^_"
|
- argsIgnorePattern: "^_"
|
||||||
varsIgnorePattern: "^_"
|
varsIgnorePattern: "^_"
|
||||||
ignoreRestSiblings: true
|
ignoreRestSiblings: true
|
||||||
"@typescript-eslint/no-use-before-define": "off"
|
|
||||||
"@typescript-eslint/object-curly-spacing": ["error", "always"]
|
|
||||||
"@typescript-eslint/triple-slash-reference": "off"
|
|
||||||
"brace-style": "off"
|
"brace-style": "off"
|
||||||
"curly": ["error", "all"]
|
"curly": ["error", "all"]
|
||||||
"eslint-comments/require-description": "error"
|
"eslint-comments/require-description": "error"
|
||||||
|
@ -20,8 +20,7 @@ export const hardCodedCSRFCookie = (): string => {
|
|||||||
export const withDefaultFeatures = (
|
export const withDefaultFeatures = (
|
||||||
fs: Partial<TypesGen.Entitlements["features"]>,
|
fs: Partial<TypesGen.Entitlements["features"]>,
|
||||||
): TypesGen.Entitlements["features"] => {
|
): TypesGen.Entitlements["features"] => {
|
||||||
for (const k in TypesGen.FeatureNames) {
|
for (const feature of TypesGen.FeatureNames) {
|
||||||
const feature = k as TypesGen.FeatureName
|
|
||||||
// Skip fields that are already filled.
|
// Skip fields that are already filled.
|
||||||
if (fs[feature] !== undefined) {
|
if (fs[feature] !== undefined) {
|
||||||
continue
|
continue
|
||||||
@ -140,8 +139,7 @@ export const getTokens = async (): Promise<TypesGen.APIKey[]> => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const deleteAPIKey = async (keyId: string): Promise<void> => {
|
export const deleteAPIKey = async (keyId: string): Promise<void> => {
|
||||||
const response = await axios.delete("/api/v2/users/me/keys/" + keyId)
|
await axios.delete("/api/v2/users/me/keys/" + keyId)
|
||||||
return response.data
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getUsers = async (
|
export const getUsers = async (
|
||||||
|
@ -65,7 +65,7 @@ const fillAndSubmitForm = async ({
|
|||||||
await userEvent.clear(maxTtlField)
|
await userEvent.clear(maxTtlField)
|
||||||
await userEvent.type(maxTtlField, default_ttl_ms.toString())
|
await userEvent.type(maxTtlField, default_ttl_ms.toString())
|
||||||
|
|
||||||
const allowCancelJobsField = await screen.getByRole("checkbox")
|
const allowCancelJobsField = screen.getByRole("checkbox")
|
||||||
// checkbox is checked by default, so it must be clicked to get unchecked
|
// checkbox is checked by default, so it must be clicked to get unchecked
|
||||||
if (!allow_user_cancel_workspace_jobs) {
|
if (!allow_user_cancel_workspace_jobs) {
|
||||||
await userEvent.click(allowCancelJobsField)
|
await userEvent.click(allowCancelJobsField)
|
||||||
|
@ -249,7 +249,7 @@ describe("UsersPage", () => {
|
|||||||
expect(API.getUsers).toBeCalledWith({ offset: 0, limit: 25, q: "" }),
|
expect(API.getUsers).toBeCalledWith({ offset: 0, limit: 25, q: "" }),
|
||||||
)
|
)
|
||||||
|
|
||||||
const pageButtons = await container.querySelectorAll(
|
const pageButtons = container.querySelectorAll(
|
||||||
`button[name="Page button"]`,
|
`button[name="Page button"]`,
|
||||||
)
|
)
|
||||||
// count handler says there are 2 pages of results
|
// count handler says there are 2 pages of results
|
||||||
|
@ -49,7 +49,7 @@ describe("WorkspacesPage", () => {
|
|||||||
name: "Previous page",
|
name: "Previous page",
|
||||||
})
|
})
|
||||||
expect(prevPage).toBeDisabled()
|
expect(prevPage).toBeDisabled()
|
||||||
const pageButtons = await container.querySelectorAll(
|
const pageButtons = container.querySelectorAll(
|
||||||
`button[name="Page button"]`,
|
`button[name="Page button"]`,
|
||||||
)
|
)
|
||||||
expect(pageButtons.length).toBe(2)
|
expect(pageButtons.length).toBe(2)
|
||||||
|
@ -51,9 +51,7 @@ export const searchUserMachine = createMachine(
|
|||||||
{
|
{
|
||||||
services: {
|
services: {
|
||||||
searchUsers: async (_, { query }) =>
|
searchUsers: async (_, { query }) =>
|
||||||
await (
|
(await getUsers(queryToFilter(query))).users,
|
||||||
await getUsers(queryToFilter(query))
|
|
||||||
).users,
|
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
assignSearchResults: assign({
|
assignSearchResults: assign({
|
||||||
|
Reference in New Issue
Block a user