Skip to content

Commit 9189f29

Browse files
authored
chore: prevent native node functions from leaking to js (#158)
* chore: prevent native node functions from leaking to js * fix lint
1 parent dd0904d commit 9189f29

File tree

3 files changed

+61
-12
lines changed

3 files changed

+61
-12
lines changed

.eslintrc.js

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,9 @@ module.exports = {
1414
],
1515
plugins: ['@typescript-eslint', 'prettier', 'import', 'promise', 'unused-imports'],
1616
rules: {
17-
'prettier/prettier': [
18-
'warn',
19-
{
20-
singleQuote: true,
21-
trailingComma: 'all',
22-
printWidth: 100,
23-
},
24-
],
17+
'@typescript-eslint/no-explicit-any': 'off',
2518
'import/named': 'off',
2619
'import/no-unresolved': 'off',
27-
'unused-imports/no-unused-imports': 'error',
28-
'@typescript-eslint/no-explicit-any': 'off',
2920
'import/order': [
3021
'warn',
3122
{
@@ -44,5 +35,61 @@ module.exports = {
4435
},
4536
},
4637
],
38+
'no-restricted-globals': [
39+
'error',
40+
{
41+
name: '__dirname',
42+
message: 'Not available in JavaScript',
43+
},
44+
{
45+
name: '__filename',
46+
message: 'Not available in JavaScript',
47+
},
48+
{
49+
name: 'atob',
50+
message:
51+
"'atob' unavailable in React Native 0.72. Use 'decodeBase64' helper in src/obfuscation.ts instead",
52+
},
53+
{
54+
name: 'btoa',
55+
message:
56+
"'btoa' unavailable in React Native 0.72. Use 'encodeBase64' helper in src/obfuscation.ts instead",
57+
},
58+
{
59+
name: 'Buffer',
60+
message:
61+
"'Buffer' unavailable in JavaScript. Use 'Uint8Array' instead. For Base64, use helpers in src/obfuscation.ts",
62+
},
63+
{
64+
name: 'clearImmediate',
65+
message: "'clearImmediate' unavailable in JavaScript.",
66+
},
67+
{
68+
name: 'process',
69+
message:
70+
"'process' unavailable in JavaScript. If this is already defined in webpack.config.js, you can safely disable the error for this line.",
71+
},
72+
{
73+
name: 'setImmediate',
74+
message: "'setImmediate' unavailable in JavaScript. Use 'setTimeout(fn, 0)' instead",
75+
},
76+
],
77+
'prettier/prettier': [
78+
'warn',
79+
{
80+
singleQuote: true,
81+
trailingComma: 'all',
82+
printWidth: 100,
83+
},
84+
],
85+
'unused-imports/no-unused-imports': 'error',
4786
},
87+
overrides: [
88+
{
89+
files: ['*.spec.ts'],
90+
rules: {
91+
'no-restricted-globals': 'off',
92+
},
93+
},
94+
],
4895
};

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"eslint.format.enable": true,
33
"editor.codeActionsOnSave": {
44
"source.fixAll.eslint": "explicit"
5-
}
6-
}
5+
},
6+
"typescript.tsdk": "node_modules/typescript/lib"
7+
}

src/application-logger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const loggerPrefix = '[Eppo SDK]';
44

55
// Create a Pino logger instance
66
export const logger = pino({
7+
// eslint-disable-next-line no-restricted-globals
78
level: process.env.LOG_LEVEL ?? (process.env.NODE_ENV === 'production' ? 'warn' : 'info'),
89
// https://getpino.io/#/docs/browser
910
browser: { disabled: true },

0 commit comments

Comments
 (0)