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 · Fixed by #12607, basics/vector#113, basics/vector#127, thinkwee/thinkwee.github.io#39 or alxtford/numconv#46
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly patch candidate This issue may necessitate a patch release in the next few days

Comments

@kufii
Copy link

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 ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Nov 26, 2019
@adamklepacz
Copy link

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
Copy link

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 The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Nov 26, 2019
@mysticatea
Copy link
Member

Hi. Thank you for your reports.

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

Thanks.

@kufii
Copy link
Author

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
Copy link
Author

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
Copy link
Member

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
Copy link
Author

kufii commented Nov 26, 2019

can I see your package.json?

@mysticatea
Copy link
Member

{
  "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
Copy link
Author

kufii commented Nov 26, 2019

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

@mysticatea
Copy link
Member

Yes, I have tried either and both.

@Digznav
Copy link

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
Copy link
Member

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 There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Nov 26, 2019
@mysticatea
Copy link
Member

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.

@mysticatea mysticatea added the patch candidate This issue may necessitate a patch release in the next few days label Nov 27, 2019
@bertho-zero
Copy link

bertho-zero commented Nov 29, 2019

You can replace

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

by

  "scripts": {
    "lint": "eslint $(pwd)/."
  }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.