Skip to content

Commit d9e31a0

Browse files
authored
fix: stop false 'Intl is not defined' lint error (#42080)
1 parent 9bc216a commit d9e31a0

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

app/client/src/plugins/Linting/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export const SUPPORTED_WEB_APIS = {
121121
console: true,
122122
crypto: true,
123123
fetch: true,
124+
Intl: true,
124125
};
125126
export enum CustomLintErrorCode {
126127
INVALID_ENTITY_PROPERTY = "INVALID_ENTITY_PROPERTY",

app/client/src/plugins/Linting/tests/generateLintingGlobalData.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ describe("generateLintingGlobalData", () => {
4444
moment: "readonly",
4545
_: "readonly",
4646
fetch: "readonly",
47+
Intl: "readonly",
4748
});
4849

4950
expect(result.asyncFunctions).toEqual([
@@ -65,6 +66,7 @@ describe("generateLintingGlobalData", () => {
6566
moment: "readonly",
6667
_: "readonly",
6768
fetch: "readonly",
69+
Intl: "readonly",
6870
});
6971

7072
expect(result.asyncFunctions).toEqual([]);
@@ -89,6 +91,7 @@ describe("generateLintingGlobalData", () => {
8991
moment: "readonly",
9092
_: "readonly",
9193
fetch: "readonly",
94+
Intl: "readonly",
9295
});
9396

9497
expect(result.asyncFunctions).toEqual([]);

app/client/src/plugins/Linting/tests/getLintingErrors.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,25 @@ describe.each(linterTypes)(
7777
scriptType,
7878
});
7979

80+
expect(lintErrors.length).toEqual(0);
81+
});
82+
it("4. For Intl", () => {
83+
const originalBinding =
84+
"{{new Intl.NumberFormat('pt-BR', { currency: 'BRL', style: 'currency' }).format(10)}}";
85+
const script =
86+
"new Intl.NumberFormat('pt-BR', { currency: 'BRL', style: 'currency' }).format(10)";
87+
88+
const scriptType = getScriptType(false, true);
89+
90+
const lintErrors = getLintingErrors({
91+
getLinterTypeFn: () => linterType,
92+
webworkerTelemetry,
93+
data,
94+
originalBinding,
95+
script,
96+
scriptType,
97+
});
98+
8099
expect(lintErrors.length).toEqual(0);
81100
});
82101
});

0 commit comments

Comments
 (0)