Socket
Socket
Sign inDemoInstall

eslint-module-utils

Package Overview
Dependencies
9
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.6.2 to 2.7.0

pkgUp.js

17

CHANGELOG.md

@@ -8,2 +8,9 @@ # Change Log

## v2.7.0 - 2021-10-11
### Added
- `fileExistsWithCaseSync`: add `strict` argument ([#1262], thanks [@sergei-startsev])
- add `visit`, to support dynamic imports ([#1660], [#2212], thanks [@maxkomarychev], [@aladdin-add], [@Hypnosphi])
- create internal replacement for `pkg-up` and `read-pkg-up` ([#2047], [@mgwalker])
## v2.6.2 - 2021-08-08

@@ -94,6 +101,9 @@

[#2212]: https://github.com/import-js/eslint-plugin-import/pull/2212
[#2160]: https://github.com/import-js/eslint-plugin-import/pull/2160
[#2047]: https://github.com/import-js/eslint-plugin-import/pull/2047
[#2026]: https://github.com/import-js/eslint-plugin-import/pull/2026
[#1786]: https://github.com/import-js/eslint-plugin-import/pull/1786
[#1671]: https://github.com/import-js/eslint-plugin-import/pull/1671
[#1660]: https://github.com/import-js/eslint-plugin-import/pull/1660
[#1606]: https://github.com/import-js/eslint-plugin-import/pull/1606

@@ -107,2 +117,3 @@ [#1602]: https://github.com/import-js/eslint-plugin-import/pull/1602

[#1290]: https://github.com/import-js/eslint-plugin-import/pull/1290
[#1262]: https://github.com/import-js/eslint-plugin-import/pull/1262
[#1218]: https://github.com/import-js/eslint-plugin-import/pull/1218

@@ -120,2 +131,3 @@ [#1166]: https://github.com/import-js/eslint-plugin-import/issues/1166

[@hulkish]: https://github.com/hulkish
[@Hypnosphi]: https://github.com/Hypnosphi
[@iamnapo]: https://github.com/iamnapo

@@ -125,5 +137,8 @@ [@JounQin]: https://github.com/JounQin

[@manuth]: https://github.com/manuth
[@maxkomarychev]: https://github.com/maxkomarychev
[@mgwalker]: https://github.com/mgwalker
[@pmcelhaney]: https://github.com/pmcelhaney
[@sergei-startsev]: https://github.com/sergei-startsev
[@sompylasar]: https://github.com/sompylasar
[@timkraut]: https://github.com/timkraut
[@vikr01]: https://github.com/vikr01
[@vikr01]: https://github.com/vikr01

4

module-require.js

@@ -21,3 +21,3 @@ 'use strict';

return require(Module._resolveFilename(p, eslintModule));
} catch(err) { /* ignore */ }
} catch (err) { /* ignore */ }

@@ -27,3 +27,3 @@ try {

return require.main.require(p);
} catch(err) { /* ignore */ }
} catch (err) { /* ignore */ }

@@ -30,0 +30,0 @@ // finally, try from here

@@ -40,3 +40,3 @@ 'use strict';

let modulePath;
// refs https://github.com/estree/estree/blob/master/es2020.md#importexpression
// refs https://github.com/estree/estree/blob/HEAD/es2020.md#importexpression
if (node.type === 'ImportExpression') {

@@ -135,3 +135,3 @@ modulePath = node.source;

if (additionalProperties){
if (additionalProperties) {
for (const key in additionalProperties) {

@@ -138,0 +138,0 @@ base.properties[key] = additionalProperties[key];

{
"name": "eslint-module-utils",
"version": "2.6.2",
"version": "2.7.0",
"description": "Core utilities to support eslint-plugin-import and other module-related plugins.",

@@ -30,4 +30,5 @@ "engines": {

"debug": "^3.2.7",
"find-up": "^2.1.0",
"pkg-dir": "^2.0.0"
}
}

@@ -6,5 +6,38 @@ 'use strict';

const extname = require('path').extname;
const fs = require('fs');
const log = require('debug')('eslint-plugin-import:parse');
function getBabelVisitorKeys(parserPath) {
if (parserPath.endsWith('index.js')) {
const hypotheticalLocation = parserPath.replace('index.js', 'visitor-keys.js');
if (fs.existsSync(hypotheticalLocation)) {
const keys = moduleRequire(hypotheticalLocation);
return keys.default || keys;
}
} else if (parserPath.endsWith('index.cjs')) {
const hypotheticalLocation = parserPath.replace('index.cjs', 'worker/ast-info.cjs');
if (fs.existsSync(hypotheticalLocation)) {
const astInfo = moduleRequire(hypotheticalLocation);
return astInfo.getVisitorKeys();
}
}
return null;
}
function keysFromParser(parserPath, parserInstance, parsedResult) {
if (/.*espree.*/.test(parserPath)) {
return parserInstance.VisitorKeys;
}
if (/.*(babel-eslint|@babel\/eslint-parser).*/.test(parserPath)) {
return getBabelVisitorKeys(parserPath);
}
if (/.*@typescript-eslint\/parser/.test(parserPath)) {
if (parsedResult) {
return parsedResult.visitorKeys;
}
}
return null;
}
exports.default = function parse(path, content, context) {

@@ -49,3 +82,8 @@

try {
ast = parser.parseForESLint(content, parserOptions).ast;
const parserRaw = parser.parseForESLint(content, parserOptions);
ast = parserRaw.ast;
return {
ast,
visitorKeys: keysFromParser(parserPath, parser, parserRaw),
};
} catch (e) {

@@ -57,9 +95,20 @@ console.warn();

if (!ast || typeof ast !== 'object') {
console.warn('`parseForESLint` from parser `' + parserPath + '` is invalid and will just be ignored');
console.warn(
'`parseForESLint` from parser `' +
parserPath +
'` is invalid and will just be ignored',
);
} else {
return ast;
return {
ast,
visitorKeys: keysFromParser(parserPath, parser, undefined),
};
}
}
return parser.parse(content, parserOptions);
const keys = keysFromParser(parserPath, parser, undefined);
return {
ast: parser.parse(content, parserOptions),
visitorKeys: keys,
};
};

@@ -66,0 +115,0 @@

@@ -45,3 +45,3 @@ 'use strict';

}
} catch(e) {
} catch (e) {
// If the target does not exist then just return undefined

@@ -56,3 +56,3 @@ return undefined;

// http://stackoverflow.com/a/27382838
exports.fileExistsWithCaseSync = function fileExistsWithCaseSync(filepath, cacheSettings) {
exports.fileExistsWithCaseSync = function fileExistsWithCaseSync(filepath, cacheSettings, strict) {
// don't care if the FS is case-sensitive

@@ -63,3 +63,3 @@ if (CASE_SENSITIVE_FS) return true;

if (filepath === null) return true;
if (filepath.toLowerCase() === process.cwd().toLowerCase()) return true;
if (filepath.toLowerCase() === process.cwd().toLowerCase() && !strict) return true;
const parsedPath = path.parse(filepath);

@@ -79,3 +79,3 @@ const dir = parsedPath.dir;

} else {
result = fileExistsWithCaseSync(dir, cacheSettings);
result = fileExistsWithCaseSync(dir, cacheSettings, strict);
}

@@ -82,0 +82,0 @@ }

'use strict';
exports.__esModule = true;
const pattern = /(^|;)\s*(export|import)((\s+\w)|(\s*[{*=]))/m;
const pattern = /(^|;)\s*(export|import)((\s+\w)|(\s*[{*=]))|import\(/m;
/**

@@ -29,3 +28,3 @@ * detect possible imports/exports without a full parse.

exports.isModule = function isUnambiguousModule(ast) {
return ast.body.some(node => unambiguousNodeType.test(node.type));
return ast.body && ast.body.some(node => unambiguousNodeType.test(node.type));
};
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc