GithubHelp home page GithubHelp logo

Parsing error: Unexpected token = eslint because of the airbnb style configuration in React-Redux project about linters-config HOT 2 CLOSED

microverseinc avatar microverseinc commented on August 16, 2024
Parsing error: Unexpected token = eslint because of the airbnb style configuration in React-Redux project

from linters-config.

Comments (2)

MauricioRobayo avatar MauricioRobayo commented on August 16, 2024 1

You are using the experimental public class fields syntax, which is a proposal in stage 3, not yet in the language.

As you notice, you are able to use it because you are using Babel which will transform it for you. That's why ESLint complains, I don't think it is an Airbnb styleguide issue, is just that it is not in the language yet, and you have to use the babel-eslint parser to avoid the issue with ESLint.

The way to do it using ES6 classes is documented on the React docs.

You have to bind your class methods on the constructor, something like this:

export class Searchform extends Component {
+  constructor(props) {
+    super(props);
+    this.onChange = this.onChange.bind(this);
+    this.onSubmit = this.onSubmit.bind(this);
+  }

-   onChange = event => {
+   onChange(event) {
    // ...
  }

-   onChange = event => {
+   onSubmit(event) {
    // ...
  }

You can check here the difference between the experimental feature and the ES6 classes.

from linters-config.

 avatar commented on August 16, 2024 1

That solved the issue, however other linting errors raised instead, being "destructuring assignment" the most annoying.

It would be great if you guys remove the Airbnb style from the official linting files. Personally, I work with "eslint-recommended" along with prettier and resulting code is beautifully.

Don't take wrong, but for me projects from Microverse are really frustrating most of the time because of the linting style implemented which causes hours of time used in fixing linting errors instead of learning something more productive.

Thank you for your suppor @MauricioRobayo!

from linters-config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.