andreogle / eslint-teamcity

A (now deprecated) ESLint formatter plugin for TeamCity. Use eslint-formatter-teamcity instead
MIT License
38 stars 9 forks source link

Only run formatter if on TeamCity? #6

Closed tolu closed 7 years ago

tolu commented 7 years ago

Would it be possible to have this formatter only run if actually running on TeamCity?

I've seen that the jest teamcity reporter does something like this:

const onTeamCity = 'TEAMCITY_VERSION' in process.env;
if(onTeamCity){
    // work the magic
} else {
    // pass to default reporter?
    // require('eslint/lib/formatters/stylish')
}

What do you think?

andreogle commented 7 years ago

What would the purpose of this be?

I don't use jest so don't know exactly how it works but it seems like you setup a configuration in package.json. ESLint is different in that you don't have any preconfigured setup, you just specify the formatter when running ESLint (at least that's the only way I'm aware of).

So, the way I currently do it is to have 2 different npm scripts in package.json - one for regular output, one for TeamCity output:

"lint": "node node_modules/.bin/eslint app/assets/javascripts" and "lint:teamcity": "node node_modules/.bin/eslint app/assets/javascripts -f './node_modules/eslint-teamcity/index.js'"

How are you running ESLint?

I'm open to this, but I'm not quite convinced yet.

tolu commented 7 years ago

I use ESLint just as you do, with two npm scripts. The purpose of my idea was mainly to be able to drop the one script and have the reporter know enough of its surrounding environment to kick in when needed.

But having read your comment I think I see your point.

Jest and ESLint have fundamentally different setup that enables this idea in an easy way for lint, that can have multiple reporters, but might be more of an anti-pattern when it comes to ESLint.

Much of the same thinking, the tool knowing in which context it is run, is part of the Volkswagen, and on a more serious note Fake.

So in the end I'm not sure if this was actually a good idea, it might be more natural if ESLint had your TeamCity reporter builtin and used it as default when running in the TeamCity context.

Thanks for a great reporter and the quick feedback!

andreogle commented 7 years ago

Not a problem at all! Thanks for opening the issue 👍