Answer the question
In order to leave comments, you need to log in
How to connect eslint airbnb to a Typescript project?
I'm building a new React / Typescript project. I want to connect the config from Airbnb to eslint . How to connect it correctly, taking into account the use of TS, so that everything works correctly and what additional plugin to install for React in this case?
Answer the question
In order to leave comments, you need to log in
You need to include tslint and optionally prettier:
tslint.json:
{
"extends": ["tslint:recommended", "tslint-config-prettier", "tslint-config-airbnb", "tslint-react"],
/* ... */
}
The simplest, GridView, in ItemsPanelTemplate, set the panel template. And then you have to rewrite the behavior of the panel. We make a new component, GamePanel, and override ArrangeOverride and MeasureOverride there, add the necessary properties, and so on.
class GamePanel:Panel
{
public int ItemsPerWidth
{
get { return (int)GetValue(ItemWidthProperty); }
set { SetValue(ItemWidthProperty, value); }
}
public static readonly DependencyProperty ItemsPerWidthProperty =
DependencyProperty.Register(nameof(ItemsPerWidth), typeof(int), typeof(GamePanel), new PropertyMetadata(null));
public int ItemsPerHeight
{
get { return (int)GetValue(ItemWidthProperty); }
set { SetValue(ItemWidthProperty, value); }
}
public static readonly DependencyProperty ItemPerHeightProperty =
DependencyProperty.Register(nameof(ItemsPerHeight), typeof(int), typeof(GamePanel), new PropertyMetadata(null));
protected override Size ArrangeOverride(Size finalSize)
{
}
protected override Size MeasureOverride(Size availableSize)
{
}
}
<GridView ItemsSource="{Binding ShopItems}" ItemContainerStyle="{StaticResource ShopGridViewItemExpanded}" Loaded="GridView_Loaded">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<controls:GamePanel ItemsPerWidth="4" ItemsPerHeight="4"></controls:VariableHeightPanel>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<Border ..цвет, заливка.......>
<TextBlock ......тут номер />
</Border>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
public class GameItem
{
public int Id { get;set; }
public string Text { get; set;}
public bool IsEmpty {get; set;}
.... ну и далее, например цвет, картинка и тд.
}
public class ViewModel
{
private readonly ObservableCollection<GameItem> _gameItems = new ObservableCollection<GameItem>();
public ObservableCollection<GameItem> GameItems => return _gameItems;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question