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

react-docgen

Package Overview
Dependencies
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-docgen - npm Package Compare versions

Comparing version 5.4.1 to 5.4.2

bin/__tests__/example/Component.js

2

bin/__tests__/example/customResolver.js

@@ -21,3 +21,3 @@ /**

module.exports = function(ast, parser) {
module.exports = function (ast, parser) {
return new NodePath(parser.parse(code)).get(

@@ -24,0 +24,0 @@ 'program',

@@ -13,3 +13,3 @@ /**

displayName: 'ComponentA',
render: function() {
render: function () {
// ...

@@ -21,5 +21,5 @@ },

displayName: 'ComponentB',
render: function() {
render: function () {
// ...
},
});

@@ -38,5 +38,3 @@ /**

const component = fs.readFileSync(
path.join(__dirname, '../../example/components/Component.js'),
);
const component = fs.readFileSync(path.join(__dirname, 'example/Component.js'));

@@ -250,11 +248,11 @@ describe('react-docgen CLI', () => {

// No option passed: same as --resolver=findExportedComponentDefinition
run([
path.join(__dirname, '../../example/components/Component.js'),
]).then(([stdout]) => {
expect(stdout).toContain('Component');
}),
run([path.join(__dirname, 'example/Component.js')]).then(
([stdout]) => {
expect(stdout).toContain('Component');
},
),
run([
'--resolver=findExportedComponentDefinition',
path.join(__dirname, '../../example/components/Component.js'),
path.join(__dirname, 'example/Component.js'),
]).then(([stdout]) => {

@@ -266,3 +264,3 @@ expect(stdout).toContain('Component');

'--resolver=findAllComponentDefinitions',
path.join(__dirname, './example/MultipleComponents.js'),
path.join(__dirname, 'example/MultipleComponents.js'),
]).then(([stdout]) => {

@@ -283,3 +281,3 @@ expect(stdout).toContain('ComponentA');

'--resolver=' + path.join(__dirname, 'example/customResolver.js'),
path.join(__dirname, '../../example/components/Component.js'),
path.join(__dirname, 'example/Component.js'),
]).then(([stdout]) => {

@@ -286,0 +284,0 @@ expect(stdout).toContain('Custom');

@@ -140,3 +140,3 @@ #!/usr/bin/env node

},
function(error, content, filename, next) {
function (error, content, filename, next) {
if (error) {

@@ -152,3 +152,3 @@ throw error;

},
function(error) {
function (error) {
if (error) {

@@ -175,10 +175,10 @@ throw error;

process.stdin.resume();
const timer = setTimeout(function() {
const timer = setTimeout(function () {
process.stderr.write('Still waiting for std input...');
}, 5000);
process.stdin.on('data', function(chunk) {
process.stdin.on('data', function (chunk) {
clearTimeout(timer);
source += chunk;
});
process.stdin.on('end', function() {
process.stdin.on('end', function () {
try {

@@ -197,4 +197,4 @@ writeResult(parse(source));

paths,
function(filePath, done) {
fs.stat(filePath, function(error, stats) {
function (filePath, done) {
fs.stat(filePath, function (error, stats) {
if (error) {

@@ -223,3 +223,3 @@ writeError(error, filePath);

},
function() {
function () {
const resultsPaths = Object.keys(result);

@@ -231,3 +231,3 @@ if (resultsPaths.length === 0) {

// a single path?
fs.stat(paths[0], function(error, stats) {
fs.stat(paths[0], function (error, stats) {
writeResult(stats.isDirectory() ? result : result[resultsPaths[0]]);

@@ -234,0 +234,0 @@ });

@@ -66,7 +66,6 @@ "use strict";

function getStatelessPropsPath(componentDefinition) {
const value = (0, _resolveToValue.default)(componentDefinition);
let value = (0, _resolveToValue.default)(componentDefinition);
if ((0, _isReactForwardRefCall.default)(value)) {
const inner = (0, _resolveToValue.default)(value.get('arguments', 0));
return inner.get('params', 0);
value = (0, _resolveToValue.default)(value.get('arguments', 0));
}

@@ -73,0 +72,0 @@

@@ -55,3 +55,7 @@ "use strict";

_astTypes.namedTypes.MemberExpression.check(value.node) && _astTypes.namedTypes.Identifier.check(value.get('property').node) && value.get('property').node.name === name || // `import { createElement } from 'react'`
_astTypes.namedTypes.ImportDeclaration.check(value.node) && value.node.specifiers.some(specifier => specifier.imported && specifier.imported.name === name)) {
_astTypes.namedTypes.ImportDeclaration.check(value.node) && value.node.specifiers.some(specifier => {
var _specifier$imported, _specifier$local;
return ((_specifier$imported = specifier.imported) === null || _specifier$imported === void 0 ? void 0 : _specifier$imported.name) === name && ((_specifier$local = specifier.local) === null || _specifier$local === void 0 ? void 0 : _specifier$local.name) === path.node.callee.name;
})) {
const module = (0, _resolveToModule.default)(value);

@@ -58,0 +62,0 @@ return Boolean(module && (0, _isReactModuleName.default)(module));

@@ -12,4 +12,2 @@ "use strict";

var _match = _interopRequireDefault(require("./match"));
var _resolveToModule = _interopRequireDefault(require("./resolveToModule"));

@@ -40,5 +38,3 @@

if (!(0, _match.default)(path.node, {
type: 'CallExpression'
})) {
if (!_astTypes.namedTypes.CallExpression.check(path.node)) {
return false;

@@ -45,0 +41,0 @@ }

{
"name": "react-docgen",
"version": "5.4.1",
"version": "5.4.2",
"description": "A CLI and toolkit to extract information from React components for documentation generation.",

@@ -25,3 +25,2 @@ "repository": {

"build": "rimraf dist/ && babel src/ --out-dir dist/ --ignore **/__tests__,**/__mocks__,**/src/types.js",
"build:website": "cd website/ && yarn && yarn build",
"lint": "eslint . --report-unused-disable-directives",

@@ -31,3 +30,2 @@ "fix": "eslint . --fix --report-unused-disable-directives",

"preversion": "yarn lint",
"start": "cd website && yarn && yarn start",
"test": "jest",

@@ -58,21 +56,19 @@ "test:ci": "yarn lint && yarn flow && yarn test --runInBand",

"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.6",
"@babel/preset-flow": "^7.7.4",
"babel-eslint": "^10.0.3",
"babel-jest": "^25.1.0",
"benchmark": "^2.1.4",
"cli-table": "^0.3.1",
"cross-spawn": "^7.0.1",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-prettier": "^3.1.1",
"flow-bin": "^0.98.0",
"jest": "^25.1.0",
"jest-diff": "^25.1.0",
"jest-matcher-utils": "^25.1.0",
"prettier": "^1.19.1",
"rimraf": "^3.0.0",
"temp": "^0.9.1"
"@babel/cli": "7.17.10",
"@babel/eslint-parser": "7.18.2",
"@babel/plugin-transform-runtime": "7.18.5",
"@babel/preset-env": "7.18.2",
"@babel/preset-flow": "7.17.12",
"babel-jest": "28.1.1",
"cross-spawn": "7.0.3",
"eslint": "8.17.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.0.0",
"flow-bin": "0.180.0",
"jest": "28.1.1",
"jest-diff": "28.1.1",
"jest-matcher-utils": "28.1.1",
"prettier": "2.6.2",
"rimraf": "3.0.2",
"temp": "0.9.4"
},

@@ -79,0 +75,0 @@ "jest": {

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