neutrinojs / neutrino

Create and build modern JavaScript projects with zero initial configuration.
https://neutrinojs.org
Mozilla Public License 2.0
3.94k stars 213 forks source link

`lint` command, eslint and additional linters #612

Closed timkelty closed 6 years ago

timkelty commented 6 years ago

Looking for advice on the best way to add a linters for additional resource types, (e.g. stylelint, htmllint).

@neutrinojs/eslint registers tasks: lint and eslintrc.

When factoring in linters for additional resource types, this can get confusing.

Should the lint command be renamed to eslint? Or - is there some way to register additional calls to the lint command?

Ideally lint would call eslint, stylelint, or any other middlwares that have somehow registered lint commands.

eliperelman commented 6 years ago

You could re-declare the lint command, and call its previous output. We are considering doing this for the WebExtensions linting.

const { lint } = neutrino.commands;

neutrino.register('lint', (...args) => {
  lint(...args);
  // do your thing
});
timkelty commented 6 years ago

👍 I'll try it!

timkelty commented 6 years ago

So I tried your suggestion and it seemed things were getting called recursively (getting Maximum call stack size exceeded).

eliperelman commented 6 years ago

Could you share the code for it so I can try it out?

timkelty commented 6 years ago

@eliperelman here's an example: https://github.com/timkelty/neutrino-dev/blob/stylelint-lint-command/packages/stylelint/index.js#L38-L49

timkelty commented 6 years ago

I think it would be nice to figure this out for 9.x.

It seems to me that the lint command could be renamed to eslint, and then provide a way for multiple middlewares to hook into a shared lint command?

Thoughts @mozilla-neutrino/core-contributors?

edmorley commented 6 years ago

@timkelty Do you mean having a command category (lint) and type (eg eslint) whereby either just the individual type can be run, or the whole category?

timkelty commented 6 years ago

@edmorley that's what I was getting at, and it might be nice, but I'm not sure how helpful it would be.

I think the most immediate clarification would be to rename the lint command to eslint.

edmorley commented 6 years ago

After #852 this issue no longer exists, since there is no lint command. Instead individual eslintrc and stylelintrc output handlers are registered by their respective presets.