
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
class-props-codemod
Advanced tools
Transform old-style assigned static properties to class static properties
Transform old-style assigned static properties to class static properties.
$ npm install -g jscodeshift
$ jscodeshift PATH_TO_SOURCE --transform PATH_TO_THIS_MODULE
// BEFORE:
class X {
method1() {}
}
X.foo = 42;
// AFTER:
class X {
static foo = 42;
method1() {}
}
The transform is very conservative:
If there are any other statements between the class definition and the assigned static properties, then it'll skip that class. Example:
// This class will NOT be transformed
class X {}
someOtherStatement;
X.foo = 42;
If any assigned static properties reference the class in the same scope, then it'll skip that class. Example:
// This class will NOT be transformed
class X {}
X.foo = 42;
X.bar = X.baz();
// This class WILL BE transformed
class X {}
X.foo = 42;
X.bar = () => X.baz();
If a static property already exists with a name and a value, then it'll skip that class. If the static property exists, but it doesn't have a value, it will get transformed. Example:
// This class will NOT be transformed
class X {
static foo = 43;
}
X.foo = 42;
// This class WILL BE transformed
class X {
static foo: number;
}
X.foo = 42;
Newly created static properties are added to the class body in the order in which they're found. Either immediately before the first method definition or immediate after the first class property.
FAQs
Transform old-style assigned static properties to class static properties
The npm package class-props-codemod receives a total of 2 weekly downloads. As such, class-props-codemod popularity was classified as not popular.
We found that class-props-codemod demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.