mirror of
https://github.com/coder/coder.git
synced 2025-07-21 01:28:49 +00:00
chore: add explicit-length-check eslint rule (#4147)
* chore: add eslint rule explicit-length-check * fix: add explicit-length-check
This commit is contained in:
@ -30,6 +30,7 @@ plugins:
|
||||
- react-hooks
|
||||
- jest
|
||||
- no-storage
|
||||
- unicorn
|
||||
root: true
|
||||
rules:
|
||||
"@typescript-eslint/brace-style":
|
||||
@ -119,6 +120,7 @@ rules:
|
||||
react/jsx-key: error
|
||||
react/jsx-uses-react: "off"
|
||||
react/react-in-jsx-scope: "off"
|
||||
"unicorn/explicit-length-check": "error"
|
||||
settings:
|
||||
react:
|
||||
version: detect
|
||||
|
@ -110,6 +110,7 @@
|
||||
"eslint-plugin-no-storage": "1.0.2",
|
||||
"eslint-plugin-react": "7.31.1",
|
||||
"eslint-plugin-react-hooks": "4.6.0",
|
||||
"eslint-plugin-unicorn": "^43.0.2",
|
||||
"html-webpack-plugin": "5.5.0",
|
||||
"jest": "27.5.1",
|
||||
"jest-canvas-mock": "2.4.0",
|
||||
|
@ -25,7 +25,7 @@ export const CodeBlock: FC<React.PropsWithChildren<CodeBlockProps>> = ({
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{ctas && ctas.length && (
|
||||
{ctas && ctas.length > 0 && (
|
||||
<div className={styles.ctaBar}>
|
||||
{ctas.map((cta, i) => {
|
||||
return <Fragment key={i}>{cta}</Fragment>
|
||||
|
@ -13,7 +13,7 @@ export const LicenseBanner: React.FC = () => {
|
||||
entitlementsSend("GET_ENTITLEMENTS")
|
||||
}, [entitlementsSend])
|
||||
|
||||
if (warnings.length) {
|
||||
if (warnings.length > 0) {
|
||||
return <LicenseBannerView warnings={warnings} />
|
||||
} else {
|
||||
return null
|
||||
|
@ -112,7 +112,7 @@ export const SearchBarWithFilter: React.FC<React.PropsWithChildren<SearchBarWith
|
||||
/>
|
||||
</div>
|
||||
|
||||
{presetFilters && presetFilters.length ? (
|
||||
{presetFilters && presetFilters.length > 0 ? (
|
||||
<Menu
|
||||
id="filter-menu"
|
||||
anchorEl={anchorEl}
|
||||
|
@ -53,7 +53,7 @@ export const UsersTableBody: FC<React.PropsWithChildren<UsersTableBodyProps>> =
|
||||
return <TableLoader />
|
||||
}
|
||||
|
||||
if (!users || !users.length) {
|
||||
if (!users || users.length === 0) {
|
||||
return (
|
||||
<TableRow>
|
||||
<TableCell colSpan={999}>
|
||||
|
@ -33,7 +33,7 @@ export const WorkspacesTableBody: FC<React.PropsWithChildren<TableBodyProps>> =
|
||||
return <TableLoader />
|
||||
}
|
||||
|
||||
if (!workspaceRefs || !workspaceRefs.length) {
|
||||
if (!workspaceRefs || workspaceRefs.length === 0) {
|
||||
return (
|
||||
<>
|
||||
{filter === workspaceFilterQuery.me || filter === workspaceFilterQuery.all ? (
|
||||
|
@ -38,7 +38,7 @@ const renderTerminal = () => {
|
||||
const expectTerminalText = (container: HTMLElement, text: string) => {
|
||||
return waitFor(() => {
|
||||
const elements = container.getElementsByClassName("xterm-rows")
|
||||
if (elements.length < 1) {
|
||||
if (elements.length === 0) {
|
||||
throw new Error("no xterm-rows")
|
||||
}
|
||||
const row = elements[0] as HTMLDivElement
|
||||
|
@ -38,5 +38,5 @@ export const combineClasses = (
|
||||
}
|
||||
}
|
||||
|
||||
return result.length ? result : undefined
|
||||
return result.length > 0 ? result : undefined
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ export const stripTimezone = (raw: string): string => {
|
||||
export const extractTimezone = (raw: string, defaultTZ = DEFAULT_TIMEZONE): string => {
|
||||
const matches = raw.match(/CRON_TZ=\S*\s/g)
|
||||
|
||||
if (matches && matches.length) {
|
||||
if (matches && matches.length > 0) {
|
||||
return matches[0].replace(/CRON_TZ=/, "").trim()
|
||||
} else {
|
||||
return defaultTZ
|
||||
|
@ -141,7 +141,7 @@ export const createWorkspaceMachine = createMachine(
|
||||
assignSelectedTemplate: assign({
|
||||
selectedTemplate: (ctx, event) => {
|
||||
const templates = event.data.filter((template) => template.name === ctx.templateName)
|
||||
return templates.length ? templates[0] : undefined
|
||||
return templates.length > 0 ? templates[0] : undefined
|
||||
},
|
||||
}),
|
||||
assignTemplateSchema: assign({
|
||||
|
@ -152,7 +152,7 @@ export const terminalMachine =
|
||||
|
||||
const agent = resources
|
||||
.map((resource) => {
|
||||
if (!resource.agents || resource.agents.length < 1) {
|
||||
if (!resource.agents || resource.agents.length === 0) {
|
||||
return
|
||||
}
|
||||
if (!context.agentName) {
|
||||
|
@ -5177,6 +5177,11 @@ buffer@^5.5.0:
|
||||
base64-js "^1.3.1"
|
||||
ieee754 "^1.1.13"
|
||||
|
||||
builtin-modules@^3.3.0:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6"
|
||||
integrity sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==
|
||||
|
||||
builtin-status-codes@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"
|
||||
@ -5504,6 +5509,11 @@ ci-info@^3.2.0:
|
||||
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.3.2.tgz#6d2967ffa407466481c6c90b6e16b3098f080128"
|
||||
integrity sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg==
|
||||
|
||||
ci-info@^3.3.2:
|
||||
version "3.4.0"
|
||||
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.4.0.tgz#b28484fd436cbc267900364f096c9dc185efb251"
|
||||
integrity sha512-t5QdPT5jq3o262DOQ8zA6E1tlH2upmUc4Hlvrbx1pGYJuiiHl7O7rvVNI+l8HTVhd/q3Qc9vqimkNk5yiXsAug==
|
||||
|
||||
cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de"
|
||||
@ -5541,6 +5551,13 @@ clean-css@^5.2.2:
|
||||
dependencies:
|
||||
source-map "~0.6.0"
|
||||
|
||||
clean-regexp@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/clean-regexp/-/clean-regexp-1.0.0.tgz#8df7c7aae51fd36874e8f8d05b9180bc11a3fed7"
|
||||
integrity sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==
|
||||
dependencies:
|
||||
escape-string-regexp "^1.0.5"
|
||||
|
||||
clean-stack@^2.0.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
|
||||
@ -6991,6 +7008,26 @@ eslint-plugin-react@7.31.1:
|
||||
semver "^6.3.0"
|
||||
string.prototype.matchall "^4.0.7"
|
||||
|
||||
eslint-plugin-unicorn@^43.0.2:
|
||||
version "43.0.2"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-unicorn/-/eslint-plugin-unicorn-43.0.2.tgz#b189d58494c8a0985a4b89dba5dbfde3ad7575a5"
|
||||
integrity sha512-DtqZ5mf/GMlfWoz1abIjq5jZfaFuHzGBZYIeuJfEoKKGWRHr2JiJR+ea+BF7Wx2N1PPRoT/2fwgiK1NnmNE3Hg==
|
||||
dependencies:
|
||||
"@babel/helper-validator-identifier" "^7.18.6"
|
||||
ci-info "^3.3.2"
|
||||
clean-regexp "^1.0.0"
|
||||
eslint-utils "^3.0.0"
|
||||
esquery "^1.4.0"
|
||||
indent-string "^4.0.0"
|
||||
is-builtin-module "^3.1.0"
|
||||
lodash "^4.17.21"
|
||||
pluralize "^8.0.0"
|
||||
read-pkg-up "^7.0.1"
|
||||
regexp-tree "^0.1.24"
|
||||
safe-regex "^2.1.1"
|
||||
semver "^7.3.7"
|
||||
strip-indent "^3.0.0"
|
||||
|
||||
eslint-scope@5.1.1, eslint-scope@^5.1.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
|
||||
@ -8636,6 +8673,13 @@ is-buffer@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.5.tgz#ebc252e400d22ff8d77fa09888821a24a658c191"
|
||||
integrity sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==
|
||||
|
||||
is-builtin-module@^3.1.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-3.2.0.tgz#bb0310dfe881f144ca83f30100ceb10cf58835e0"
|
||||
integrity sha512-phDA4oSGt7vl1n5tJvTWooWWAsXLY+2xCnxNqvKhGEzujg+A43wPlPOyDg3C8XQHN+6k/JTQWJ/j0dQh/qr+Hw==
|
||||
dependencies:
|
||||
builtin-modules "^3.3.0"
|
||||
|
||||
is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.4:
|
||||
version "1.2.4"
|
||||
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.4.tgz#47301d58dd0259407865547853df6d61fe471945"
|
||||
@ -11626,6 +11670,11 @@ playwright-core@1.25.1:
|
||||
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.25.1.tgz#abe56aec8bef645fba988320d9f9328fafab0446"
|
||||
integrity sha512-lSvPCmA2n7LawD2Hw7gSCLScZ+vYRkhU8xH0AapMyzwN+ojoDqhkH/KIEUxwNu2PjPoE/fcE0wLAksdOhJ2O5g==
|
||||
|
||||
pluralize@^8.0.0:
|
||||
version "8.0.0"
|
||||
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-8.0.0.tgz#1a6fa16a38d12a1901e0320fa017051c539ce3b1"
|
||||
integrity sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==
|
||||
|
||||
pnp-webpack-plugin@1.6.4:
|
||||
version "1.6.4"
|
||||
resolved "https://registry.yarnpkg.com/pnp-webpack-plugin/-/pnp-webpack-plugin-1.6.4.tgz#c9711ac4dc48a685dabafc86f8b6dd9f8df84149"
|
||||
@ -12612,6 +12661,11 @@ regex-not@^1.0.0, regex-not@^1.0.2:
|
||||
extend-shallow "^3.0.2"
|
||||
safe-regex "^1.1.0"
|
||||
|
||||
regexp-tree@^0.1.24, regexp-tree@~0.1.1:
|
||||
version "0.1.24"
|
||||
resolved "https://registry.yarnpkg.com/regexp-tree/-/regexp-tree-0.1.24.tgz#3d6fa238450a4d66e5bc9c4c14bb720e2196829d"
|
||||
integrity sha512-s2aEVuLhvnVJW6s/iPgEGK6R+/xngd2jNQ+xy4bXNDKxZKJH6jpPHY6kVeVv1IeLCHgswRj+Kl3ELaDjG6V1iw==
|
||||
|
||||
regexp.prototype.flags@^1.4.1, regexp.prototype.flags@^1.4.3:
|
||||
version "1.4.3"
|
||||
resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz#87cab30f80f66660181a3bb7bf5981a872b367ac"
|
||||
@ -12959,6 +13013,13 @@ safe-regex@^1.1.0:
|
||||
dependencies:
|
||||
ret "~0.1.10"
|
||||
|
||||
safe-regex@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-2.1.1.tgz#f7128f00d056e2fe5c11e81a1324dd974aadced2"
|
||||
integrity sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==
|
||||
dependencies:
|
||||
regexp-tree "~0.1.1"
|
||||
|
||||
"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.1.0:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
|
||||
|
Reference in New Issue
Block a user