Code Monkey home page Code Monkey logo

Comments (7)

txchen avatar txchen commented on August 17, 2024

@vonWolfehaus I thought eslint is designed for es6, but not es5. Besides, riot's default syntax is es5 + tiny es6 like method declaration, I thought it is not going to work. Maybe I am wrong?

from eslint-plugin-riot.

vonWolfehaus avatar vonWolfehaus commented on August 17, 2024

No, eslint only lints es5 by default - you need a plugin to lint es6+. Riot does use the es6 way of declaring functions, but it is optional. So instead of requiring it, it seems prudent to let developers choose whichever linting rules they want. ESLint was designed to be open-ended and not force any particular version of JS - it all depends on the plugins you use with it.

Didn't you try it without that early return and a default eslint installation? What happened?

from eslint-plugin-riot.

txchen avatar txchen commented on August 17, 2024

I don't remember I use some plugin to let eslint lint es6:)
I will have a try to see what will happen, thanks for the suggestion.

from eslint-plugin-riot.

txchen avatar txchen commented on August 17, 2024

@vonWolfehaus

This is my test result:

script (copied from riot official site):

this.items = []

add(e) {
  var input = e.target[0]
  this.items.push(input.value)
  input.value = ''
}

Then use eslint to lint it, I got:

/Users/txchen/localcode/eslinttest/riotes5.js
  3:9  error  Parsing error: Unexpected token {

✖ 1 problem (1 error, 0 warnings)

So I think eslint by default does not support riot's mini es6 syntax, which is not a standard syntax. http://riotjs.com/guide/#tag-syntax

from eslint-plugin-riot.

vonWolfehaus avatar vonWolfehaus commented on August 17, 2024

I didn't expect it to. People will have to use pure es5 with riot in order to use eslint, which I think is the way to go. Otherwise they can add the es6 plugin.

In the meantime, can you add that function syntax to your plugin as a rule? That would solve the issue and make it work out of the box without having to use extra plugins (eg es6).

from eslint-plugin-riot.

txchen avatar txchen commented on August 17, 2024

I don't think a rule can solve the problem, it should be parser problem. Both eslint default parser 'esprima' and 'babel-eslint' does not support riot's mini es6 syntax. And honestly I don't think I have bandwidth to create a parser for that, sorry.

BTW, in the README of this plugin, it is called out that this only support 'es6' script type.

from eslint-plugin-riot.

vonWolfehaus avatar vonWolfehaus commented on August 17, 2024

I know your plugin only supports es6, that's why I created this issue :) Thanks for your time anyway though.

from eslint-plugin-riot.

Related Issues (11)

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.