Skip to content

Commit cc41463

Browse files
committed
chore: prevent native node functions from leaking to js
1 parent 0587b36 commit cc41463

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

.eslintrc.js

Lines changed: 49 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,53 @@ 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. Use 'setTimeout(fn, 0)' instead",
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: 'Not available in JavaScript.',
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
},
4887
};

.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+
}

0 commit comments

Comments
 (0)