clutchski / coffeelint

Lint your CoffeeScript.
http://www.coffeelint.org
Other
1.18k stars 171 forks source link

import is reserved word #536

Closed hoIIer closed 8 years ago

hoIIer commented 8 years ago

Hello, I am trying out coffeelint with my ember-cli project and have an error being thrown for the es6 import in my files... How can I have coffeelint ignore this?

image

import Ember from 'ember'
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin'

SettingsRoute = Ember.Route.extend AuthenticatedRouteMixin,
  beforeModel: (transition)->
    # If the user is not authenticated, send them to the homepage.
    if not @session.isAuthenticated
      @transitionTo 'index'
    ...
AsaAyers commented 8 years ago

CoffeeScript doesn't support ES6 modules, so what have there is a syntax error.

If CoffeeScript won't parse it there's no way CoffeeLint is going to lint it. If somehow your code does compile because you're using some fork of CoffeeScript you can try https://github.com/clutchski/coffeelint/blob/master/doc/user.md#what-about-different-flavors-of-coffeescript-like-icedcoffeescript

ChrisOelmueller commented 6 years ago

Just checking in here now that CoffeeScript does in fact support ES6 modules for about a year. What steps would I need to take in order to convince my linter it's all gonna be okay? ;-)

@AsaAyers
I'd be grateful for pointers regarding proper syntax support, or silencing this very specific check. Easiest solution probably involves telling Coffeelint about the CS version I'd prefer it to use?

AsaAyers commented 6 years ago

@swang runs this project now.

My sincere suggestion is to use http://decaffeinate-project.org/ to move any project you have to JavaScript, and then replace CoffeeScript with https://babeljs.io/, and replace CoffeeLint with https://eslint.org/. There just aren't many benefits to using CoffeeScript vs JavaScript with Babel. See You don't need CoffeeScript for more details.

If you install CoffeeLint and CoffeeScript locally (npm install --save-dev coffeelint coffee-script), then CoffeeLint will use that local CoffeeScript.

ChrisOelmueller commented 6 years ago

Coffeescript 2 is published on NPM under coffeescript without the dash to not cause accidental upgrades between versions 1 and 2. Unfortunately, that means it is not picked up automatically by Coffeelint as far as I can tell.

I guess I was asking for an easy way to configure which executable to use!

edit
To clarify, I'm seeing this with both coffeescript and coffee-script packages installed globally (for various projects I require either 1 or 2 be present) and with coffeelint installed globally under a different --prefix.