Socket
Socket
Sign inDemoInstall

@iadvize-oss/eslint-patch

Package Overview
Dependencies
Maintainers
12
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iadvize-oss/eslint-patch - npm Package Compare versions

Comparing version 0.0.1-beta.0 to 0.0.1-beta.0-canary-438ce57-1582016057742

49

index.js

@@ -0,6 +1,29 @@

/* eslint-disable import/no-dynamic-require, no-underscore-dangle */
// This is a workaround for https://github.com/eslint/eslint/issues/3458
// @see https://github.com/eslint/eslint/issues/3458#issuecomment-516716165
const path = require('path');
const eslintFolder = path.join(path.dirname(require.resolve('eslint')), '..');
let currentModule = module;
while (
!/[\\/]eslint[\\/]lib[\\/]cli-engine[\\/]config-array-factory\.js/i.test(
currentModule.filename,
)
) {
if (!currentModule.parent) {
// This was tested with ESLint 6.1.0; other versions may not work
throw new Error(
'Failed to patch ESLint because the calling module was not recognized',
);
}
currentModule = currentModule.parent;
}
const eslintFolder = path.join(path.dirname(currentModule.filename), '../..');
const configArrayFactoryPath = path.join(
eslintFolder,
'lib/cli-engine/config-array-factory',
);
const configArrayFactoryModule = require(configArrayFactoryPath);
const moduleResolverPath = path.join(

@@ -10,11 +33,21 @@ eslintFolder,

);
// eslint-disable-next-line import/no-dynamic-require
const ModuleResolver = require(moduleResolverPath);
ModuleResolver.resolve = function(moduleName) {
// const p = require(`${moduleName}/package.json`)
const modulePath = require.resolve(moduleName);
return modulePath;
const originalLoadPlugin =
configArrayFactoryModule.ConfigArrayFactory.prototype._loadPlugin;
configArrayFactoryModule.ConfigArrayFactory.prototype._loadPlugin = function(
name,
importerPath,
) {
const originalResolve = ModuleResolver.resolve;
try {
ModuleResolver.resolve = function(moduleName) {
// resolve using importerPath instead of relativeToPath
return originalResolve.call(this, moduleName, importerPath);
};
// eslint-disable-next-line prefer-rest-params
return originalLoadPlugin.apply(this, arguments);
} finally {
ModuleResolver.resolve = originalResolve;
}
};

2

package.json
{
"name": "@iadvize-oss/eslint-patch",
"version": "0.0.1-beta.0",
"version": "0.0.1-beta.0-canary-438ce57-1582016057742",
"description": "Workaround for eslint plugin resolution",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,3 +10,3 @@ # @iadvize/eslint-patch

```bash
npm add --dev @iadvize-oss/eslint-patch
npm add --save-dev @iadvize-oss/eslint-patch
```

@@ -13,0 +13,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc