ESLint custom formatter for CI


#1

When developing Atom packages in ES/Babel I use ESLint for linting as it’s part of Atom CI. The output of ESLint however difference from CoffeeLint. ESLint supports different output formatters. However none that showed the same style as CoffeeLint. So I thought I write my own custom ESLint output formatter, which is supported through the --format command line option. The formatter works great when called from npm eslint -f "./scripts/formatter.js" ..

Now is my concern how can I use a custom formatter in Atom CI (preferably without altering the build-package.sh file)?


#2

The standard solution would be to alter the build-package.sh file. The atom/ci repository contains example templates to help people get off the ground, not something that should be considered inviolate.


#3

I thought the best solution would be to alter the build-package.sh file. :frowning: Hoped it could solved differently.

Would there be any interest from the Atom team in a ESLint formatter with the same output of CoffeeLint (just to keep them the same)? I could make it an NPM package…


#4

What is the benefit of having the output be identical? Mostly readability?


#5

Yes, exactly. I for example was used to CoffeeLint syntax before switching to ESLint recently.


#6

Would you mind opening an Issue on atom/ci for an enhancement and link it here? I’ll see about getting someone to take a look.


#7

Will do. Going to make it an NPM package first.


#8

So I solved it a bit differently. First I created a separate NPM package for the custom formatter. To get the formatter to work I added an extra line to .travis.yml:

sed -i.bak 's/\.bin\/eslint /\.bin\/eslint --format \.\/node_modules\/coffeelint-reporter-style-for-eslint-formatter\/main\.js /g' build-package.sh

This will replace all calls to eslint with a call to eslint with custom formatter (OSX and Linux only). You can see an example of the results here.