kimroen / ember-cli-coffeescript

Adds precompilation of CoffeeScript files and all the basic generation types to the ember generate command.
MIT License
72 stars 49 forks source link

Support for coffeelint custom rules #83

Open jsec opened 9 years ago

jsec commented 9 years ago

We're trying to port our app over from brunch to ember-cli, and we have several custom modules that we included in the coffeelint hash of our brunch configuration file. Does the built-in coffeelint include support for custom rules?

kimroen commented 9 years ago

It does not, but it should be just a matter of allowing the user to specify somehow and then pass that along to coffeelint in this file: https://github.com/kimroen/ember-cli-coffeescript/blob/master/lib/coffee-linter.js

I don't have the capacity to check this out further right now unfortunately, but I'd love to help make it happen through a PR.

It should probably be a configuration option of either a glob-pattern for a set of files, or just a folder name. How do you define this using brunch?

jsec commented 9 years ago

We use the coffeelint-brunch plugin. This adds a coffeelint hash where we can then define our lint rules without the need of a coffeelint.json. Here's an excerpt of our config:

    coffeelint:
      options:
        no_stand_alone_at: level: "error"
        space_operators: level: "error"
        no_interpolation_in_single_quotes: level: "error"
        no_unnecessary_fat_arrows: level: 'error'
        no_set_timeout:
          module: "./lint/noSetTimeout"
        no_set_interval:
          module: "./lint/noSetInterval"

The two defined modules at the bottom are what I'm trying to port over. There are two files at noSetTimeout.coffee and noSetInterval.coffee that each export one coffeelint rule. I've tried adapting the same strategy with this addon, but the lint spams my console with an Error loading module noSetTimeout error.

This is something I might be able to help make a PR out of, but I'd need a better idea of what you'd like to see the configuration look like.

spinlock99 commented 9 years ago

@jsec, you can add custom rules to coffeelint.json in almost the same way. Here's a copy of our custom rules:

{
  "change_adstage_require": {
    "level": "error",
    "module": "tools/coffeelint/rules/change_adstage_require.coffee"
  },
  "deprecate_open_notification_bar": {
    "level": "error",
    "module": "tools/coffeelint/rules/deprecate_open_notification_bar.coffee"
  },
  "check_adstage_namespace": {
    "level": "error",
    "module": "tools/coffeelint/rules/check_adstage_namespace.coffee"
  },
....

I'm still upgrading our app to ember-cli so I haven't tested this yet but hopefully that gets you over the hump.

kimroen commented 8 years ago

Hi again,

It's very unlikely that I'll be able to work on this any time soon, so if this is something you need - please feel free to take charge.

jsec commented 8 years ago

I should have some bandwidth opening up between now and the new year, so I might be able take a stab at it.