Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

precinct

Package Overview
Dependencies
Maintainers
3
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

precinct - npm Package Compare versions

Comparing version 11.0.0 to 11.0.1

135

index.js

@@ -34,3 +34,2 @@ 'use strict';

let dependencies = [];
let ast;

@@ -52,3 +51,3 @@

debug('could not parse content: %s', error.message);
return dependencies;
return [];
}

@@ -64,66 +63,8 @@ // SASS files shouldn't be parsed by Acorn

const type = options.type || getModuleType.fromSource(ast);
const type = options.type ?? getModuleType.fromSource(ast);
debug('module type: %s', type);
let detective;
const mixedMode = options.es6 && options.es6.mixedImports;
const detective = getDetective(type, options);
let dependencies = [];
switch (type) {
case 'cjs':
case 'commonjs': {
detective = mixedMode ? detectiveEs6Cjs : detectiveCjs;
break;
}
case 'css': {
detective = detectivePostcss;
break;
}
case 'amd': {
detective = detectiveAmd;
break;
}
case 'mjs':
case 'esm':
case 'es6': {
detective = mixedMode ? detectiveEs6Cjs : detectiveEs6;
break;
}
case 'sass': {
detective = detectiveSass;
break;
}
case 'less': {
detective = detectiveLess;
break;
}
case 'scss': {
detective = detectiveScss;
break;
}
case 'stylus': {
detective = detectiveStylus;
break;
}
case 'ts': {
detective = detectiveTypeScript;
break;
}
case 'tsx': {
detective = detectiveTypeScript.tsx;
break;
}
default:
// nothing
}
if (detective) {

@@ -136,3 +77,3 @@ dependencies = detective(ast, options[type]);

// For non-JS files that we don't parse
if (detective && detective.ast) {
if (detective?.ast) {
precinct.ast = detective.ast;

@@ -144,9 +85,2 @@ }

function detectiveEs6Cjs(ast, detectiveOptions) {
return [
...detectiveEs6(ast, detectiveOptions),
...detectiveCjs(ast, detectiveOptions)
];
}
/**

@@ -210,2 +144,61 @@ * Returns the dependencies for the given file path

function getDetective(type, options) {
const mixedMode = options.es6?.mixedImports;
switch (type) {
case 'cjs':
case 'commonjs': {
return mixedMode ? detectiveEs6Cjs : detectiveCjs;
}
case 'css': {
return detectivePostcss;
}
case 'amd': {
return detectiveAmd;
}
case 'mjs':
case 'esm':
case 'es6': {
return mixedMode ? detectiveEs6Cjs : detectiveEs6;
}
case 'sass': {
return detectiveSass;
}
case 'less': {
return detectiveLess;
}
case 'scss': {
return detectiveScss;
}
case 'stylus': {
return detectiveStylus;
}
case 'ts': {
return detectiveTypeScript;
}
case 'tsx': {
return detectiveTypeScript.tsx;
}
default:
// nothing
}
}
function detectiveEs6Cjs(ast, detectiveOptions) {
return [
...detectiveEs6(ast, detectiveOptions),
...detectiveCjs(ast, detectiveOptions)
];
}
module.exports = precinct;
{
"name": "precinct",
"version": "11.0.0",
"version": "11.0.1",
"description": "Unleash the detectives",

@@ -77,6 +77,2 @@ "main": "index.js",

],
"complexity": [
"error",
25
],
"curly": [

@@ -86,6 +82,2 @@ "error",

],
"max-nested-callbacks": [
"error",
5
],
"operator-linebreak": [

@@ -107,12 +99,4 @@ "error",

"unicorn/prevent-abbreviations": "off"
},
"overrides": [
{
"files": "test/**",
"envs": [
"mocha"
]
}
]
}
}
}
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