Skip to content

Commit 1446d0b

Browse files
dart fix --apply --code=unnecessary_new
1 parent e452d16 commit 1446d0b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+249
-249
lines changed

example/geocodes/geocodes.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class _GeocodesResultItem extends react.Component {
4848
/// shortly.
4949
///
5050
/// This is the only correct way to create a [Component]. Do not use the constructor!
51-
var geocodesResultItem = react.registerComponent(() => new _GeocodesResultItem());
51+
var geocodesResultItem = react.registerComponent(() => _GeocodesResultItem());
5252

5353
/// In this component we'll build an HTML `<table>` element full of the `<tr>` elements generated by
5454
/// [_GeocodesResultItem]
@@ -95,7 +95,7 @@ class _GeocodesResultList extends react.Component {
9595
}
9696
}
9797

98-
var geocodesResultList = react.registerComponent(() => new _GeocodesResultList());
98+
var geocodesResultList = react.registerComponent(() => _GeocodesResultList());
9999

100100
/// In this [Component] we'll build a search form.
101101
///
@@ -167,7 +167,7 @@ class _GeocodesForm extends react.Component {
167167
}
168168
}
169169

170-
var geocodesForm = react.registerComponent(() => new _GeocodesForm());
170+
var geocodesForm = react.registerComponent(() => _GeocodesForm());
171171

172172
/// Renders an HTML `<li>` to be used as a child within the [_GeocodesHistoryList].
173173
class _GeocodesHistoryItem extends react.Component {
@@ -189,7 +189,7 @@ class _GeocodesHistoryItem extends react.Component {
189189
}
190190
}
191191

192-
var geocodesHistoryItem = react.registerComponent(() => new _GeocodesHistoryItem());
192+
var geocodesHistoryItem = react.registerComponent(() => _GeocodesHistoryItem());
193193

