Ban Node APIs in plugins/
Reviewed By: mweststrate Differential Revision: D33021152 fbshipit-source-id: bdeb71a42d330b8fed4040d42a02907ee82b3254
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3f771c05dd
commit
9fd45b96d2
@@ -190,6 +190,78 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
files: ['plugins/**/*.ts', 'plugins/**/*.tsx'],
|
||||
rules: {
|
||||
'no-restricted-imports': [
|
||||
'error',
|
||||
{
|
||||
...restrictedImportsUniversalErrorConfig,
|
||||
paths: [
|
||||
...restrictedImportsUniversalErrorConfig.paths,
|
||||
// Ban Node.js API
|
||||
'async_hooks',
|
||||
{
|
||||
name: 'child_process',
|
||||
message:
|
||||
"Node APIs are not allowed. Use 'getFlipperLib().remoteServerContext.child_process' from 'flipper-plugin' instead. See https://fbflipper.com/docs/extending/flipper-plugin/.",
|
||||
},
|
||||
'cluster',
|
||||
'crypto',
|
||||
'dgram',
|
||||
'dns',
|
||||
{
|
||||
name: 'fs',
|
||||
message:
|
||||
"Node APIs are not allowed. Use 'getFlipperLib().remoteServerContext.fs' from 'flipper-plugin' instead. See https://fbflipper.com/docs/extending/flipper-plugin/.",
|
||||
},
|
||||
{
|
||||
name: 'fs-extra',
|
||||
message:
|
||||
"Node APIs are not allowed. Use 'getFlipperLib().remoteServerContext.fs' from 'flipper-plugin' instead. See https://fbflipper.com/docs/extending/flipper-plugin/.",
|
||||
},
|
||||
'http',
|
||||
'https',
|
||||
'net',
|
||||
{
|
||||
name: 'os',
|
||||
message:
|
||||
"Node APIs are not allowed. Use 'getFlipperLib().paths' and 'getFlipperLib().environmentInfo' from 'flipper-plugin' instead. See https://fbflipper.com/docs/extending/flipper-plugin/.",
|
||||
},
|
||||
{
|
||||
name: 'path',
|
||||
message:
|
||||
"Node APIs are not allowed. Use 'path' from 'flipper-plugin' instead. See https://fbflipper.com/docs/extending/flipper-plugin/.",
|
||||
},
|
||||
'stream',
|
||||
],
|
||||
},
|
||||
],
|
||||
'rulesdir/no-restricted-imports-clone': [
|
||||
'warn',
|
||||
{
|
||||
paths: [
|
||||
{
|
||||
name: 'flipper',
|
||||
message:
|
||||
"Direct imports from 'flipper' are deprecated. Import from 'flipper-plugin' instead, which can be tested and distributed stand-alone. See https://fbflipper.com/docs/extending/sandy-migration for more details.",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
// Overide rules for tests and service scripts (postinstall). Allow Node APIs usage there.
|
||||
{
|
||||
files: [
|
||||
'plugins/**/__tests__/*.tsx',
|
||||
'plugins/**/__tests__/*.ts',
|
||||
'plugins/postinstall.ts',
|
||||
// TODO: Remove specific plugin overrides down below
|
||||
'plugins/fb/graphql/data/getQueryFromQueryId.tsx',
|
||||
'plugins/fb/kaios-portal/kaios-debugger-client/client.tsx',
|
||||
'plugins/public/crash_reporter/index.tsx',
|
||||
'plugins/public/crash_reporter/ios-crash-utils.tsx',
|
||||
'plugins/public/reactdevtools/index.tsx',
|
||||
],
|
||||
rules: {
|
||||
'no-restricted-imports': [
|
||||
'error',
|
||||
|
||||
Reference in New Issue
Block a user