Skip to content

Commit 82a136d

Browse files
authored
Merge pull request #688 from devtron-labs/fix/sort-imports
fix: improve import/export order across modules via eslint-plugin-simple-import-sort
2 parents 02025c1 + 027f327 commit 82a136d

File tree

422 files changed

+1638
-1216
lines changed

Some content is hidden

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

422 files changed

+1638
-1216
lines changed

.eslintrc.cjs

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,
@@ -109,6 +111,26 @@ module.exports = {
109111
'import/prefer-default-export': 'off',
110112
'no-restricted-exports': 'off',
111113
'import/named': 'off',
114+
'simple-import-sort/imports': [
115+
'error',
116+
{
117+
groups: [
118+
// Packages `react` related packages and external packages.
119+
['^react', '^@?\\w'],
120+
// Devtron packages
121+
['^@devtron-labs'],
122+
// Internal packages.
123+
[...Object.keys(tsconfigPath.compilerOptions.paths).map((alias) => alias.replace('/*', ''))],
124+
// Side effect imports.
125+
['^\\u0000'],
126+
// Put same-folder imports, `..` and `.` last. Other relative imports.
127+
['^\\.\\.(?!/?$)', '^\\.\\./?$', '^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$',],
128+
// Style imports.
129+
[ '^.+\\.?(css|scss)$'],
130+
],
131+
},
132+
],
133+
'simple-import-sort/exports': 'error',
112134
},
113135
overrides: [
114136
{

package-lock.json

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.10.18",
3+
"version": "1.10.19",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
@@ -60,6 +60,7 @@
6060
"eslint-plugin-prettier": "^5.1.2",
6161
"eslint-plugin-react": "^7.33.2",
6262
"eslint-plugin-react-hooks": "^4.6.0",
63+
"eslint-plugin-simple-import-sort": "^12.1.1",
6364
"glob": "^10.3.3",
6465
"husky": "^7.0.4",
6566
"json-schema": "^0.4.0",

src/Common/API/CoreAPI.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import { INVALID_LICENSE_KEY, ResponseHeaders } from '@Shared/index'
2-
import { API_STATUS_CODES, APIOptions, FALLBACK_REQUEST_TIMEOUT, Host, noop, ResponseType, ServerErrors } from '..'
1+
import { API_STATUS_CODES, FALLBACK_REQUEST_TIMEOUT, Host } from '@Common/Constants'
2+
import { noop } from '@Common/Helper'
3+
import { ServerErrors } from '@Common/ServerError'
4+
import { APIOptions, ResponseType } from '@Common/Types'
5+
import { INVALID_LICENSE_KEY } from '@Shared/constants'
6+
import { ResponseHeaders } from '@Shared/types'
7+
38
import { CoreAPIConstructorParamsType, FetchAPIParamsType, FetchInTimeParamsType } from './types'
49
import { handleServerError } from './utils'
510

src/Common/API/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ const dashboardAPI = new CoreAPI({
88
})
99

1010
export const { post, put, patch, get, trash } = dashboardAPI
11-
export { getIsRequestAborted, abortPreviousRequests, handleRedirectToLicenseActivation } from './utils'
1211
export { default as CoreAPI } from './CoreAPI'
12+
export { abortPreviousRequests, getIsRequestAborted, handleRedirectToLicenseActivation } from './utils'

src/Common/API/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { ServerErrors } from '@Common/ServerError'
21
import { MutableRefObject } from 'react'
2+
33
import { URLS } from '@Common/Constants'
4+
import { ServerErrors } from '@Common/ServerError'
5+
46
import { RESPONSE_MESSAGES } from './constants'
57

68
export const handleServerError = async (contentType: string, response: Response) => {

src/Common/AddCDButton/utils.tsx

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

1717
import { AddCDPositions, AddPipelineType, PipelineType, WorkflowNodeType } from '../Types'
18-
import { HandleAddCD, GetPipelineType } from './types'
18+
import { GetPipelineType, HandleAddCD } from './types'
1919

2020
const getPipelineType = ({ startNode }: GetPipelineType) => {
2121
if (startNode.type === WorkflowNodeType.WEBHOOK) {

src/Common/ClipboardButton/ClipboardButton.tsx

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

17-
import { useState, useEffect, useRef } from 'react'
17+
import { useEffect, useRef, useState } from 'react'
18+
1819
import Tooltip from '@Common/Tooltip/Tooltip'
20+
21+
import { ReactComponent as Check } from '../../Assets/Icon/ic-check.svg'
22+
import { ReactComponent as ICCopy } from '../../Assets/Icon/ic-copy.svg'
1923
import { copyToClipboard, noop, stopPropagation } from '../Helper'
2024
import ClipboardProps from './types'
21-
import { ReactComponent as ICCopy } from '../../Assets/Icon/ic-copy.svg'
22-
import { ReactComponent as Check } from '../../Assets/Icon/ic-check.svg'
2325

2426
/**
2527
* @param content - Content to be copied

src/Common/CodeEditor/CodeEditor.reducer.ts

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

1717
import YAML from 'yaml'
18+
1819
import { noop, YAMLStringify } from '@Common/Helper'
20+
1921
import { MODES } from '../Constants'
2022
import { Action, CodeEditorInitialValueType, CodeEditorState } from './types'
2123
import { getCodeEditorThemeFromAppTheme } from './utils'

src/Common/CodeEditor/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import { AppThemeType } from '@Shared/Providers'
18+
1819
import { MODES } from '../Constants'
1920

2021
export interface InformationBarProps {

0 commit comments

Comments
 (0)