禁用eslint警告

时间:2018-04-26 06:44:38

标签: reactjs eslint eslint-config-airbnb

Anchor用作按钮。锚点主要用于导航。请改用按钮元素。 (JSX-A11Y /锚是有效)的

我想禁用上述警告。

所以我写了

<div data-g-id={this.props.g.id}>
  (// eslint-disable-next-line anchor-is-valid)
  <a
    className='classname'
    href="#"
    data-point="TL"
    onClick={this.callFunction}
   >
</div>

但是上面的那个没有用。

2 个答案:

答案 0 :(得分:4)

使用

class WorkingDayAPI(APIView):

    """
    {   "start":"2018-01-01",
        "end":"2018-05-01"
    }
    GET work days between dates 
    """

    serializer_class = WorkingDaySerializer

    def get(self, request, format=None):
        business_days = WorkingDay.objects.all()
        serializer = WorkingDaySerializer(business_days, many=True)
        return Response(serializer.data)

    def post(self, request, *args, **kwargs):
        start = request.data.get('start')
        end = request.data.get('end')

        # bizdays = request.data.get('bizdays')

        business_days = WorkingDay.objects.create(**request.data)
        business_days.start = start
        business_days.end = end
        business_days.workdays = workdays
        business_days.save()
        serializer = WorkingDaySerializer(business_days)
        return Response(serializer.data, status=status.HTTP_201_CREATED)

而不是{ // eslint-disable-next-line anchor-is-valid } <a ...

答案 1 :(得分:0)

您也可以在.eslintrc文件中全局进行操作:

{
  "rules": {
    "jsx-a11y/anchor-is-valid": 0
  }
}