airbnb / javascript

JavaScript Style Guide
MIT License
144.96k stars 26.48k forks source link

Can I use jsx with vue instead of react? #1418

Closed sabrinaluo closed 7 years ago

sabrinaluo commented 7 years ago

Hi, I'm using vue2 with jsx, and got below error:

  ✘  https://google.com/#q=react%2Freact-in-jsx-scope      'React' must be in scope when using JSX         
  /Users/sabrina/github/vue-grommet/src/components/button/button.vue:23:15
      return (<Tag></Tag>)

Is it possible to use eslint-plugin-jsx-a11y without react? how should I configure it? thank you.

deecewan commented 7 years ago

this error, without seeing the rest of your code, means that you need to do

import React from 'react';
/* or */
const React = require('react');

Pick the one of those that matches the rest of your structure.

EDIT: Ignore me. You probably want to add the following to your .eslintrc to disable this particular error.

{
  "rules": [{"react/react-in-jsx-scope": 0}]
}
ljharb commented 7 years ago

The airbnb config enables a lot of rules that will probably conflict with using vue - it might be possible to configure eslint-plugin-react, however, to use vue, such that you wouldn't have to disable any (including "react in jsx scope"), using eslint-plugin-react's pragma settings.

Either way, the airbnb config does not support, recommend, or allow vue - https://npmjs.com/eslint-config-airbnb-base is for when you're not using React, and https://npmjs.com/eslint-config-airbnb is intended for React, exclusively.