Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.7] running eslint through npm script throws error. #12604

Closed
kufii opened this issue Nov 26, 2019 · 14 comments · May be fixed by rsumner868/librealsense2.1#1, rsumner868/librealsense#4, nl253/BlogUI#3, yowainwright/learn-redux#7 or O330oei/node#4

Comments

@kufii
Copy link

@kufii kufii commented Nov 26, 2019

I don't experience the issue when using eslint v6.6.x.

I have the following script in my package.json:

  "scripts": {
    "lint": "eslint ."
  },

If I run eslint . directly in the console it works correctly, but when I run npm run lint, it throws an error. It seems like it's using the wrong config?

ESLint: 6.7.1.

ESLint couldn't find the config "adpyke-es6" to extend from. Please check that the name of the config is correct.

The config "adpyke-es6" was referenced from the config file in "C:\Users\pykea\.eslintrc".

If you still have problems, please stop by https://gitter.im/eslint/eslint to chat with the team.
@kufii kufii added bug triage labels Nov 26, 2019
@adamklepacz

This comment has been minimized.

Copy link

@adamklepacz adamklepacz commented Nov 26, 2019

I have the same problem but with eslint-prettier-plugin.
I've been adding prettier to eslint on Saturday and everything works fine, but today on the new project I've got this:


ESLint: 6.7.1.

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/Users/adamklepacz/GitHub/weather_tracker/node_modules/eslint-plugin-prettier/eslint-plugin-prettier.js".

Should I downgrade the eslint to the previous release?

@Digznav

This comment has been minimized.

Copy link

@Digznav Digznav commented Nov 26, 2019

Same here. I was updating the dependencies today and the error pop up when testing with eslint@6.7.1

$ eslint --report-unused-disable-directives .


Oops! Something went wrong! :(

ESLint: 6.7.1.

ESLint couldn't find the config "airbnb" to extend from. Please check that the name of the config is correct.

The config "airbnb" was referenced from the config file in "/Users/diegomiguel/.eslintrc.json".

I then installed a previous version eslint@6.6.0, and it worked as expected.

@mysticatea mysticatea added evaluating and removed triage labels Nov 26, 2019
@mysticatea

This comment has been minimized.

Copy link
Member

@mysticatea mysticatea commented Nov 26, 2019

Hi. Thank you for your reports.

Would you provide the repro steps from scratch?
I'm troubled to reproduce it.

Thanks.

@kufii

This comment has been minimized.

Copy link
Author

@kufii kufii commented Nov 26, 2019

npm init
npm install --save-dev eslint eslint-config-adpyke-es6

create .eslintrc in the root of the project, use these contents

{
  "extends": "adpyke-es6"
}

add the following script to package.json

"lint": "eslint ."

run npm run lint

@kufii

This comment has been minimized.

Copy link
Author

@kufii kufii commented Nov 26, 2019

also it might be important to have a .eslintrc in your home folder as well? so if this doesn't work try adding .eslintrc to your home folder with the same contents

@mysticatea

This comment has been minimized.

Copy link
Member

@mysticatea mysticatea commented Nov 26, 2019

Thank you.

Hmm, I put {"extends": "adpyke-es6"} and eslint-config-adpyke-es6 into both cases of the current directory and home directory, but I couldn't reproduce it.

@kufii

This comment has been minimized.

Copy link
Author

@kufii kufii commented Nov 26, 2019

can I see your package.json?

@mysticatea

This comment has been minimized.

Copy link
Member

@mysticatea mysticatea commented Nov 26, 2019

{
  "name": "sandbox",
  "version": "0.0.0",
  "description": "",
  "main": "index.js",
  "files": [],
  "scripts": {
    "try": "eslint ."
  },
  "keywords": [],
  "author": "Toru Nagashima <public@mysticatea.dev>",
  "license": "MIT",
  "dependencies": {
    "eslint": "^6.7.1",
    "eslint-config-adpyke-es6": "^1.4.13"
  }
}
@kufii

This comment has been minimized.

Copy link
Author

@kufii kufii commented Nov 26, 2019

that looks right. And you have an .eslintrc in both your project folder and your home folder?

@mysticatea

This comment has been minimized.

Copy link
Member

@mysticatea mysticatea commented Nov 26, 2019

Yes, I have tried either and both.

@Digznav

This comment has been minimized.

Copy link

@Digznav Digznav commented Nov 26, 2019

I have an .eslintrc.json in my home folder:

{
  "extends": [
    "airbnb",
    "prettier"
  ],
  "plugins": ["prettier"],
  "parser": "babel-eslint"
}

And also have a .eslintrc.json in my project folder: ~/projects/packages/eslint-config

In which I have the following structure:

eslint-config/
	- rules/
	- index.js
	- .eslintrc.json
	- package.json

In config file:

{
  "extends": "./index"
}

index.js:

module.exports = {
    extends: [
        './rules/best-practices',
        './rules/errors'
    ].map(require.resolve),
    parser: 'babel-eslint',
    parserOptions: {
        ecmaVersion: 2018,
        sourceType: 'module'
    },
    rules: {}
};

Script in package.json: "lint": "eslint --report-unused-disable-directives ."

@mysticatea

This comment has been minimized.

Copy link
Member

@mysticatea mysticatea commented Nov 26, 2019

Ah, OK, I have found what it happens. Thank you for providing the information.

This happens under the following conditions:

  1. You have ESLint config in your HOME directory, but the config doesn't work because of lacking dependencies in your HOME directory. (this behavior has been same since 6.0.0)
  2. You have ESLint config in your project directory as well and it works well.
  3. You started linting with the project directory itself (i.e., eslint .).

In the situation, first, ESLint has checked if the directory is ignored or not. Previously this process loads only .eslintignore. But since 6.7.0, this process additionally loads config files from the directory that the project directory exists because it uses ignorePatterns property of config files. If config files were not found in the directory that the project directory exists, it loads the config file in the HOME directory.

I think it's not intuitive if eslint . command loads config files from outside of the project directory.

@mysticatea mysticatea added accepted and removed evaluating labels Nov 26, 2019
mysticatea added a commit that referenced this issue Nov 27, 2019
@mysticatea

This comment has been minimized.

Copy link
Member

@mysticatea mysticatea commented Nov 27, 2019

Side note: As you may know, we have deprecated the config files in HOME directory. The error of this issue looks like thrown from unused config files in HOME directory (because it should not work since ESLint 6.0.0, I guess that you have not used it while a time), therefore I'd like to recommend to remove it.

@bertho-zero

This comment has been minimized.

Copy link

@bertho-zero bertho-zero commented Nov 29, 2019

You can replace

  "scripts": {
    "lint": "eslint ."
  }

by

  "scripts": {
    "lint": "eslint $(pwd)/."
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.