Socket
Socket
Sign inDemoInstall

unimported

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unimported - npm Package Compare versions

Comparing version 1.30.0 to 1.31.0

2

dist/config.d.ts

@@ -28,2 +28,3 @@ import { ProcessedResult } from './process';

ignoreUnused: string[];
respectGitignore?: boolean;
moduleDirectory?: string[];

@@ -55,2 +56,3 @@ rootDir?: string;

ignoreUnused: string[];
respectGitignore: boolean;
moduleDirectory?: string[];

@@ -57,0 +59,0 @@ rootDir?: string;

23

dist/config.js

@@ -64,3 +64,3 @@ "use strict";

function getConfig(args) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
return __awaiter(this, void 0, void 0, function* () {

@@ -83,15 +83,16 @@ if (cachedConfig) {

ignorePatterns: (_m = (_l = configFile === null || configFile === void 0 ? void 0 : configFile.ignorePatterns) !== null && _l !== void 0 ? _l : preset === null || preset === void 0 ? void 0 : preset.ignorePatterns) !== null && _m !== void 0 ? _m : [],
moduleDirectory: (_o = configFile === null || configFile === void 0 ? void 0 : configFile.moduleDirectory) !== null && _o !== void 0 ? _o : preset === null || preset === void 0 ? void 0 : preset.moduleDirectory,
respectGitignore: (_o = configFile === null || configFile === void 0 ? void 0 : configFile.respectGitignore) !== null && _o !== void 0 ? _o : true,
moduleDirectory: (_p = configFile === null || configFile === void 0 ? void 0 : configFile.moduleDirectory) !== null && _p !== void 0 ? _p : preset === null || preset === void 0 ? void 0 : preset.moduleDirectory,
entryFiles: [],
extensions: [],
assetExtensions: (_p = configFile === null || configFile === void 0 ? void 0 : configFile.assetExtensions) !== null && _p !== void 0 ? _p : [],
pathTransforms: (_q = configFile === null || configFile === void 0 ? void 0 : configFile.pathTransforms) !== null && _q !== void 0 ? _q : preset === null || preset === void 0 ? void 0 : preset.pathTransforms,
scannedDirs: (_s = (_r = configFile === null || configFile === void 0 ? void 0 : configFile.scannedDirs) !== null && _r !== void 0 ? _r : preset === null || preset === void 0 ? void 0 : preset.scannedDirs) !== null && _s !== void 0 ? _s : [],
assetExtensions: (_q = configFile === null || configFile === void 0 ? void 0 : configFile.assetExtensions) !== null && _q !== void 0 ? _q : [],
pathTransforms: (_r = configFile === null || configFile === void 0 ? void 0 : configFile.pathTransforms) !== null && _r !== void 0 ? _r : preset === null || preset === void 0 ? void 0 : preset.pathTransforms,
scannedDirs: (_t = (_s = configFile === null || configFile === void 0 ? void 0 : configFile.scannedDirs) !== null && _s !== void 0 ? _s : preset === null || preset === void 0 ? void 0 : preset.scannedDirs) !== null && _t !== void 0 ? _t : [],
};
const aliases = (_u = (_t = configFile === null || configFile === void 0 ? void 0 : configFile.aliases) !== null && _t !== void 0 ? _t : preset === null || preset === void 0 ? void 0 : preset.aliases) !== null && _u !== void 0 ? _u : {};
const extensions = (_w = (_v = configFile === null || configFile === void 0 ? void 0 : configFile.extensions) !== null && _v !== void 0 ? _v : preset === null || preset === void 0 ? void 0 : preset.extensions) !== null && _w !== void 0 ? _w : [];
const entryFiles = (_y = (_x = configFile === null || configFile === void 0 ? void 0 : configFile.entry) !== null && _x !== void 0 ? _x : preset === null || preset === void 0 ? void 0 : preset.entry) !== null && _y !== void 0 ? _y : [];
const aliases = (_v = (_u = configFile === null || configFile === void 0 ? void 0 : configFile.aliases) !== null && _u !== void 0 ? _u : preset === null || preset === void 0 ? void 0 : preset.aliases) !== null && _v !== void 0 ? _v : {};
const extensions = (_x = (_w = configFile === null || configFile === void 0 ? void 0 : configFile.extensions) !== null && _w !== void 0 ? _w : preset === null || preset === void 0 ? void 0 : preset.extensions) !== null && _x !== void 0 ? _x : [];
const entryFiles = (_z = (_y = configFile === null || configFile === void 0 ? void 0 : configFile.entry) !== null && _y !== void 0 ? _y : preset === null || preset === void 0 ? void 0 : preset.entry) !== null && _z !== void 0 ? _z : [];
// throw if no entry point could be found
if (entryFiles.length === 0) {
throw new Error(`Unable to locate entry points for this ${(_z = preset === null || preset === void 0 ? void 0 : preset.preset) !== null && _z !== void 0 ? _z : ''} project. Please declare them in package.json or .unimportedrc.json`);
throw new Error(`Unable to locate entry points for this ${(_0 = preset === null || preset === void 0 ? void 0 : preset.preset) !== null && _0 !== void 0 ? _0 : ''} project. Please declare them in package.json or .unimportedrc.json`);
}

@@ -111,7 +112,7 @@ for (const entry of entryFiles) {

? entry.aliases
: ((_0 = entry.extend) === null || _0 === void 0 ? void 0 : _0.aliases)
: ((_1 = entry.extend) === null || _1 === void 0 ? void 0 : _1.aliases)
? Object.assign(Object.assign({}, aliases), entry.extend.aliases) : aliases;
const entryExtensions = entry.extensions
? entry.extensions
: ((_1 = entry.extend) === null || _1 === void 0 ? void 0 : _1.extensions)
: ((_2 = entry.extend) === null || _2 === void 0 ? void 0 : _2.extensions)
? [...entry.extend.extensions, ...extensions]

@@ -118,0 +119,0 @@ : extensions;

@@ -121,2 +121,3 @@ "use strict";

ignoreUnresolved: config.ignoreUnresolved,
respectGitignore: config.respectGitignore,
});

@@ -123,0 +124,0 @@ spinner.stop();

@@ -36,2 +36,19 @@ "use strict";

}
function getExpo(options, rootExtensions) {
const expoEntry = options.packageJson.main;
if (!expoEntry) {
return;
}
const [file] = (0, fs_1.resolveFilesSync)([expoEntry], rootExtensions);
if (!file) {
return;
}
return {
file,
label: 'expo',
extend: {
extensions: rootExtensions,
},
};
}
const preset = {

@@ -43,5 +60,7 @@ name: 'react-native',

const extensions = base.extensions;
const hasExpo = options.hasPackage('expo');
const entry = [
getEntry('android', extensions),
getEntry('ios', extensions),
hasExpo ? getExpo(options, extensions) : undefined,
].filter(meta_1.typedBoolean);

@@ -48,0 +67,0 @@ return Object.assign(Object.assign({}, base), { entry, ignoreUnused: [

@@ -11,5 +11,11 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.processResults = void 0;
const ignore_1 = __importDefault(require("ignore"));
const ensureArray_1 = require("./ensureArray");
const path_1 = __importDefault(require("path"));
const fs_1 = require("./fs");
function index(array) {

@@ -26,10 +32,17 @@ return (0, ensureArray_1.ensureArray)(array).reduce((acc, str) => {

const ignoreUnimportedIdx = index(context.config.ignoreUnimported);
const unresolved = Array.from(traverseResult.unresolved).filter(([x]) => !ignoreUnresolvedIdx[x]);
const unresolved = Array.from(traverseResult.unresolved).filter((entry) => !ignoreUnresolvedIdx[entry.toString()]);
const unused = Object.keys(context.dependencies).filter((x) => !traverseResult.modules.has(x) &&
!context.peerDependencies[x] &&
!ignoreUnusedIdx[x]);
const unimported = files
let unimported = files
.filter((x) => !traverseResult.files.has(x))
.map((x) => x.replace(context.cwd + '/', ''))
.filter((x) => !ignoreUnimportedIdx[x]);
if (context.config.respectGitignore && (yield (0, fs_1.exists)('.gitignore'))) {
const gitignore = (yield (0, fs_1.readText)('.gitignore')).split('\n');
const ig = (0, ignore_1.default)().add(gitignore);
unimported = ig
.filter(unimported.map((x) => path_1.default.relative(context.cwd, path_1.default.resolve(context.cwd, x))))
.map((x) => path_1.default.join(context.cwd, x));
}
const formatTypeResultMap = {

@@ -36,0 +49,0 @@ showUnusedFiles: !unimported.length,

{
"name": "unimported",
"version": "1.30.0",
"version": "1.31.0",
"description": "Scans your nodejs project folder and shows obsolete files and modules",

@@ -41,4 +41,4 @@ "main": "./dist/index.js",

"dependencies": {
"@typescript-eslint/parser": "^5.27.1",
"@typescript-eslint/typescript-estree": "^5.27.1",
"@typescript-eslint/parser": "^6.7.3",
"@typescript-eslint/typescript-estree": "^6.7.3",
"chalk": "^4.1.0",

@@ -50,2 +50,3 @@ "cosmiconfig": "^8.3.6",

"glob": "^7.1.6",
"ignore": "^5.2.4",
"json5": "^2.2.0",

@@ -57,3 +58,3 @@ "ora": "^5.3.0",

"term-size": "^2.2.1",
"typescript": "^4.3.5",
"typescript": "^5.2.2",
"yargs": "^16.2.0"

@@ -70,3 +71,3 @@ },

"@types/yargs": "^16.0.0",
"@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"console-testing-library": "0.6.0",

@@ -77,7 +78,7 @@ "eslint": "^7.20.0",

"husky": "^5.1.1",
"jest": "^26.6.3",
"jest": "^29.1.1",
"jest-in-case": "^1.0.2",
"jest-partial": "^1.0.1",
"lint-staged": "^13.2.1",
"nodemon": "^2.0.7",
"nodemon": "^3.0.1",
"patch-package": "^6.4.7",

@@ -87,3 +88,3 @@ "pinst": "^2.1.6",

"rimraf": "^3.0.2",
"ts-jest": "^26.5.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1"

@@ -97,4 +98,4 @@ },

"engines": {
"node": ">=14.0.0"
"node": ">=16.0.0"
}
}

@@ -125,2 +125,3 @@ # unimported

"ignoreUnused": ["bcrypt", "create-emotion"],
"respectGitignore": true,
"scannedDirs": ["./modules"]

@@ -302,2 +303,10 @@ }

In addition `unimported` will also ignore files that match your `.gitignore` patterns. To disable this behavior, set `respectGitignore` to `false` in your `.unimportedrc.json` file.
```json
{
"respectGitignore": false
}
```
## Troubleshooting

@@ -420,2 +429,4 @@

<td align="center" valign="top" width="14.28%"><a href="https://github.com/ritingliudd01"><img src="https://avatars.githubusercontent.com/u/47513914?v=4?s=100" width="100px;" alt="Riting LIU"/><br /><sub><b>Riting LIU</b></sub></a><br /><a href="https://github.com/smeijer/unimported/commits?author=ritingliudd01" title="Code">💻</a> <a href="https://github.com/smeijer/unimported/commits?author=ritingliudd01" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://fritsch.tech/"><img src="https://avatars.githubusercontent.com/u/111692684?v=4?s=100" width="100px;" alt="Lukas Fritsch"/><br /><sub><b>Lukas Fritsch</b></sub></a><br /><a href="https://github.com/smeijer/unimported/commits?author=Fritsch-Tech" title="Code">💻</a> <a href="https://github.com/smeijer/unimported/commits?author=Fritsch-Tech" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/MathiasVandePol"><img src="https://avatars.githubusercontent.com/u/606681?v=4?s=100" width="100px;" alt="Mathias Van de Pol"/><br /><sub><b>Mathias Van de Pol</b></sub></a><br /><a href="https://github.com/smeijer/unimported/commits?author=MathiasVandePol" title="Code">💻</a></td>
</tr>

@@ -422,0 +433,0 @@ </tbody>

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