find-react-legacy-context-usages
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Find React Legacy Context Usages

The title says it. See sample reports in here and here.

Usage

npx find-react-legacy-context-usages \
    "./src/**/*.{js,jsx,ts,tsx}" \
    --root="./src" \
    --report-file="./legacy-context-usages-report.json"

Options

--root: Root folder for sources where .babelrc exists.

--report-file: Report file output path

Important: Don't forget the double-quotes in path glob.

What's supported?

// ClassProperty
class SampleComponent extends React.Component {
  static contextTypes = {
    darkMode: PropTypes.bool.isRequired,
    isLoggedIn: PropTypes.bool.isRequired,
  };

  static childContextTypes = {
    darkMode: PropTypes.bool.isRequired,
    isLoggedIn: PropTypes.bool.isRequired,
  };
}

// AssignmentExpression
function SampleFunctionalComponent() {}

SampleFunctionalComponent.contextTypes = {
  darkMode: PropTypes.bool.isRequired,
  isLoggedIn: PropTypes.bool.isRequired,
};

SampleFunctionalComponent.childContextTypes = {
  darkMode: PropTypes.bool.isRequired,
  isLoggedIn: PropTypes.bool.isRequired,
};

What's not supported?

class SampleComponent extends React.Component {
  static contextTypes = someStupidVariableContainingTheContextTypes;
  static childContextTypes = someStupidVariableContainingTheChildContextTypes;
}

Readme

Keywords

Package Sidebar

Install

npm i find-react-legacy-context-usages

Weekly Downloads

3,087

Version

1.0.3

License

MIT

Unpacked Size

22.7 kB

Total Files

20

Last publish

Collaborators

  • sidx1024