Skip to content

Commit 5efc7e9

Browse files
ergunshDevtools-frontend LUCI CQ
authored andcommitted
[Eslint] Add a custom rule for enforcing as const in UIStrings
We needed to update other l10n related eslint rules and `collect-strings` script to look for `as const` definitions as well. Fixed: 397381592 Change-Id: Ia3eb9a97fa1595093fb332525f996039f7546d8e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6287325 Commit-Queue: Ergün Erdoğmuş <[email protected]> Reviewed-by: Nikolay Vitkov <[email protected]> Reviewed-by: Mathias Bynens <[email protected]> Reviewed-by: Simon Zünd <[email protected]>
1 parent f947981 commit 5efc7e9

File tree

546 files changed

+678
-573
lines changed

Some content is hidden

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

546 files changed

+678
-573
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ export default [
615615
rootFrontendDirectory: join(import.meta.dirname, 'front_end'),
616616
},
617617
],
618+
'rulesdir/enforce-ui-strings-as-const': 'error',
618619
},
619620
},
620621
{

front_end/core/common/ResourceType.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const UIStrings = {
145145
*@description Name of a network initiator type
146146
*/
147147
webbundle: 'WebBundle',
148-
};
148+
} as const;
149149
const str_ = i18n.i18n.registerUIStrings('core/common/ResourceType.ts', UIStrings);
150150
const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);
151151

front_end/core/common/Revealer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const UIStrings = {
5454
* @description The UI destination when revealing loaded resources through the Animations panel
5555
*/
5656
animationsPanel: 'Animations panel',
57-
};
57+
} as const;
5858
const str_ = i18n.i18n.registerUIStrings('core/common/Revealer.ts', UIStrings);
5959
const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);
6060

front_end/core/common/SettingRegistration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const UIStrings = {
7878
* @description Text for the privacy section of the page.
7979
*/
8080
privacy: 'Privacy',
81-
};
81+
} as const;
8282
const str_ = i18n.i18n.registerUIStrings('core/common/SettingRegistration.ts', UIStrings);
8383
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
8484
let registeredSettings: SettingRegistration[] = [];

front_end/core/host/InspectorFrontendHost.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const UIStrings = {
7474
*@example {example.com} PH1
7575
*/
7676
devtoolsS: 'DevTools - {PH1}',
77-
};
77+
} as const;
7878
const str_ = i18n.i18n.registerUIStrings('core/host/InspectorFrontendHost.ts', UIStrings);
7979
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
8080

front_end/core/host/ResourceLoader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const UIStrings = {
6565
*@description Name of an error category used in error messages
6666
*/
6767
decodingDataUrlFailed: 'Decoding Data URL failed',
68-
};
68+
} as const;
6969
const str_ = i18n.i18n.registerUIStrings('core/host/ResourceLoader.ts', UIStrings);
7070
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
7171
export const ResourceLoader = {};

front_end/core/sdk/CPUProfilerModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const UIStrings = {
4343
*@example {2} PH1
4444
*/
4545
profileD: 'Profile {PH1}',
46-
};
46+
} as const;
4747
const str_ = i18n.i18n.registerUIStrings('core/sdk/CPUProfilerModel.ts', UIStrings);
4848
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
4949

front_end/core/sdk/CPUThrottlingManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const UIStrings = {
3030
* @description Text label indicating why an option is not available, because the user's device is not fast enough to emulate a device.
3131
*/
3232
calibrationErrorDeviceTooWeak: 'Device is not powerful enough',
33-
};
33+
} as const;
3434
const str_ = i18n.i18n.registerUIStrings('core/sdk/CPUThrottlingManager.ts', UIStrings);
3535
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
3636
const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);

front_end/core/sdk/CSSStyleSheetHeader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const UIStrings = {
2424
*@description Error message to display when a source CSS file could not be retrieved.
2525
*/
2626
thereWasAnErrorRetrievingThe: 'There was an error retrieving the source styles.',
27-
};
27+
} as const;
2828
const str_ = i18n.i18n.registerUIStrings('core/sdk/CSSStyleSheetHeader.ts', UIStrings);
2929
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
3030

front_end/core/sdk/ChildTargetManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const UIStrings = {
2323
* targets at the same time in some scenarios.
2424
*/
2525
main: 'Main',
26-
};
26+
} as const;
2727
const str_ = i18n.i18n.registerUIStrings('core/sdk/ChildTargetManager.ts', UIStrings);
2828
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
2929

0 commit comments

Comments
 (0)