diff --git a/.eslintrc.js b/.eslintrc.js index 97300d4..37a9e55 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -14,18 +14,9 @@ module.exports = { ], plugins: ['@typescript-eslint', 'prettier', 'import', 'promise', 'unused-imports'], rules: { - 'prettier/prettier': [ - 'warn', - { - singleQuote: true, - trailingComma: 'all', - printWidth: 100, - }, - ], + '@typescript-eslint/no-explicit-any': 'off', 'import/named': 'off', 'import/no-unresolved': 'off', - 'unused-imports/no-unused-imports': 'error', - '@typescript-eslint/no-explicit-any': 'off', 'import/order': [ 'warn', { @@ -44,5 +35,61 @@ module.exports = { }, }, ], + 'no-restricted-globals': [ + 'error', + { + name: '__dirname', + message: 'Not available in JavaScript', + }, + { + name: '__filename', + message: 'Not available in JavaScript', + }, + { + name: 'atob', + message: + "'atob' unavailable in React Native 0.72. Use 'decodeBase64' helper in src/obfuscation.ts instead", + }, + { + name: 'btoa', + message: + "'btoa' unavailable in React Native 0.72. Use 'encodeBase64' helper in src/obfuscation.ts instead", + }, + { + name: 'Buffer', + message: + "'Buffer' unavailable in JavaScript. Use 'Uint8Array' instead. For Base64, use helpers in src/obfuscation.ts", + }, + { + name: 'clearImmediate', + message: "'clearImmediate' unavailable in JavaScript.", + }, + { + name: 'process', + message: + "'process' unavailable in JavaScript. If this is already defined in webpack.config.js, you can safely disable the error for this line.", + }, + { + name: 'setImmediate', + message: "'setImmediate' unavailable in JavaScript. Use 'setTimeout(fn, 0)' instead", + }, + ], + 'prettier/prettier': [ + 'warn', + { + singleQuote: true, + trailingComma: 'all', + printWidth: 100, + }, + ], + 'unused-imports/no-unused-imports': 'error', }, + overrides: [ + { + files: ['*.spec.ts'], + rules: { + 'no-restricted-globals': 'off', + }, + }, + ], }; diff --git a/.vscode/settings.json b/.vscode/settings.json index d5f8acf..9d543bb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,6 @@ "eslint.format.enable": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" - } -} + }, + "typescript.tsdk": "node_modules/typescript/lib" +} \ No newline at end of file diff --git a/src/application-logger.ts b/src/application-logger.ts index 03185b2..a4ae490 100644 --- a/src/application-logger.ts +++ b/src/application-logger.ts @@ -4,6 +4,7 @@ export const loggerPrefix = '[Eppo SDK]'; // Create a Pino logger instance export const logger = pino({ + // eslint-disable-next-line no-restricted-globals level: process.env.LOG_LEVEL ?? (process.env.NODE_ENV === 'production' ? 'warn' : 'info'), // https://getpino.io/#/docs/browser browser: { disabled: true },