194194
/// Renders the "history list"
195195
///
@@ -203,7 +203,7 @@ class _GeocodesHistoryList extends react.Component {
203203
{
204204
'key': 'list',
205205
},
206-
new List.from(props['data'].keys.map((key) => geocodesHistoryItem({
206+
List.from(props['data'].keys.map((key) => geocodesHistoryItem({
207207
'key': key,
208208
'query': props['data'][key]['query'],
209209
'status': props['data'][key]['status'],
@@ -214,7 +214,7 @@ class _GeocodesHistoryList extends react.Component {
214214
}
215215
}
216216

217-
var geocodesHistoryList = react.registerComponent(() => new _GeocodesHistoryList());
217+
var geocodesHistoryList = react.registerComponent(() => _GeocodesHistoryList());
218218

219219
/// The root [Component] of our application.
220220
///
@@ -257,7 +257,7 @@ class _GeocodesApp extends react.Component {
257257
// Send the request
258258
var raw = await HttpRequest.getString(path);
259259
// Delay the answer 2 more seconds, for test purposes
260-
await new Future.delayed(new Duration(seconds: 2));
260+
await Future.delayed(Duration(seconds: 2));
261261
// Is this the answer to the last request?
262262
if (id == last_id) {
263263
// If yes, query was `OK` and `shown_addresses` are replaced
@@ -324,7 +324,7 @@ class _GeocodesApp extends react.Component {
324324
}
325325
}
326326

327-
var geocodesApp = react.registerComponent(() => new _GeocodesApp());
327+
var geocodesApp = react.registerComponent(() => _GeocodesApp());
328328

329329
/// And finally, a few magic commands to wire it all up!
330330
///

example/js_components/js_components.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ main() {
1515
react_dom.render(content, querySelector('#content'));
1616
}
1717

18-
var IndexComponent = react.registerComponent2(() => new _IndexComponent());
18+
var IndexComponent = react.registerComponent2(() => _IndexComponent());
1919

2020
class _IndexComponent extends react.Component2 {
2121
SimpleCustomComponent simpleRef;
@@ -98,7 +98,7 @@ external ReactClass get _SimpleCustomComponent;
9898
///
9999
/// This converts the Dart props [Map] passed into it in the
100100
/// the same way props are converted for DOM components.
101-
final SimpleCustom = new ReactJsComponentFactoryProxy(_SimpleCustomComponent);
101+
final SimpleCustom = ReactJsComponentFactoryProxy(_SimpleCustomComponent);
102102

103103
/// JS interop wrapper class for the component,
104104
/// allowing us to interact with component instances
@@ -131,13 +131,13 @@ class MaterialUI {
131131
external Map get theme;
132132

133133
// All the Material UI components converted to dart Components
134-
final Button = new ReactJsComponentFactoryProxy(MaterialUI.Button);
135-
final CssBaseline = new ReactJsComponentFactoryProxy(MaterialUI.CssBaseline);
136-
final Dialog = new ReactJsComponentFactoryProxy(MaterialUI.Dialog);
137-
final DialogActions = new ReactJsComponentFactoryProxy(MaterialUI.DialogActions);
138-
final DialogContent = new ReactJsComponentFactoryProxy(MaterialUI.DialogContent);
139-
final DialogContentText = new ReactJsComponentFactoryProxy(MaterialUI.DialogContentText);
140-
final DialogTitle = new ReactJsComponentFactoryProxy(MaterialUI.DialogTitle);
141-
final Icon = new ReactJsComponentFactoryProxy(MaterialUI.Icon);
142-
final MuiThemeProvider = new ReactJsComponentFactoryProxy(MaterialUI.MuiThemeProvider);
143-
final Typography = new ReactJsComponentFactoryProxy(MaterialUI.Typography);
134+
final Button = ReactJsComponentFactoryProxy(MaterialUI.Button);
135+
final CssBaseline = ReactJsComponentFactoryProxy(MaterialUI.CssBaseline);
136+
final Dialog = ReactJsComponentFactoryProxy(MaterialUI.Dialog);
137+
final DialogActions = ReactJsComponentFactoryProxy(MaterialUI.DialogActions);
138+
final DialogContent = ReactJsComponentFactoryProxy(MaterialUI.DialogContent);
139+
final DialogContentText = ReactJsComponentFactoryProxy(MaterialUI.DialogContentText);
140+
final DialogTitle = ReactJsComponentFactoryProxy(MaterialUI.DialogTitle);
141+
final Icon = ReactJsComponentFactoryProxy(MaterialUI.Icon);
142+
final MuiThemeProvider = ReactJsComponentFactoryProxy(MaterialUI.MuiThemeProvider);
143+
final Typography = ReactJsComponentFactoryProxy(MaterialUI.Typography);

example/test/call_and_nosuchmethod_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class _CustomComponent extends react.Component {
1010
}
1111
}
1212

13-
var customComponent = react.registerComponent(() => new _CustomComponent());
13+
var customComponent = react.registerComponent(() => _CustomComponent());
1414

1515
void main() {
1616
react_dom.render(

example/test/false_and_null_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class _Component extends react.Component {
1414
}
1515
}
1616

17-
var component = react.registerComponent(() => new _Component());
17+
var component = react.registerComponent(() => _Component());
1818

1919
void main() {
2020
var content = react.div({}, [

example/test/get_dom_node_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ customAssert(text, condition) {
1111
throw (text);
1212
}
1313

14-
var ChildComponent = react.registerComponent(() => new _ChildComponent());
14+
var ChildComponent = react.registerComponent(() => _ChildComponent());
1515

1616
class _ChildComponent extends react.Component {
1717
var counter = 0;
@@ -31,7 +31,7 @@ class _ChildComponent extends react.Component {
3131
]);
3232
}
3333

34-
var simpleComponent = react.registerComponent(() => new SimpleComponent());
34+
var simpleComponent = react.registerComponent(() => SimpleComponent());
3535

3636
class SimpleComponent extends react.Component {
3737
var refToSpan;

example/test/order_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class _Item extends react.Component {
1919
}
2020
}
2121

22-
var item = react.registerComponent(() => new _Item());
22+
var item = react.registerComponent(() => _Item());
2323

2424
class _List extends react.Component {
2525
var items = ['item1', 'item2', 'item3'];
@@ -34,7 +34,7 @@ class _List extends react.Component {
3434
}
3535
}
3636

37-
var list = react.registerComponent(() => new _List());
37+
var list = react.registerComponent(() => _List());
3838

3939
void main() {
4040
react_dom.render(list({}), querySelector('#content'));

example/test/react_test_components.dart

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class _HelloComponent extends react.Component2 {
2121
}
2222
}
2323

24-
var helloComponent = react.registerComponent(() => new _HelloComponent());
24+
var helloComponent = react.registerComponent(() => _HelloComponent());
2525

2626
class _HelloGreeter extends react.Component {
2727
var myInput;
@@ -47,7 +47,7 @@ class _HelloGreeter extends react.Component {
4747
}
4848
}
4949

50-
var helloGreeter = react.registerComponent(() => new _HelloGreeter());
50+
var helloGreeter = react.registerComponent(() => _HelloGreeter());
5151

5252
class _CheckBoxComponent extends react.Component {
5353
getInitialState() => {"checked": false};
@@ -77,7 +77,7 @@ class _CheckBoxComponent extends react.Component {
7777
}
7878
}
7979

80-
var checkBoxComponent = react.registerComponent(() => new _CheckBoxComponent());
80+
var checkBoxComponent = react.registerComponent(() => _CheckBoxComponent());
8181

8282
class _ClockComponent extends react.Component {
8383
Timer timer;
@@ -87,7 +87,7 @@ class _ClockComponent extends react.Component {
8787
Map getDefaultProps() => {'refreshRate': 1000};
8888

8989
void componentWillMount() {
90-
timer = new Timer.periodic(new Duration(milliseconds: this.props["refreshRate"]), this.tick);
90+
timer = Timer.periodic(Duration(milliseconds: this.props["refreshRate"]), this.tick);
9191
}
9292

9393
void componentWillUnmount() {
@@ -120,12 +120,12 @@ class _ClockComponent extends react.Component {
120120
}
121121
}
122122

123-
var clockComponent = react.registerComponent(() => new _ClockComponent());
123+
var clockComponent = react.registerComponent(() => _ClockComponent());
124124

125125
class _ListComponent extends react.Component {
126126
Map getInitialState() {
127127
return {
128-
"items": new List.from([0, 1, 2, 3])
128+
"items": List.from([0, 1, 2, 3])
129129
};
130130
}
131131

@@ -144,7 +144,7 @@ class _ListComponent extends react.Component {
144144
int iterator = 3;
145145

146146
void addItem(event) {
147-
List items = new List.from(state["items"]);
147+
List items = List.from(state["items"]);
148148
items.add(++iterator);
149149
setState({"items": items});
150150
}
@@ -167,15 +167,15 @@ class _ListComponent extends react.Component {
167167
}
168168
}
169169

170-
var listComponent = react.registerComponent(() => new _ListComponent());
170+
var listComponent = react.registerComponent(() => _ListComponent());
171171

172172
class _MainComponent extends react.Component {
173173
render() {
174174
return react.div({}, props['children']);
175175
}
176176
}
177177

178-
var mainComponent = react.registerComponent(() => new _MainComponent());
178+
var mainComponent = react.registerComponent(() => _MainComponent());
179179

180180
/////
181181
// REACT OLD CONTEXT COMPONENTS
@@ -210,7 +210,7 @@ class _LegacyContextComponent extends react.Component {
210210
}
211211
}
212212

213-
var legacyContextComponent = react.registerComponent(() => new _LegacyContextComponent());
213+
var legacyContextComponent = react.registerComponent(() => _LegacyContextComponent());
214214

215215
class _LegacyContextConsumerComponent extends react.Component {
216216
@override
@@ -229,7 +229,7 @@ class _LegacyContextConsumerComponent extends react.Component {
229229
}
230230
}
231231

232-
var legacyContextConsumerComponent = react.registerComponent(() => new _LegacyContextConsumerComponent());
232+
var legacyContextConsumerComponent = react.registerComponent(() => _LegacyContextConsumerComponent());
233233

234234
class _GrandchildLegacyContextConsumerComponent extends react.Component {
235235
@override
@@ -246,7 +246,7 @@ class _GrandchildLegacyContextConsumerComponent extends react.Component {
246246
}
247247

248248
var grandchildLegacyContextConsumerComponent =
249-
react.registerComponent(() => new _GrandchildLegacyContextConsumerComponent());
249+
react.registerComponent(() => _GrandchildLegacyContextConsumerComponent());
250250

251251
////
252252
// REACT NEW CONTEXT COMPONENTS
@@ -261,7 +261,7 @@ class _NewContextRefComponent extends react.Component2 {
261261
}
262262
}
263263

264-
var newContextRefComponent = react.registerComponent(() => new _NewContextRefComponent());
264+
var newContextRefComponent = react.registerComponent(() => _NewContextRefComponent());
265265

266266
int calculateChangedBits(currentValue, nextValue) {
267267
int result = 1 << 1;
@@ -342,7 +342,7 @@ class _NewContextProviderComponent extends react.Component2 {
342342
}
343343
}
344344

345-
var newContextProviderComponent = react.registerComponent(() => new _NewContextProviderComponent());
345+
var newContextProviderComponent = react.registerComponent(() => _NewContextProviderComponent());
346346

347347
class _NewContextConsumerComponent extends react.Component2 {
348348
render() {
@@ -359,7 +359,7 @@ class _NewContextConsumerComponent extends react.Component2 {
359359
}
360360
}
361361

362-
var newContextConsumerComponent = react.registerComponent(() => new _NewContextConsumerComponent());
362+
var newContextConsumerComponent = react.registerComponent(() => _NewContextConsumerComponent());
363363

364364
class _NewContextConsumerObservedBitsComponent extends react.Component2 {
365365
render() {
@@ -377,7 +377,7 @@ class _NewContextConsumerObservedBitsComponent extends react.Component2 {
377377
}
378378

379379
var newContextConsumerObservedBitsComponent =
380-
react.registerComponent(() => new _NewContextConsumerObservedBitsComponent());
380+
react.registerComponent(() => _NewContextConsumerObservedBitsComponent());
381381

382382
class _NewContextTypeConsumerComponent extends react.Component2 {
383383
@override
@@ -402,7 +402,7 @@ class _Component2TestComponent extends react.Component2 with react.TypedSnapshot
402402
final prevItems = prevState['items'];
403403
if (prevItems.isEmpty || prevItems[0] != 3) {
404404
return ({
405-
'items': new List.from([3, 1, 2, 0])
405+
'items': List.from([3, 1, 2, 0])
406406
});
407407
}
408408
return null;
@@ -425,13 +425,13 @@ class _Component2TestComponent extends react.Component2 with react.TypedSnapshot
425425
}
426426

427427
void removeItem(event) {
428-
List items = new List.from(state["items"]);
428+
List items = List.from(state["items"]);
429429
items.removeAt(items.length - 1);
430430
setState({"items": items});
431431
}
432432

433433
void addItem(event) {
434-
List items = new List.from(state["items"]);
434+
List items = List.from(state["items"]);
435435
items.add(items.length);
436436
setState({"items": items});
437437
}
@@ -463,13 +463,13 @@ class _Component2TestComponent extends react.Component2 with react.TypedSnapshot
463463
}
464464
}
465465

466-
var newContextTypeConsumerComponentComponent = react.registerComponent(() => new _NewContextTypeConsumerComponent());
467-
var component2TestComponent = react.registerComponent(() => new _Component2TestComponent());
466+
var newContextTypeConsumerComponentComponent = react.registerComponent(() => _NewContextTypeConsumerComponent());
467+
var component2TestComponent = react.registerComponent(() => _Component2TestComponent());
468468

469469
class _ErrorComponent extends react.Component2 {
470470
void componentDidMount() {
471471
if (!props["errored"]) {
472-
throw new _CustomException("It broke!", 2);
472+
throw _CustomException("It broke!", 2);
473473
}
474474
}
475475

@@ -481,7 +481,7 @@ class _ErrorComponent extends react.Component2 {
481481
}
482482
}
483483

484-
var ErrorComponent = react.registerComponent(() => new _ErrorComponent());
484+
var ErrorComponent = react.registerComponent(() => _ErrorComponent());
485485

486486
class _CustomException implements Exception {
487487
int code;
@@ -563,4 +563,4 @@ class _Component2ErrorTestComponent extends react.Component2 {
563563
}
564564
}
565565

566-
var component2ErrorTestComponent = react.registerComponent(() => new _Component2ErrorTestComponent(), ['render']);
566+
var component2ErrorTestComponent = react.registerComponent(() => _Component2ErrorTestComponent(), ['render']);

example/test/ref_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "package:react/react.dart" as react;
55
import "package:react/react_dom.dart" as react_dom;
66
import "package:react/react_client.dart";
77

8-
var ChildComponent = react.registerComponent(() => new _ChildComponent());
8+
var ChildComponent = react.registerComponent(() => _ChildComponent());
99

1010
class _ChildComponent extends react.Component {
1111
int somevalue = 10;
@@ -66,7 +66,7 @@ var ChildComponentForm = react.forwardRef2((props, ref) {
6666
]);
6767
}, displayName: 'ChildComponentForm');
6868

69-
var ParentComponent = react.registerComponent(() => new _ParentComponent());
69+
var ParentComponent = react.registerComponent(() => _ParentComponent());
7070

7171
class _ParentComponent extends react.Component {
7272
// String refs

0 commit comments

Comments
 (0)