Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

v8.1.0: "Couldn't find preset "node5" relative to directory" #796

Closed
atkinchris opened this issue Jan 31, 2017 · 10 comments
Closed

v8.1.0: "Couldn't find preset "node5" relative to directory" #796

atkinchris opened this issue Jan 31, 2017 · 10 comments

Comments

@atkinchris
Copy link

Issue Type

Bug introduced with version 8.1.0.

Issue Description

When using eslint-import-resolver-webpack with a webpack.config.babel.js, linter-eslint no longer lints files in the project.

The below console output is observed in Atom, when no linting occurs:

[Linter-ESLint] STDERR There was a problem loading formatter: /Users/christopher.atkin/.atom/packages/linter-eslint/lib/reporter.js
Error: Couldn't find preset "node5" relative to directory "/Users/christopher.atkin/.atom/packages/linter-eslint"

Reverting to linter-eslint@8.0.0 (or using a non-Babel webpack.config.js) resolved the issue.

Bug Checklist

Atom restarted, freshly reinstalled all plugins and Atom itself, and moved between linter-eslint versions to confirm.

Atom version: 1.13.1
linter-eslint version: 8.1.0
ESLint version: 3.14.1
Hours since last Atom restart: 0.1
Platform: darwin
Using local project ESLint from /Users/christopher.atkin/Source/promcomm-app/node_modules/eslint
linter-eslint configuration: {
  "lintHtmlFiles": false,
  "useGlobalEslint": false,
  "showRuleIdInMessage": true,
  "disableWhenNoEslintConfig": true,
  "eslintrcPath": "",
  "globalNodePath": "",
  "advancedLocalNodeModules": "",
  "eslintRulesDir": "",
  "disableEslintIgnore": false,
  "disableFSCache": false,
  "fixOnSave": false,
  "scopes": [
    "source.js",
    "source.jsx",
    "source.js.jsx",
    "source.babel",
    "source.js-semantic"
  ],
  "rulesToSilenceWhileTyping": [],
  "rulesToDisableWhileFixing": []
}
@atkinchris
Copy link
Author

Installing babel-preset-node5 as a non-dev dependency into ~/.atom/packages/linter-eslint also resolves this. Could this have been introduced following 5b4f682?

@atkinchris
Copy link
Author

Looking further into this, I suspect this comes from the 'use babel' pragma mark in each file (https://github.com/AtomLinter/linter-eslint/blob/master/lib/helpers.js#L2) causing Atom to preprocess package files (ref: http://blog.atom.io/2015/02/04/built-in-6to5.html).

By changing to a .babelrc file in 5b4f682, Babel uses this to determine which presets to use. As node5 is not installed as a regular dependency, it will not be available to Atom when it attempts to preprocess the eslint files that need transpiling.

@Arcanemagus
Copy link
Member

This sounds like a bug in eslint-import-resolver-webpack, the linter-eslint code should have nothing to do with linting your project, especially since your project is properly loading a local ESLint instance. I have no idea how it's even getting a reference to it 😕.

Can you provide a minimal repro case?

@atkinchris
Copy link
Author

I agree, @Arcanemagus - it feels like it should be a bug in eslint-import-resolver-webpack, or at the very least, an incompatibility. The version bump in this project surfaced the error, and gave the related error message, hence my starting here.

I'll try to reproduce a minimal case.

@atkinchris
Copy link
Author

I cannot create a succinct reproduction for this issue, that doesn't require a range of ESLint plugins (and that doesn't return a different error, handled gracefully through linter-eslint).

Happy to close this as a compatibility issue, when mixing a specific set of plugins with an edge usage case.

@beauroberts
Copy link

Hey, I also ran into this issue because I'm sure I have the same weird combination of eslint plugins installed. Is the current recommendation to downgrade linter-eslint? Has an issue been filed against eslint-import-resolver-webpack?

@nicolasartman
Copy link

nicolasartman commented Feb 6, 2017

I was able to solve this in my project by pulling my resolve configuration out into a new es5-only file and exporting it using commonjs form.

For example:

webpack-resolve-configuration.js

module.exports = {
  resolve: {
    root: path.resolve('src'),
    extensions: ['', '.js', '.jsx', '.json'],
    modulesDirectories: ['node_modules/']
  }
};

Then I just import that file into my main webpack configuration file to use for the resolve configuration field, and also reference it with my eslint config for the import plugin:

  "settings": {
    "import/resolver": {
      "webpack": {
        "config": "webpack-resolve-configuration.js"
      }
    },
  }

It's not a perfect solution but it's simple, it works, and you don't have to duplicate code or downgrade your whole webpack config to es5.

@Arcanemagus
Copy link
Member

Can either of you determine a sharable reproduction case? Has anyone filed this bug with eslint-import-resolver-webpack?

@nicolasartman
Copy link

nicolasartman commented Feb 7, 2017

It took a bit but I think I have it pretty well narrowed down. Here's a reproduction—in v8.0.0 it lints fine, but in v8.1.0 it silently fails with the error.

repro-broken.zip

To fix it in v8.1 just change the config to reference babel.config.js, delete the import in that file, and change the export to module.exports format.

The problem seems to be that the webpack config, when referenced through the resolver, doesn't get transpiled. I haven't been able to investigate exactly why, but I hope this reproduction helps!

repro-fixed.zip

(edit) One more note: if you open the broken repro, change the path to others.js and then npm run lint you'll see it correctly report the error. This suggests to me that the main issue here may be related to Atom or its plugin environment.

SpainTrain pushed a commit to SpainTrain/linter-eslint that referenced this issue Feb 10, 2017
- Added git attribute to export-ignore build-time babelrc config

More info: atom/apm#498 (comment)

Closes AtomLinter#796
@SpainTrain
Copy link
Member

SpainTrain commented Feb 10, 2017

Deeper explanation in #809, but TLDR: this is caused by how babel/register finds and processes .babelrc files.

.babelrc appears to only be used at build-time, so isn't needed in the installed APM package. Reopening this issue because:

@SpainTrain SpainTrain reopened this Feb 10, 2017
SpainTrain pushed a commit to SpainTrain/linter-eslint that referenced this issue Feb 10, 2017
- Added git attribute to export-ignore build-time babelrc config

More info: atom/apm#498 (comment)

Closes AtomLinter#796
SpainTrain added a commit that referenced this issue Feb 10, 2017
- Added git attribute to export-ignore build-time babelrc config

More info: atom/apm#498 (comment)

Closes #796
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants