Hi, we have these versions in our project:
"eslint": "~3.18.0"
"eslint-config-airbnb": "~14.0.0",
With recent patch release our setup broke. Was there any purpose to release changes as a patch release?
Release : https://github.com/airbnb/javascript/releases/tag/eslint-config-airbnb-base-v11.1.3
Change: https://github.com/airbnb/javascript/commit/74071a809c22fa1104fe5d86bcd1eda949e1d0d9
From my point of view it should be a minor release, because the new functionality was added, it was an enhancement for a new eslint version that requires update for a minor eslint version.
https://github.com/airbnb/javascript/issues/1353
This might be more a bug. I get this while attempting to lint files:
fatal: Error: /project/node_modules/eslint-config-airbnb-base/rules/style.js: Configuration for rule "no-restricted-syntax" is invalid: Value "[object Object]" is the wrong type. Referenced from: /project/node_modules/eslint-config-airbnb-base/index.js Referenced from: airbnb Referenced from: /project/.eslintrc.json
Versions:
eslint-config-airbnb: 14.1.0
eslint-config-airbnb-base: 11.1.3 (<- dependency from eslint-config-airbnb)
eslint: 3.19.0
.eslint.json
{
"extends": [ "airbnb" ],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": false
}
},
"env": {
"browser": true,
"jquery": true,
"amd": true
}
}
@hultberg Have you tried to update eslint version to 3.19.*? It helped me.
@jackkainov I editied my comment after you commented, but I already have the latest eslint. :smile:
I just downgraded eslint-config-airbnb to 14.0 (npm i [email protected]), awaiting fix.
Same here. I'm using the latest available version of eslint and eslint-plugin-import.
eslint-config-airbnb-base 11.1.3 causes Fatal Error in eslint
Our setup that works
├─┬ [email protected]
├─┬ [email protected]
│ └── [email protected]
Wow. I was under the impression that the atom package I was using for eslinting used the locally installed one, however, that was not the case. It used eslint 3.18.0. I switched to another package that is using the locally installed eslint, and now it works. Sorry for the inconvenience. :tada:
The issue is that eslint was not up to date.
We do not consider a peer dep update a breaking change; if you install the package using the command in the readme, you'll get the updated peer deps; similarly, if you npm install and have everything properly specified with a ^ semver range (not with ~, which does not upgrade minors, only patches), eslint will always be updated correctly.
There's nothing to fix here.
@ljharb hi. Could you tell me what's wrong with my setup? I'm using Windows
C:\frontend>npm info "eslint-config-airbnb-base@latest" peerDependencies
{ eslint: '^3.19.0', 'eslint-plugin-import': '^2.2.0' }
C:\frontend>npm view eslint version
3.19.0
C:\frontend>npm view eslint-plugin-import version
2.2.0
C:\frontend>npm view eslint-config-airbnb-base version
11.1.3
C:\frontend>gulp lint
[21:51:25] Requiring external module babel-register
[21:51:26] [Building for Production environment]
[21:51:26] Using gulpfile C:\frontend\gulpfile.babel.js
[21:51:26] Starting 'lint'...
[21:51:26] 'lint' errored after 73 ms
[21:51:26] Error: Cannot find module 'eslint-module-utils/resolve'
Referenced from: airbnb-base
Referenced from: C:\frontend\.eslintrc
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\frontend\node_modules\eslint-plugin-import\lib\rules\rules\no-unresolved.js:6:1)
at Module._compile (module.js:571:32)
at Module._extensions..js (module.js:580:10)
at Object.require.extensions.(anonymous function) [as .js] (C:\frontend\node_modules\babel-register\lib\node.js:152:7)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
When I do npm list I get these messages:
npm ERR! missing: eslint-import-resolver-node@^0.2.0, required by [email protected]
npm ERR! missing: eslint-module-utils@^2.0.0, required by [email protected]
npm ERR! missing: better-assert@~1.0.0, required by [email protected]
npm ERR! missing: better-assert@~1.0.0, required by [email protected]
npm ERR! missing: better-assert@~1.0.0, required by [email protected]
Oops. I just found out that the error occurs after I run npm prune
This command removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed.
Extraneous packages are packages that are not listed on the parent package's dependencies list.
C:\frontend>npm prune
- [email protected] node_modules\callsite
- [email protected] node_modules\better-assert
- [email protected] node_modules\eslint-import-resolver-node
- [email protected] node_modules\eslint-module-utils\node_modules\ms
- [email protected] node_modules\eslint-module-utils\node_modules\debug
- [email protected] node_modules\pkg-dir
- [email protected] node_modules\eslint-module-utils
npm WARN [email protected] No repository field.
npm update installs [email protected] again and everything works fine, but as I quoted above the npm prune command must remove not used packages. But it removes eslint-plugin-import for some reason. It was working fine before version 11.1.3
npm prune is supposed to remove everything that's not in package.json - i'm not sure where any of those pruned dependencies come from, but if any of them are peer deps of any of your other deps (or of, perhaps, eslint-plugin-import) and not in your package.json, then that would cause this.
@ljharb could you please take a look at this log https://gist.github.com/maxkorz/3e5c3f316350e6643c91d30742706f67
I do:
npm init
npm install eslint --save
npm info "eslint-config-airbnb-base@latest" peerDependencies
npm install eslint-plugin-import --save
npm install eslint-config-airbnb-base --save
npm list (no errors)
npm prune
npm list (missing deps in eslint-config-airbnb-base)
I don't think this is expected behavior. I have 51 dependency in my package.js and only eslint-config-airbnb-base have this problem with npm prune
Just to prove my point I made this screenshot https://i.imgur.com/vVHqsYz.png
I do npm-prune and it doesn't remove any dependency of eslint plugin. You can see that I still have a lot of folders in node_modules folder. But eslint-import-resolver-node and eslint-module-utils are removed for some reason
The package readme has an install command that works on Windows; your commands don't necessarily install the correct versions.
as I said - it might be a bug in eslint-plugin-import, I'm not sure. (Running npm prune every time is not a common use case, since nobody else is running into this).
I can see here that both of these are deps of eslint-plugin-import, so perhaps it's a bug in npm?
If you use --save-dev (since eslint is a dev dep, not a runtime dep) or better, use the install command in the readme, what happens both before and after npm prune?
If I use --save-dev npm prune doesn't remove anything. But I'm using NODE_ENV=development for a development server and NODE_ENV=production for a production server. When the NODE_ENV environment variable is set to production, npm will not install modules listed in devDependencies. That's why I install everything into dependencies. That way I don't have to worry about NODE_ENV variable. npm prune also have different behavior based on NODE_ENV:
If the --production flag is specified or the NODE_ENV environment variable is set to production, this command will remove the packages specified in your devDependencies
But as I said, I don't have this kind of problem with any other package.
I found out this issue is definitely connected to NODE_ENV:
package.json:
{
"name": "frontend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"eslint": "^3.19.0",
"eslint-config-airbnb-base": "^11.1.3",
"eslint-plugin-import": "^2.2.0"
}
}
C:\frontend>SET NODE_ENV=development
C:\frontend>npm prune // nothing gets removed
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
C:\frontend>SET NODE_ENV=production
C:\frontend>npm prune
- [email protected] node_modules\eslint-import-resolver-node
- [email protected] node_modules\eslint-module-utils\node_modules\ms
- [email protected] node_modules\eslint-module-utils\node_modules\debug
- [email protected] node_modules\pkg-dir
- [email protected] node_modules\eslint-module-utils
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
As you can see the npm prune command removes packages only if variable NODE_ENV is set to production. Any thoughts?
You shouldn't be running npm install in production at all :-/ but this is definitely off topic.
Does the same thing happen with NODE_ENV set to development but npm prune --production?
Yes.
C:\frontend>SET NODE_ENV=development
C:\frontend>npm prune
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
C:\frontend>npm prune --production
- [email protected] node_modules\eslint-import-resolver-node
- [email protected] node_modules\eslint-module-utils\node_modules\ms
- [email protected] node_modules\eslint-module-utils\node_modules\debug
- [email protected] node_modules\pkg-dir
- [email protected] node_modules\eslint-module-utils
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
Please note that npm prune doesn't remove any dependency of eslint itself.
C:\frontend>SET NODE_ENV=production
C:\frontend2>npm list --depth 1
[email protected] C:\frontend2
`-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]
C:\frontend2>npm install && npm update && npm prune
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
As you can see, eslint has a lot of dependencies and there's nothing to install or update (which means I have the latest version of eslint) and still npm prune doesn't remove anything.
I'm not sure what to tell you - can you file a separate issue for this, with a summary of this info?
Yeah will do. Also I'm going to open issue about this here https://github.com/npm/npm
@ljharb I found an existing issue that describes the problem: https://github.com/npm/npm/issues/15669
eslint-plugin-import's package.json has eslint-module-utils and eslint-import-resolver-node dependencies listed in both dependencies and devDependencies.
So I amended /node_modules/eslint-plugin-import/package.json to have eslint-module-utils only in dependencies and npm prune didn't remove it. So can this be fixed? Do you still want me to create an issue on this topic? Or you need these dependencies to be in both dependencies and devDependencies?
That's just an npm bug then. You can certainly make a pr to eslint-plugin-import to remove the dev dep entries.
Most helpful comment
Wow. I was under the impression that the atom package I was using for eslinting used the locally installed one, however, that was not the case. It used eslint 3.18.0. I switched to another package that is using the locally installed eslint, and now it works. Sorry for the inconvenience. :tada: