Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Neutrino lint and ESLint return different results #708

Closed
gir opened this issue Feb 16, 2018 · 1 comment
Closed

Neutrino lint and ESLint return different results #708

gir opened this issue Feb 16, 2018 · 1 comment
Labels
Milestone

Comments

@gir
Copy link

gir commented Feb 16, 2018

Hello,

I'm trying to figure out what's going on here and have been stuck. It seems that when running neutrino lint vs eslint directly, results differ.

I have created a minimal repro here. I am unsure if the problem is with the specific usage of Webpack module resolve (perhaps I use it incorrectly?), a neutrino setup oversight, or a bug. I have quickly tried to trace it through some of the Neutrino source, but don't see anything that jumps out. I also had a look at #380 and #382 but may have missed something.

Essentially I have added src as a module directory to the Webpack config so that I can do something like import foo from 'foo' (note not './foo'). Then I add the directory to import/resolver through ESLint settings so the airbnb-configured import/no-unresolved should not fail.

yarn lint which runs neutrino lint returns errors.
yarn eslint src --ext .js,.jsx returns no errors.

I would expect the two runs to return the same results.

Versions:

neutrino v8.1.1
node v9.5.0
yarn v1.3.2

@neutrinojs/airbnb v8.1.1
@neutrinojs/jest v8.1.1
@neutrinojs/react v8.1.1
@yasinuslu
Copy link

yasinuslu commented Mar 19, 2018

[EDIT] I moved my comment to #747 (comment)

@edmorley edmorley added this to the v9 milestone Apr 27, 2018
eliperelman added a commit that referenced this issue May 23, 2018
… tools (#852)

__Edited to reflect current state of PR.__

Fixes #708.
Fixes #736.
Fixes #870.
Fixes #842.
Closes #773.
Closes #839.
Closes #849.

Outstanding issues to file:

- [x] Update docs to reflect these API changes (#896)
- [x] ~~Determine need for config-loading bins instead of forcing config file boilerplate (still unsure if we should do this because of IDE integration)~~
- [x] Modify stats to produce friendlier build output (#897)

This patch is a work-in-progress, and is quite the overhaul of Neutrino into something different. Right now there is no change to the documentation, which I will change if we decide to move forward with this.

This patch morphs Neutrino into a "preset engine" for transforming managed webpack configuration into a format that can be consumed by other CLI tools. No longer would we wrap external CLI tools like webpack, eslint, jest, karma, mocha, stylelint, etc. Instead, Neutrino could augment these tools by exposing methods for returning usable configuration.

This approach gives the user control of their CLI tool back, and they can programmatically invoke Neutrino to load their configuration, and override however they like:

```bash
webpack --mode production
```

```js
// webpack.config.js
const neutrino = require('neutrino');

// Load with no config overrides:
module.exports = neutrino().webpack();

// Load with config overrides:
module.exports = neutrino().webpack(config => {
  // return whatever config you want
});

// Load with no config overrides using low-level API:
module.exports = neutrino().output('webpack');

// Load with config overrides using low-level API:
module.exports = neutrino().output('webpack', config => {
  // return whatever config you want
});
```

The same works for ESLint and friends too (except for mocha, since it has no config file we can be required from):

```bash
eslint src
```

```js
// .eslintrc.js
const neutrino = require('neutrino');

// Load with no config overrides:
module.exports = neutrino().eslintrc();

// Load with config overrides:
module.exports = neutrino().eslintrc(config => {
  // return whatever config you want, like manipulating rules, etc.
});
```

---

- This approach is predicated on having middleware defined in `.neutrinorc.js`, which shouldn't change at all.
- ~~This does do away with a bunch of CLI functionality like `--inspect` or `--use`, but those become less useful if we are just an interface to external CLI tools. We can discuss potentially bringing those back.~~ This is now back in the form of the CLI with `neutrino --inspect`.
- ~~All environment variables are gone. We rely only on webpack's `mode` value.~~ We internally only use webpack's `mode` value, but still set `process.env.NODE_ENV` if not set based on the mode, or defaulted to `production`.
- ~~There is no longer a create-project tool, since we cannot force users to choose between competing tools like webpack-cli or webpack-command, and webpack-dev-server or webpack-serve.~~ The create-project tool is back, and we opt for `webpack-cli` and `webpack-dev-server` as opinions for now.

I'm sure there are other major things I am neglecting to mention. Let's discuss! I see so many benefits to this, including reduced maintenance burden and the ability to allow people to use Neutrino without dumping their existing tools.

cc: @mozilla-neutrino/core-contributors
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

4 participants