Skip to content

Commit 47cbbe7

Browse files
authored
chore: Turn on prefer-const eslint rule (#4421)
1 parent 3e81f4b commit 47cbbe7

File tree

18 files changed

+37
-27
lines changed

18 files changed

+37
-27
lines changed

eslint.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default defineConfig(
7474
'no-irregular-whitespace': 'warn',
7575
'no-prototype-builtins': 'warn',
7676
'no-unsafe-optional-chaining': 'warn',
77-
'prefer-const': 'warn',
77+
'prefer-const': 'error',
7878
},
7979
},
8080
],

src/components/App/ClusterRoutes.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { useUrl } from 'hooks/useUrl';
2727
import { sidebarNavigationNodesAtom } from 'state/navigation/sidebarNavigationNodesAtom';
2828

2929
export default function ClusterRoutes() {
30-
let { currentClusterName } = useParams() || {};
30+
const { currentClusterName } = useParams() || {};
3131

3232
const navigate = useNavigate();
3333
const { t } = useTranslation();

src/components/App/resourceSchemas/resourceSchemaWorkerApi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if (typeof Worker !== 'undefined') {
1010
);
1111
}
1212

13-
export let isWorkerAvailable = !!schemasWorker;
13+
export const isWorkerAvailable = !!schemasWorker;
1414
export const terminateWorker = () => {
1515
schemasWorker?.terminate();
1616
};

src/components/App/resourceSchemas/resourceSchemas.worker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ const CUSTOM_FORMATS = {
1313
function getExistingCustomFormats(obj, path = '') {
1414
let existingData = [];
1515

16-
for (let i in obj) {
16+
for (const i in obj) {
1717
if (!obj.hasOwnProperty(i)) continue;
1818
if (typeof obj[i] === 'object') {
1919
existingData = existingData.concat(
2020
getExistingCustomFormats(obj[i], path ? `${path}.${i}` : i),
2121
);
2222
} else if (i === CUSTOM_KEY) {
23-
for (let formatKey of Object.keys(CUSTOM_FORMATS)) {
23+
for (const formatKey of Object.keys(CUSTOM_FORMATS)) {
2424
if (formatKey === obj[i]) {
2525
existingData.push({ path, formatKey });
2626
break;
@@ -32,7 +32,7 @@ function getExistingCustomFormats(obj, path = '') {
3232
}
3333

3434
function replaceObjects(existingCustomFormats, schema) {
35-
for (let i in existingCustomFormats) {
35+
for (const i in existingCustomFormats) {
3636
let object = {
3737
...jp.value(schema, `$.${existingCustomFormats[i].path}`),
3838
};

src/components/Clusters/views/ClusterOverview/ClusterStats.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const Injections = React.lazy(
2727
export default function ClusterStats({ nodesData }) {
2828
const { t } = useTranslation();
2929

30-
let cpu = { usage: 0, capacity: 0 };
31-
let memory = { usage: 0, capacity: 0 };
30+
const cpu = { usage: 0, capacity: 0 };
31+
const memory = { usage: 0, capacity: 0 };
3232

3333
if (nodesData) {
3434
for (const node of nodesData) {

src/components/Extensibility/ExtensibilityDetails.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export const ExtensibilityDetailsCore = ({
3939
features,
4040
description: resourceDescription,
4141
} = resMetaData?.general ?? {};
42-
let { disableEdit, disableDelete } = features?.actions || {};
42+
let { disableDelete } = features?.actions || {};
43+
const { disableEdit } = features?.actions || {};
4344
if (isModule) disableDelete = true;
4445

4546
const { schema } = useGetSchema({

src/components/Extensibility/ExtensibilityInjections.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function ExtensibilityInjectionCore({ resMetaData, root }) {
2222
resource: isStatic ? staticResource : resource,
2323
});
2424

25-
let resourceUrl = usePrepareResourceUrl({
25+
const resourceUrl = usePrepareResourceUrl({
2626
apiGroup: resource?.group,
2727
apiVersion: resource?.version,
2828
resourceType: pluralize(resource?.kind || '').toLowerCase(),

src/components/Extensibility/components-form/Modules/Modules.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ export function Modules({ storeKeys, resource, onChange, schema, required }) {
7070
console.warn('Widget::Modules');
7171
return null;
7272
}
73-
let parsedOpt = {};
73+
const parsedOpt = {};
7474
Promise.all(
7575
Object.keys(options).map(async (optionName) => {
7676
if (
7777
optionName === 'name' &&
7878
!Array.isArray(await makeJsonata(options[optionName]))
7979
) {
80-
let moduleName = await makeJsonata(options[optionName]);
80+
const moduleName = await makeJsonata(options[optionName]);
8181
parsedOpt[optionName] = [moduleName];
8282
} else {
8383
parsedOpt[optionName] = await makeJsonata(options[optionName]);
@@ -103,7 +103,7 @@ export function Modules({ storeKeys, resource, onChange, schema, required }) {
103103
return v.name === name;
104104
});
105105

106-
let channelModuleTemplate = [];
106+
const channelModuleTemplate = [];
107107

108108
parsedOptions?.moduleTemplates?.map((moduleTemplate) => {
109109
if (

src/components/Extensibility/contexts/DataSources.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,13 @@ export const DataSourcesContextProvider: FC<Props> = ({
111111
dataSource: DataSource,
112112
resource: Resource = {} as Resource,
113113
) => {
114-
let {
115-
resource: { group, kind, version, name, namespace },
114+
const {
115+
resource: { group, kind, version, name },
116116
ownerLabelSelectorPath,
117117
} = dataSource;
118+
let {
119+
resource: { namespace },
120+
} = dataSource;
118121
if (typeof namespace === 'undefined') {
119122
namespace = resource?.metadata?.namespace || fallbackNamespace;
120123
}

src/components/Extensibility/helpers/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export const getResourceDescAndUrl = (descID) => {
176176
};
177177

178178
const helmBracketsRegex = /{{"(.*?)"}}/g;
179-
let trans = descID.replace(helmBracketsRegex, '$1');
179+
const trans = descID.replace(helmBracketsRegex, '$1');
180180

181181
if (typeof trans === 'string') {
182182
const links = extractLinks(trans);

0 commit comments

Comments
 (0)