A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Workiva/over_react_codemod below:

Workiva/over_react_codemod: Codemods to help consumers of over_react automate the migration of UI component code.

Built with dart_codemod.

Codemods to help consumers of over_react automate the migration of UI component code.

Note: this package requires Dart SDK version 2.1.0 to run, but the codemods themselves are designed to run on code that is written for Dart 1.x or 2.x.

dart pub global activate over_react_codemod

Once you've activated this package, you should be able to run whichever codemods you need via pub global run.

Internationalization Codemod

This package provides a intl_message_migration codemod that will modify existing UI component code to make them available for internationalization.

For more information, please see the INTL Message Codemod Readme

The dart2_upgrade codemod that used to be provided by this package is no longer available.

To use it, you'll need over_react_codemod 1.1.0 instead of the latest, which also must be used with Dart 2.1.0:

asdf install dart 2.1.0
asdf shell dart 2.1.0
pub global activate over_react_codemod 1.1.0

Once that's set up, see the dart2_upgrade documentation here: https://github.com/Workiva/over_react_codemod/tree/1.1.0#dart-1-to-dart-2-codemod

Especially in the case where a forwards- and backwards-compatible version of your code is necessary, it can be helpful to be able to check automatically for regressions after having initially migrated your code. Doing so will help prevent accidentally merging code that doesn't meet your compatability expectations.

Each of these codemods can be run in a --fail-on-changes mode that will count the number of changes that would have been suggested and exit with a non-zero exit code if that number is greater than 0.

As an example, adding the following command to your CI process or pre-merge checklist will prevent merging code that is not in the form that is compatible with both Dart 1 and Dart 2:

dart pub global run over_react_codemod:dart2_upgrade --fail-on-changes
Ignoring Codemod Suggestions

Some of the changes provided by the codemods in this package are based on imperfect heuristics (e.g. looking for a specific naming convention) and consequently may be susceptible to false positives. If you hit such a case in your codebase, you can tell the codemod to ignore a certain line by attaching an ignore comment either on the same line or the immediately preceding line.

For example, consider a mixin usage that happens to match the naming convention of ending with StateMixin, but isn't actually an over_react state mixin:

class Foo extends Object with BarStateMixin {}

As is, the dart2_upgrade --backwards-compat codemod would find this code and attempt to change it to:

class Foo extends Object
    with
        BarStateMixin,
        // ignore: mixin_of_non_class, undefined_class
        $BarStateMixin {}

But if BarStateMixin isn't actually an over_react state mixin, then this updated code will fail. To avoid this problem, simply add an // orcm_ignore comment to the mixin type that should be ignored:

class Foo extends Object
    with
        // orcm_ignore
        BarStateMixin {}

This ignore mechanism works with any of the changes that the codemods in this package will try to suggest.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4