Skip to content

Commit 2d03669

Browse files
authored
Merge pull request #2634 from devtron-labs/fix/sort-imports
fix: improve import/export order across modules via eslint-plugin-simple-import-sort
2 parents 98ba115 + 48a9bb6 commit 2d03669

File tree

460 files changed

+2914
-2100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

460 files changed

+2914
-2100
lines changed

.eslintrc.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17+
const tsconfigPath = require('./tsconfig.json')
18+
1719
module.exports = {
1820
parser: '@typescript-eslint/parser',
19-
plugins: ['@typescript-eslint', 'react', 'prettier', 'import'],
21+
plugins: ['@typescript-eslint', 'react', 'prettier', 'import', 'simple-import-sort'],
2022
env: {
2123
browser: true,
2224
es2021: true,
@@ -112,6 +114,26 @@ module.exports = {
112114
'import/named': 'off',
113115
'no-use-before-define': 'off',
114116
'@typescript-eslint/no-use-before-define': 'error',
117+
'simple-import-sort/imports': [
118+
'error',
119+
{
120+
groups: [
121+
// Packages `react` related packages and external packages.
122+
['^react', '^@?\\w'],
123+
// Devtron packages
124+
['^@devtron-labs'],
125+
// Internal packages.
126+
[...Object.keys(tsconfigPath.compilerOptions.paths).map((alias) => alias.replace('/*', ''))],
127+
// Side effect imports.
128+
['^\\u0000'],
129+
// Put same-folder imports, `..` and `.` last. Other relative imports.
130+
['^\\.\\.(?!/?$)', '^\\.\\./?$', '^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$',],
131+
// Style imports.
132+
[ '^.+\\.?(css|scss)$'],
133+
],
134+
},
135+
],
136+
'simple-import-sort/exports': 'error',
115137
},
116138
overrides: [
117139
{

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.10.18",
7+
"@devtron-labs/devtron-fe-common-lib": "1.10.19",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",
@@ -111,6 +111,7 @@
111111
"eslint-plugin-prettier": "^5.1.2",
112112
"eslint-plugin-react": "^7.33.2",
113113
"eslint-plugin-react-hooks": "^4.6.0",
114+
"eslint-plugin-simple-import-sort": "^12.1.1",
114115
"eslint-plugin-storybook": "^0.8.0",
115116
"husky": "^7.0.4",
116117
"jest-extended": "^2.0.0",

src/Pages/App/CreateAppModal/AppToCloneSelector.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { useState } from 'react'
18+
1719
import {
1820
AppSelectorNoOptionsMessage as appSelectorNoOptionsMessage,
1921
ComponentSizeType,
2022
InfoBlock,
2123
SelectPicker,
2224
SelectPickerProps,
2325
} from '@devtron-labs/devtron-fe-common-lib'
26+
2427
import { appListOptions } from '@Components/AppSelector/AppSelectorUtil'
25-
import { useState } from 'react'
28+
2629
import { AppToCloneSelectorProps } from './types'
2730

2831
const AppToCloneSelector = ({ isJobView, error, handleCloneIdChange }: AppToCloneSelectorProps) => {

src/Pages/App/CreateAppModal/ApplicationInfoForm.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { ChangeEvent } from 'react'
18+
1719
import { CustomInput, TagsContainer, Textarea } from '@devtron-labs/devtron-fe-common-lib'
18-
import { ReactComponent as ICDevtronApp } from '@Icons/ic-devtron-app.svg'
20+
1921
import { ReactComponent as ICCaretLeftSmall } from '@Icons/ic-caret-left-small.svg'
20-
import { ChangeEvent } from 'react'
22+
import { ReactComponent as ICDevtronApp } from '@Icons/ic-devtron-app.svg'
2123
import { importComponentFromFELibrary } from '@Components/common'
2224
import { APP_TYPE } from '@Config/constants'
25+
26+
import AppToCloneSelector from './AppToCloneSelector'
2327
import ProjectSelector from './ProjectSelector'
2428
import {
2529
ApplicationInfoFormProps,
@@ -29,7 +33,6 @@ import {
2933
HandleFormStateChangeParamsType,
3034
ProjectSelectorProps,
3135
} from './types'
32-
import AppToCloneSelector from './AppToCloneSelector'
3336

3437
const MandatoryTagsContainer = importComponentFromFELibrary('MandatoryTagsContainer', null, 'function')
3538

src/Pages/App/CreateAppModal/CreateAppModal.component.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { useEffect, useMemo, useState } from 'react'
18+
import { useHistory } from 'react-router-dom'
19+
1720
import {
1821
Button,
1922
ButtonStyleType,
@@ -28,17 +31,21 @@ import {
2831
validateTagKeyValue,
2932
validateTagValue,
3033
} from '@devtron-labs/devtron-fe-common-lib'
31-
import { useEffect, useMemo, useState } from 'react'
32-
import { getHostURLConfiguration } from '@Services/service'
34+
35+
import { ReactComponent as ICAppTemplate } from '@Icons/ic-app-template.svg'
36+
import { ReactComponent as ICBack } from '@Icons/ic-caret-left-small.svg'
37+
import { importComponentFromFELibrary } from '@Components/common'
3338
import { saveHostURLConfiguration } from '@Components/hostURL/hosturl.service'
3439
import { createJob } from '@Components/Jobs/Service'
35-
import { APP_COMPOSE_STAGE, getAppComposeURL, URLS } from '@Config/routes'
36-
import { useHistory } from 'react-router-dom'
3740
import { REQUIRED_FIELDS_MISSING } from '@Config/constants'
38-
import { importComponentFromFELibrary } from '@Components/common'
39-
import { ReactComponent as ICBack } from '@Icons/ic-caret-left-small.svg'
40-
import { ReactComponent as ICAppTemplate } from '@Icons/ic-app-template.svg'
41+
import { APP_COMPOSE_STAGE, getAppComposeURL, URLS } from '@Config/routes'
42+
import { getHostURLConfiguration } from '@Services/service'
4143

44+
import ApplicationInfoForm from './ApplicationInfoForm'
45+
import { createAppInitialFormErrorState, createAppInitialFormState } from './constants'
46+
import HeaderSection from './HeaderSection'
47+
import { createApp } from './service'
48+
import Sidebar from './Sidebar'
4249
import {
4350
ApplicationInfoFormProps,
4451
CreateAppFormErrorStateType,
@@ -47,13 +54,8 @@ import {
4754
CreateAppModalProps,
4855
CreationMethodType,
4956
} from './types'
50-
import { createAppInitialFormErrorState, createAppInitialFormState } from './constants'
51-
import { getCreateMethodConfig, validateAppName, validateCloneApp, validateProject } from './utils'
52-
import { createApp } from './service'
53-
import ApplicationInfoForm from './ApplicationInfoForm'
54-
import HeaderSection from './HeaderSection'
55-
import Sidebar from './Sidebar'
5657
import UpdateTemplateConfig from './UpdateTemplateConfig'
58+
import { getCreateMethodConfig, validateAppName, validateCloneApp, validateProject } from './utils'
5759

5860
import './styles.scss'
5961

src/Pages/App/CreateAppModal/HeaderSection.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616

1717
import { Button, ButtonStyleType, ButtonVariantType, ComponentSizeType } from '@devtron-labs/devtron-fe-common-lib'
18+
1819
import { ReactComponent as ICClose } from '@Icons/ic-close.svg'
20+
1921
import { HeaderSectionProps } from './types'
2022

2123
const HeaderSection = ({ isJobView, handleClose, isCloseDisabled }: HeaderSectionProps) => (

src/Pages/App/CreateAppModal/ProjectSelector.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ import {
2121
SelectPickerProps,
2222
useGetResourceKindsOptions,
2323
} from '@devtron-labs/devtron-fe-common-lib'
24+
2425
import { ReactComponent as ICFolderColor } from '@Icons/ic-folder-color.svg'
26+
2527
import { CreateAppFormStateType, ProjectSelectorProps } from './types'
2628

2729
const ProjectSelector = ({ selectedProjectId, handleProjectIdChange, error }: ProjectSelectorProps) => {

src/Pages/App/CreateAppModal/Sidebar.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616

1717
import { ModalSidebarPanel } from '@devtron-labs/devtron-fe-common-lib'
18+
1819
import { DOCUMENTATION } from '@Config/constants'
20+
1921
import { CreationMethodType, SidebarProps } from './types'
2022

2123
const Sidebar = ({

src/Pages/App/CreateAppModal/UpdateTemplateConfig.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
import { noop } from '@devtron-labs/devtron-fe-common-lib'
1818

19-
import MaterialList from '@Components/material/MaterialList'
2019
import CIConfig from '@Components/ciConfig/CIConfig'
2120
import { CIConfigProps } from '@Components/ciConfig/types'
2221
import { DockerConfigOverrideKeys } from '@Components/ciPipeline/types'
2322
import { MaterialListProps } from '@Components/material/material.types'
23+
import MaterialList from '@Components/material/MaterialList'
2424

25-
import { Workflow, WorkflowProps } from './Workflow'
2625
import { CreateAppFormStateActionType, UpdateTemplateConfigProps } from './types'
26+
import { Workflow, WorkflowProps } from './Workflow'
2727

2828
const parentState: CIConfigProps['parentState'] = {
2929
loadingState: null,

src/Pages/App/CreateAppModal/Workflow/Workflow.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import { useEffect, useState } from 'react'
18+
1819
import {
1920
APIResponseHandler,
2021
GenericEmptyState,
@@ -29,6 +30,7 @@ import {
2930
import { getCreateWorkflows } from '@Components/app/details/triggerView/workflow.service'
3031
import { getEnvironmentListMin } from '@Services/service'
3132

33+
import { HandleNodeUpdateActionProps, NodeUpdateActionType, WorkflowProps } from './types'
3234
import {
3335
getCDNodeIcon,
3436
getPipelineIdFromNodeId,
@@ -37,7 +39,6 @@ import {
3739
getWorkflowGraphVisualizerNodes,
3840
getWorkflowLinkedCDNodes,
3941
} from './utils'
40-
import { HandleNodeUpdateActionProps, NodeUpdateActionType, WorkflowProps } from './types'
4142

4243
export const Workflow = ({ templateId, onChange, workflowIdToErrorMessageMap }: WorkflowProps) => {
4344
// STATES

0 commit comments

Comments
 (0)