ember-cli-coffeescript icon indicating copy to clipboard operation
ember-cli-coffeescript copied to clipboard

Support for coffeelint custom rules

Open jsec opened this issue 10 years ago • 5 comments

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?

jsec avatar Jun 23 '15 19:06 jsec

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?

kimroen avatar Jun 23 '15 20:06 kimroen

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.

jsec avatar Jun 23 '15 20:06 jsec

@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.

spinlock99 avatar Jul 17 '15 23:07 spinlock99

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.

kimroen avatar Nov 22 '15 19:11 kimroen

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

jsec avatar Nov 23 '15 15:11 jsec