clutchski / coffeelint

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

`extends` config option works only from commandline #570

Open cueedee opened 8 years ago

cueedee commented 8 years ago

When employing the coffeelint API directly instead of through the commandline, passing in a config containing an extends option, it is simply ignored.

coffeelint.lint(
    someFile
    extends: 'coffeelint-config-foobar'
    literate
)

Caught while fully expecting extends to work from grunt-coffeelint.

AsaAyers commented 8 years ago

This was as designed because when using the app you may not have file system access. For example, coffeelint.com uses the api.

I'm mobile, but for what I remember I think there's an undocumented way to solve this.

coffeelint should probably error in this case and require you to pass a processed/complete config.

On Jul 15, 2016 8:07 AM, "David Bouman" notifications@github.com wrote:

When employing the coffeelint API directly instead of through the commandline, passing in a config containing an extends option, it is simply ignored.

coffeelint.lint( someFile extends: 'coffeelint-config-foobar' literate )

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/clutchski/coffeelint/issues/570, or mute the thread https://github.com/notifications/unsubscribe-auth/AAT1h4AyWdbaWT1QKgpN7YjVrubjL7lcks5qV4WLgaJpZM4JNYN_ .

cueedee commented 8 years ago

Does it make sense to get different results between invoking the coffeelint cli versus, say, grunt-coffeelint when both get fed the same coffeelint.json config?

Why not turn it around; make extends work from the coffeelint.lint() API and only error on the rare (?) occasion the API finds itself in a context where it cannot resolve the base config?

To have that error would make perfect sense then and there, and you would be opening up to a very useful use-case for all the times that file system access is simply a given.

AsaAyers commented 8 years ago

configfinder is the way to handle this. Take a look at linter-coffeelint for an example.

CoffeeLint walks up the path looking for a coffeelint.json or a package.json that has a coffeeLint key. If it gets to the root of the filesystem it looks in your home directory for a coffeelint.json. configfinder does all of this work for you and when it finds a file it will flatten it by merging any extends and coffeelint.lint expects a flat configuration.