A
A
Andrey Okhotnikov2019-04-16 13:55:45
typescript
Andrey Okhotnikov, 2019-04-16 13:55:45

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

2 answer(s)
A
Anton Spirin, 2019-04-16
@tsepen

You need to include tslint and optionally prettier:
tslint.json:

{
  "extends": ["tslint:recommended", "tslint-config-prettier", "tslint-config-airbnb", "tslint-react"],
  /* ... */
}

R
Roman, 2017-02-26
@ZelibobA1706

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)
        {
        }

    }

about ArrangeOverride and MeasureOverride here
and in Xaml
<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>

that's all. now in the model view you will have a collection of chips (like
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;
}

Naturally, you can set properties for the ItemsPerHeight and ItemsPerWidth binding.
everything is simple? a new game? we clear the collection, fill it with new chips (do not forget about the empty one), check for the end of the game, go through the list and look at the elements in order.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question