Skip to content
Snippets Groups Projects
Unverified Commit 649aa72d authored by Tasso Evangelista's avatar Tasso Evangelista Committed by GitHub
Browse files

Chore: Update ESlint rules of client code (#27427)

parent 012fe171
No related branches found
No related tags found
No related merge requests found
Showing
with 103 additions and 150 deletions
import { DecoratorFunction } from '@storybook/addons'; import type { DecoratorFunction } from '@storybook/addons';
import React, { ReactElement } from 'react'; import type { ReactElement } from 'react';
import React from 'react';
import ModalContextMock from '../client/stories/contexts/ModalContextMock'; import ModalContextMock from '../client/stories/contexts/ModalContextMock';
import QueryClientProviderMock from '../client/stories/contexts/QueryClientProviderMock'; import QueryClientProviderMock from '../client/stories/contexts/QueryClientProviderMock';
......
{ {
"root": true, "root": true,
"extends": [ "extends": ["@rocket.chat/eslint-config/original", "prettier"],
"@rocket.chat/eslint-config/original",
"prettier"
],
"parser": "@babel/eslint-parser", "parser": "@babel/eslint-parser",
"plugins": [ "plugins": ["react", "react-hooks", "prettier", "testing-library", "anti-trojan-source"],
"react",
"react-hooks",
"prettier",
"testing-library",
"anti-trojan-source"
],
"rules": { "rules": {
"import/named": "error", "import/named": "error",
"import/order": [ "import/order": [
"error", "error",
{ {
"newlines-between": "always", "newlines-between": "always",
"groups": [ "groups": ["builtin", "external", "internal", ["parent", "sibling", "index"]],
"builtin",
"external",
"internal",
[
"parent",
"sibling",
"index"
]
],
"alphabetize": { "alphabetize": {
"order": "asc" "order": "asc"
} }
} }
], ],
"jsx-quotes": [ "jsx-quotes": ["error", "prefer-single"],
"error",
"prefer-single"
],
"new-cap": [ "new-cap": [
"error", "error",
{ {
"capIsNewExceptions": [ "capIsNewExceptions": ["HTML.Comment", "HTML.Raw", "HTML.DIV", "SHA256"]
"HTML.Comment",
"HTML.Raw",
"HTML.DIV",
"SHA256"
]
} }
], ],
"prefer-arrow-callback": [ "prefer-arrow-callback": [
...@@ -59,10 +33,7 @@ ...@@ -59,10 +33,7 @@
"react/jsx-uses-react": "error", "react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error", "react/jsx-uses-vars": "error",
"react/jsx-no-undef": "error", "react/jsx-no-undef": "error",
"react/jsx-fragments": [ "react/jsx-fragments": ["error", "syntax"],
"error",
"syntax"
],
"react/no-multi-comp": "error", "react/no-multi-comp": "error",
"react-hooks/rules-of-hooks": "error", "react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": [ "react-hooks/exhaustive-deps": [
...@@ -76,11 +47,7 @@ ...@@ -76,11 +47,7 @@
"settings": { "settings": {
"import/resolver": { "import/resolver": {
"node": { "node": {
"extensions": [ "extensions": [".js", ".ts", ".tsx"]
".js",
".ts",
".tsx"
]
} }
}, },
"react": { "react": {
...@@ -93,81 +60,74 @@ ...@@ -93,81 +60,74 @@
}, },
"overrides": [ "overrides": [
{ {
"files": [ "files": ["**/*.ts", "**/*.tsx"],
"**/*.ts", "extends": ["@rocket.chat/eslint-config"],
"**/*.tsx" "plugins": ["react", "react-hooks"],
],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"@rocket.chat/eslint-config/original",
"prettier"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"react",
"react-hooks",
"prettier"
],
"rules": { "rules": {
"@typescript-eslint/ban-types": "warn", "@typescript-eslint/naming-convention": [
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-extra-parens": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error", "error",
{ {
"argsIgnorePattern": "^_" "selector": ["function", "parameter", "variable"],
"modifiers": ["destructured"],
"format": null
},
{
"selector": ["variable"],
"format": ["camelCase", "UPPER_CASE", "PascalCase"],
"leadingUnderscore": "allowSingleOrDouble"
},
{
"selector": ["function"],
"format": ["camelCase", "PascalCase"],
"leadingUnderscore": "allowSingleOrDouble"
},
{
"selector": ["parameter"],
"format": ["PascalCase"],
"filter": {
"regex": "Component$",
"match": true
}
},
{
"selector": ["parameter"],
"format": ["camelCase"],
"leadingUnderscore": "allow"
},
{
"selector": ["parameter"],
"format": ["camelCase"],
"modifiers": ["unused"],
"leadingUnderscore": "require"
},
{
"selector": ["interface"],
"format": ["PascalCase"],
"custom": {
"regex": "^I[A-Z]",
"match": true
}
} }
], ],
"@typescript-eslint/prefer-optional-chain": "warn", "@typescript-eslint/no-extra-parens": "off",
"func-call-spacing": "off",
"indent": "off",
"import/order": [ "import/order": [
"error", "error",
{ {
"newlines-between": "always", "newlines-between": "always",
"groups": [ "groups": ["builtin", "external", "internal", ["parent", "sibling", "index"]],
"builtin",
"external",
"internal",
[
"parent",
"sibling",
"index"
]
],
"alphabetize": { "alphabetize": {
"order": "asc" "order": "asc"
} }
} }
], ],
"jsx-quotes": [
"error",
"prefer-single"
],
"new-cap": [ "new-cap": [
"error", "error",
{ {
"capIsNewExceptions": [ "capIsNewExceptions": ["HTML.Comment", "HTML.Raw", "HTML.DIV", "SHA256"]
"HTML.Comment",
"HTML.Raw",
"HTML.DIV",
"SHA256"
]
} }
], ],
"no-empty-function": "off", "no-empty-function": "off",
"no-extra-parens": "off", "no-extra-parens": "off",
"no-redeclare": "off",
"no-spaced-func": "off",
"no-undef": "off",
"no-unused-vars": "off",
"no-useless-constructor": "off",
"no-use-before-define": "off",
"prefer-arrow-callback": [ "prefer-arrow-callback": [
"error", "error",
{ {
...@@ -179,10 +139,7 @@ ...@@ -179,10 +139,7 @@
"react/jsx-uses-react": "error", "react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error", "react/jsx-uses-vars": "error",
"react/jsx-no-undef": "error", "react/jsx-no-undef": "error",
"react/jsx-fragments": [ "react/jsx-fragments": ["error", "syntax"],
"error",
"syntax"
],
"react/no-multi-comp": "error", "react/no-multi-comp": "error",
"react-hooks/rules-of-hooks": "error", "react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": [ "react-hooks/exhaustive-deps": [
...@@ -190,8 +147,7 @@ ...@@ -190,8 +147,7 @@
{ {
"additionalHooks": "(useComponentDidUpdate)" "additionalHooks": "(useComponentDidUpdate)"
} }
], ]
"anti-trojan-source/no-bidi": "error"
}, },
"env": { "env": {
"browser": true, "browser": true,
...@@ -200,11 +156,7 @@ ...@@ -200,11 +156,7 @@
"settings": { "settings": {
"import/resolver": { "import/resolver": {
"node": { "node": {
"extensions": [ "extensions": [".js", ".ts", ".tsx"]
".js",
".ts",
".tsx"
]
} }
}, },
"react": { "react": {
...@@ -213,27 +165,15 @@ ...@@ -213,27 +165,15 @@
} }
}, },
{ {
"files": [ "files": ["**/*.stories.js", "**/*.stories.jsx", "**/*.stories.ts", "**/*.stories.tsx"],
"**/*.stories.js",
"**/*.stories.jsx",
"**/*.stories.ts",
"**/*.stories.tsx"
],
"rules": { "rules": {
"react/display-name": "off", "react/display-name": "off",
"react/no-multi-comp": "off" "react/no-multi-comp": "off"
} }
}, },
{ {
"files": [ "files": ["**/*.tests.js", "**/*.tests.ts", "**/*.spec.ts", "**/*.spec.tsx"],
"**/*.tests.js", "extends": ["plugin:testing-library/react"],
"**/*.tests.ts",
"**/*.spec.ts",
"**/*.spec.tsx"
],
"extends": [
"plugin:testing-library/react"
],
"rules": { "rules": {
"testing-library/no-await-sync-events": "warn", "testing-library/no-await-sync-events": "warn",
"testing-library/no-manual-cleanup": "warn", "testing-library/no-manual-cleanup": "warn",
...@@ -245,10 +185,7 @@ ...@@ -245,10 +185,7 @@
} }
}, },
{ {
"files": [ "files": ["**/*.stories.ts", "**/*.stories.tsx"],
"**/*.stories.ts",
"**/*.stories.tsx"
],
"rules": { "rules": {
"@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off" "@typescript-eslint/explicit-module-boundary-types": "off"
......
...@@ -3,7 +3,7 @@ import { UIKitIncomingInteractionContainerType } from '@rocket.chat/apps-engine/ ...@@ -3,7 +3,7 @@ import { UIKitIncomingInteractionContainerType } from '@rocket.chat/apps-engine/
// import { Banner, Icon } from '@rocket.chat/fuselage'; // import { Banner, Icon } from '@rocket.chat/fuselage';
// import { kitContext, UiKitBanner as renderUiKitBannerBlocks } from '@rocket.chat/fuselage-ui-kit'; // import { kitContext, UiKitBanner as renderUiKitBannerBlocks } from '@rocket.chat/fuselage-ui-kit';
// import React, { Context, FC, useMemo } from 'react'; // import React, { Context, FC, useMemo } from 'react';
import { UiKitPayload, UIKitActionEvent } from '@rocket.chat/core-typings'; import type { UiKitPayload, UIKitActionEvent } from '@rocket.chat/core-typings';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
// import { UIKitIncomingInteractionContainerType } from '@rocket.chat/apps-engine/definition/uikit/UIKitIncomingInteractionContainer'; // import { UIKitIncomingInteractionContainerType } from '@rocket.chat/apps-engine/definition/uikit/UIKitIncomingInteractionContainer';
......
import { UIKitInteractionType } from '@rocket.chat/apps-engine/definition/uikit'; import type { UIKitInteractionType } from '@rocket.chat/apps-engine/definition/uikit';
/* eslint-disable new-cap */ /* eslint-disable new-cap */
// import { Banner, Icon } from '@rocket.chat/fuselage'; // import { Banner, Icon } from '@rocket.chat/fuselage';
// import { kitContext, UiKitBanner as renderUiKitBannerBlocks } from '@rocket.chat/fuselage-ui-kit'; // import { kitContext, UiKitBanner as renderUiKitBannerBlocks } from '@rocket.chat/fuselage-ui-kit';
// import React, { Context, FC, useMemo } from 'react'; // import React, { Context, FC, useMemo } from 'react';
import { UiKitPayload } from '@rocket.chat/core-typings'; import type { UiKitPayload } from '@rocket.chat/core-typings';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useToastMessageDispatch } from '@rocket.chat/ui-contexts'; import { useToastMessageDispatch } from '@rocket.chat/ui-contexts';
// import { UIKitIncomingInteractionContainerType } from '@rocket.chat/apps-engine/definition/uikit/UIKitIncomingInteractionContainer'; // import { UIKitIncomingInteractionContainerType } from '@rocket.chat/apps-engine/definition/uikit/UIKitIncomingInteractionContainer';
......
import { isErrorType, UIKitUserInteractionResult, UiKitPayload } from '@rocket.chat/core-typings'; import type { UIKitUserInteractionResult, UiKitPayload } from '@rocket.chat/core-typings';
import { isErrorType } from '@rocket.chat/core-typings';
import { useSafely } from '@rocket.chat/fuselage-hooks'; import { useSafely } from '@rocket.chat/fuselage-hooks';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
......
import { OptionDivider } from '@rocket.chat/fuselage'; import { OptionDivider } from '@rocket.chat/fuselage';
import React, { FC, Fragment } from 'react'; import type { FC } from 'react';
import React, { Fragment } from 'react';
import { AccountBoxItem, IAppAccountBoxItem, isAppAccountBoxItem } from '../../../app/ui-utils/client/lib/AccountBox'; import type { AccountBoxItem, IAppAccountBoxItem } from '../../../app/ui-utils/client/lib/AccountBox';
import { isAppAccountBoxItem } from '../../../app/ui-utils/client/lib/AccountBox';
import AdministrationModelList from './AdministrationModelList'; import AdministrationModelList from './AdministrationModelList';
import AppsModelList from './AppsModelList'; import AppsModelList from './AppsModelList';
import AuditModelList from './AuditModelList'; import AuditModelList from './AuditModelList';
......
import { OptionTitle } from '@rocket.chat/fuselage'; import { OptionTitle } from '@rocket.chat/fuselage';
import { useTranslation, useRoute } from '@rocket.chat/ui-contexts'; import { useTranslation, useRoute } from '@rocket.chat/ui-contexts';
import { FlowRouter } from 'meteor/kadira:flow-router'; import { FlowRouter } from 'meteor/kadira:flow-router';
import React, { FC } from 'react'; import type { FC } from 'react';
import React from 'react';
import { userHasAllPermission } from '../../../app/authorization/client'; import { userHasAllPermission } from '../../../app/authorization/client';
import { SideNav } from '../../../app/ui-utils/client'; import { SideNav } from '../../../app/ui-utils/client';
import { AccountBoxItem } from '../../../app/ui-utils/client/lib/AccountBox'; import type { AccountBoxItem } from '../../../app/ui-utils/client/lib/AccountBox';
import { getUpgradeTabLabel, isFullyFeature } from '../../../lib/upgradeTab'; import { getUpgradeTabLabel, isFullyFeature } from '../../../lib/upgradeTab';
import { useUpgradeTabParams } from '../../views/hooks/useUpgradeTabParams'; import { useUpgradeTabParams } from '../../views/hooks/useUpgradeTabParams';
import Emoji from '../Emoji'; import Emoji from '../Emoji';
......
import { OptionTitle } from '@rocket.chat/fuselage'; import { OptionTitle } from '@rocket.chat/fuselage';
import { useTranslation, useRoute } from '@rocket.chat/ui-contexts'; import { useTranslation, useRoute } from '@rocket.chat/ui-contexts';
import React, { ReactElement } from 'react'; import type { ReactElement } from 'react';
import React from 'react';
import { triggerActionButtonAction } from '../../../app/ui-message/client/ActionManager'; import { triggerActionButtonAction } from '../../../app/ui-message/client/ActionManager';
import { IAppAccountBoxItem } from '../../../app/ui-utils/client/lib/AccountBox'; import type { IAppAccountBoxItem } from '../../../app/ui-utils/client/lib/AccountBox';
import ListItem from '../Sidebar/ListItem'; import ListItem from '../Sidebar/ListItem';
type AppsModelListProps = { type AppsModelListProps = {
......
import { OptionTitle } from '@rocket.chat/fuselage'; import { OptionTitle } from '@rocket.chat/fuselage';
import { useRoute, useTranslation } from '@rocket.chat/ui-contexts'; import { useRoute, useTranslation } from '@rocket.chat/ui-contexts';
import React, { FC } from 'react'; import type { FC } from 'react';
import React from 'react';
import ListItem from '../Sidebar/ListItem'; import ListItem from '../Sidebar/ListItem';
......
import { PaginatedSelectFiltered } from '@rocket.chat/fuselage'; import { PaginatedSelectFiltered } from '@rocket.chat/fuselage';
import { useDebouncedValue } from '@rocket.chat/fuselage-hooks'; import { useDebouncedValue } from '@rocket.chat/fuselage-hooks';
import React, { memo, ReactElement, useMemo, useState } from 'react'; import type { ReactElement } from 'react';
import React, { memo, useMemo, useState } from 'react';
import { useRecordList } from '../hooks/lists/useRecordList'; import { useRecordList } from '../hooks/lists/useRecordList';
import { AsyncStatePhase } from '../lib/asyncState'; import { AsyncStatePhase } from '../lib/asyncState';
......
import { ILivechatAgent } from '@rocket.chat/core-typings'; import type { ILivechatAgent } from '@rocket.chat/core-typings';
import { PaginatedSelectFiltered } from '@rocket.chat/fuselage'; import { PaginatedSelectFiltered } from '@rocket.chat/fuselage';
import { useDebouncedValue } from '@rocket.chat/fuselage-hooks'; import { useDebouncedValue } from '@rocket.chat/fuselage-hooks';
import React, { FC, memo, useMemo, useState } from 'react'; import type { FC } from 'react';
import React, { memo, useMemo, useState } from 'react';
import { useRecordList } from '../hooks/lists/useRecordList'; import { useRecordList } from '../hooks/lists/useRecordList';
import { AsyncStatePhase } from '../lib/asyncState'; import { AsyncStatePhase } from '../lib/asyncState';
......
import { PaginatedSelectFiltered } from '@rocket.chat/fuselage'; import { PaginatedSelectFiltered } from '@rocket.chat/fuselage';
import { useDebouncedValue } from '@rocket.chat/fuselage-hooks'; import { useDebouncedValue } from '@rocket.chat/fuselage-hooks';
import { useTranslation } from '@rocket.chat/ui-contexts'; import { useTranslation } from '@rocket.chat/ui-contexts';
import React, { memo, ReactElement, useMemo, useState } from 'react'; import type { ReactElement } from 'react';
import React, { memo, useMemo, useState } from 'react';
import { useRecordList } from '../hooks/lists/useRecordList'; import { useRecordList } from '../hooks/lists/useRecordList';
import { AsyncStatePhase } from '../hooks/useAsyncState'; import { AsyncStatePhase } from '../hooks/useAsyncState';
......
import { Modal } from '@rocket.chat/fuselage'; import { Modal } from '@rocket.chat/fuselage';
import React, { ComponentProps, ReactElement } from 'react'; import type { ComponentProps, ReactElement } from 'react';
import React from 'react';
type BackdropProps = ComponentProps<typeof Modal.Backdrop>; type BackdropProps = ComponentProps<typeof Modal.Backdrop>;
......
import { Box } from '@rocket.chat/fuselage'; import { Box } from '@rocket.chat/fuselage';
import { ComponentMeta, ComponentStory } from '@storybook/react'; import type { ComponentMeta, ComponentStory } from '@storybook/react';
import React, { ReactElement } from 'react'; import type { ReactElement } from 'react';
import React from 'react';
import BurgerBadge from './BurgerBadge'; import BurgerBadge from './BurgerBadge';
......
import { css } from '@rocket.chat/css-in-js'; import { css } from '@rocket.chat/css-in-js';
import { Box, Badge } from '@rocket.chat/fuselage'; import { Box, Badge } from '@rocket.chat/fuselage';
import React, { ReactElement } from 'react'; import type { ReactElement } from 'react';
import React from 'react';
const BurgerBadge = ({ children }: { children?: unknown }): ReactElement => ( const BurgerBadge = ({ children }: { children?: unknown }): ReactElement => (
<Box <Box
......
import { ComponentMeta, ComponentStory } from '@storybook/react'; import type { ComponentMeta, ComponentStory } from '@storybook/react';
import React from 'react'; import React from 'react';
import { useAutoSequence } from '../../stories/hooks/useAutoSequence'; import { useAutoSequence } from '../../stories/hooks/useAutoSequence';
......
import { usePrefersReducedMotion } from '@rocket.chat/fuselage-hooks'; import { usePrefersReducedMotion } from '@rocket.chat/fuselage-hooks';
import React, { ReactElement, ReactNode } from 'react'; import type { ReactElement, ReactNode } from 'react';
import React from 'react';
import Line from './Line'; import Line from './Line';
import Wrapper from './Wrapper'; import Wrapper from './Wrapper';
......
import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useLayout, useSession } from '@rocket.chat/ui-contexts'; import { useLayout, useSession } from '@rocket.chat/ui-contexts';
import React, { memo, ReactElement } from 'react'; import type { ReactElement } from 'react';
import React, { memo } from 'react';
import { useEmbeddedLayout } from '../../hooks/useEmbeddedLayout'; import { useEmbeddedLayout } from '../../hooks/useEmbeddedLayout';
import BurgerMenuButton from './BurgerMenuButton'; import BurgerMenuButton from './BurgerMenuButton';
......
import { action } from '@storybook/addon-actions'; import { action } from '@storybook/addon-actions';
import { ComponentMeta, ComponentStory } from '@storybook/react'; import type { ComponentMeta, ComponentStory } from '@storybook/react';
import React from 'react'; import React from 'react';
import { useAutoSequence } from '../../stories/hooks/useAutoSequence'; import { useAutoSequence } from '../../stories/hooks/useAutoSequence';
......
import { css } from '@rocket.chat/css-in-js'; import { css } from '@rocket.chat/css-in-js';
import { Box } from '@rocket.chat/fuselage'; import { Box } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts'; import { useTranslation } from '@rocket.chat/ui-contexts';
import React, { ReactElement } from 'react'; import type { ReactElement } from 'react';
import React from 'react';
import BurgerBadge from './BurgerBadge'; import BurgerBadge from './BurgerBadge';
import BurgerIcon from './BurgerIcon'; import BurgerIcon from './BurgerIcon';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment