Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const dependencies = dependencyQueryParam.split(',').reduce((acc, curr) => {
const first = curr.slice(0, 1);
// remove the first letter so we don't match stuff like `@expo/` when splitting
const [dep, version] = curr.slice(1).split('@');
const name = first + dep;
if (isModulePreloaded(name, this.props.sdkVersion)) {
return acc;
}
return {
...acc,
[name]: version || null,
};
}, {});
({ name }) =>
// If the dependency is already in props, or is in progress, don't add them
!(
dependencies[name] ||
this.props.dependencies[name] ||
isModulePreloaded(name, this.props.sdkVersion)
)
)
({ name }) =>
// If the dependency is already in props, or is in progress, don't add them
!(
dependencies[name] ||
this.props.dependencies[name] ||
isModulePreloaded(name, this.props.sdkVersion)
)
)
.map((it: any) => {
if (isModulePreloaded(it.key.value, sdkVersion)) {
return {
startLineNumber: it.key.loc.start.line,
endLineNumber: it.key.loc.end.line,
startColumn: it.key.loc.start.column,
endColumn: it.key.loc.end.column,
message: `The package "${
it.key.value
}" can be imported without adding to "dependencies"`,
severity: 3,
source,
};
}
if (
it.value.type !== 'Literal' ||
!(semver.validRange(it.value.value) || it.value.value === 'latest')
.map(it => {
if (isModulePreloaded(it.key.value, sdkVersion)) {
return {
startLineNumber: it.key.loc.start.line,
endLineNumber: it.key.loc.end.line,
startColumn: it.key.loc.start.column,
endColumn: it.key.loc.end.column,
message: `The package "${it.key
.value}" can be imported without adding to "dependencies"`,
severity: 3,
source,
};
}
if (
it.value.type !== 'Literal' ||
!(semver.validRange(it.value.value) || it.value.value === 'latest')
) {
pickBy(deps, (_, name) => !isModulePreloaded(name, this.props.sdkVersion))
);
(acc: { [key: string]: string }, name) => {
if (!isModulePreloaded(name, this.props.sdkVersion)) {
acc[name] = next.dependencies[name];
}
return acc;
},
{}