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

jsx-info

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsx-info - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

__tests__/__snapshots__/api.test.ts.snap

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# v2.1.1
- Fixes a bug where prop usage wasn't collected
# v2.1.0

@@ -2,0 +6,0 @@

16

dist/package.json
{
"name": "jsx-info",
"version": "2.1.0",
"version": "2.1.1",
"description": "displays a report of JSX component and prop usage",

@@ -8,8 +8,12 @@ "main": "dist/src/api.js",

"scripts": {
"prepack": "rm -rf dist && tsc",
"preversion": "npm test",
"prepack": "rimraf dist && tsc",
"preversion": "npm run eslint && npm run prettier && npm test",
"postversion": "git push && git push --tags && npm publish",
"start": "tsc --watch",
"upgrade": "npm-check --update",
"test": "eslint src --ext .js,.ts --format unix && prettier --check \"src/**/*.{js,ts}\""
"lint": "npm run eslint && npm run prettier",
"eslint": "eslint src --ext .js,.ts --format unix",
"prettier": "prettier --check \"src/**/*.{js,ts}\"",
"test": "jest",
"test:watch": "jest --watch"
},

@@ -46,6 +50,10 @@ "repository": {

"eslint": "^7.12.1",
"jest": "^26.6.3",
"npm-check": "^5.9.2",
"prettier": "^2.1.2",
"rimraf": "^3.0.2",
"ts-jest": "^26.4.4",
"ts-node": "^9.1.1",
"typescript": "^4.0.5"
}
}

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

const globby_1 = __importDefault(require("globby"));
const path_1 = __importDefault(require("path"));
const sleep_1 = require("./sleep");

@@ -32,11 +33,18 @@ /**

*/
function analyze({ babelPlugins = [], components, directory, files = ["**/*.{js,jsx,tsx}"], gitignore = true, ignore = [], onFile, prop: searchProp = "", }) {
function analyze({ babelPlugins = [], components, directory = process.cwd(), files = ["**/*.{js,jsx,tsx}"], gitignore = true, ignore = [], onFile, prop = "", relativePaths = false, }) {
return __awaiter(this, void 0, void 0, function* () {
function processFilename(filename) {
if (relativePaths) {
return filename;
}
return path_1.default.resolve(directory, filename);
}
const searchProp = prop;
const timeStart = Date.now();
const filenames = yield globby_1.default(files || "**/*.{js,jsx,tsx}", {
absolute: true,
absolute: !relativePaths,
onlyFiles: true,
gitignore,
ignore,
cwd: directory || process.cwd(),
cwd: directory,
});

@@ -46,3 +54,3 @@ const reporter = new Reporter();

if (onFile) {
yield onFile(filename);
yield onFile(processFilename(filename));
}

@@ -53,3 +61,3 @@ else {

try {
const code = fs_1.default.readFileSync(filename, "utf8");
const code = fs_1.default.readFileSync(path_1.default.resolve(directory, filename), "utf8");
parse(code, {

@@ -87,3 +95,3 @@ babelPlugins,

prettyCode: formatPrettyCode(code, node.loc.start.line, node.loc.end.line),
filename,
filename: processFilename(filename),
});

@@ -110,3 +118,3 @@ }

}
if (prop.propName !== wantPropKey) {
if (wantPropKey && prop.propName !== wantPropKey) {
return;

@@ -122,3 +130,3 @@ }

prettyCode: formatPrettyCode(code, prop.startLoc.line, prop.endLoc.line),
filename,
filename: processFilename(filename),
});

@@ -132,3 +140,3 @@ }

if (error instanceof SyntaxError) {
reporter.addParseError(filename, error);
reporter.addParseError(processFilename(filename), error);
}

@@ -151,2 +159,3 @@ else {

elapsedTime: elapsedTime,
directory,
};

@@ -153,0 +162,0 @@ });

{
"name": "jsx-info",
"version": "2.1.0",
"version": "2.1.1",
"description": "displays a report of JSX component and prop usage",

@@ -8,8 +8,12 @@ "main": "dist/src/api.js",

"scripts": {
"prepack": "rm -rf dist && tsc",
"preversion": "npm test",
"prepack": "rimraf dist && tsc",
"preversion": "npm run eslint && npm run prettier && npm test",
"postversion": "git push && git push --tags && npm publish",
"start": "tsc --watch",
"upgrade": "npm-check --update",
"test": "eslint src --ext .js,.ts --format unix && prettier --check \"src/**/*.{js,ts}\""
"lint": "npm run eslint && npm run prettier",
"eslint": "eslint src --ext .js,.ts --format unix",
"prettier": "prettier --check \"src/**/*.{js,ts}\"",
"test": "jest",
"test:watch": "jest --watch"
},

@@ -46,6 +50,10 @@ "repository": {

"eslint": "^7.12.1",
"jest": "^26.6.3",
"npm-check": "^5.9.2",
"prettier": "^2.1.2",
"rimraf": "^3.0.2",
"ts-jest": "^26.4.4",
"ts-node": "^9.1.1",
"typescript": "^4.0.5"
}
}

@@ -6,2 +6,3 @@ import { parse as babelParse, ParserPlugin } from "@babel/parser";

import globby from "globby";
import path from "path";
import { sleep } from "./sleep";

@@ -27,2 +28,4 @@

prop?: string;
/** Use relative paths instead of absolute paths */
relativePaths?: boolean;
}

@@ -67,2 +70,3 @@

elapsedTime: number;
directory: string;
}

@@ -83,3 +87,3 @@

components,
directory,
directory = process.cwd(),
files = ["**/*.{js,jsx,tsx}"],

@@ -89,11 +93,19 @@ gitignore = true,

onFile,
prop: searchProp = "",
prop = "",
relativePaths = false,
}: AnalyzeOptions): Promise<Analysis> {
function processFilename(filename: string): string {
if (relativePaths) {
return filename;
}
return path.resolve(directory, filename);
}
const searchProp = prop;
const timeStart = Date.now();
const filenames = await globby(files || "**/*.{js,jsx,tsx}", {
absolute: true,
absolute: !relativePaths,
onlyFiles: true,
gitignore,
ignore,
cwd: directory || process.cwd(),
cwd: directory,
});

@@ -103,3 +115,3 @@ const reporter = new Reporter();

if (onFile) {
await onFile(filename);
await onFile(processFilename(filename));
} else {

@@ -109,3 +121,3 @@ await sleep();

try {
const code = fs.readFileSync(filename, "utf8");
const code = fs.readFileSync(path.resolve(directory, filename), "utf8");
parse(code, {

@@ -148,3 +160,3 @@ babelPlugins,

),
filename,
filename: processFilename(filename),
});

@@ -169,3 +181,3 @@ }

}
if (prop.propName !== wantPropKey) {
if (wantPropKey && prop.propName !== wantPropKey) {
return;

@@ -185,3 +197,3 @@ }

),
filename,
filename: processFilename(filename),
});

@@ -194,3 +206,3 @@ }

if (error instanceof SyntaxError) {
reporter.addParseError(filename, error);
reporter.addParseError(processFilename(filename), error);
} else {

@@ -212,2 +224,3 @@ throw error;

elapsedTime: elapsedTime,
directory,
};

@@ -214,0 +227,0 @@ }

Sorry, the diff of this file is not supported yet

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