WordPress-Coding-Standards / stylelint-config-wordpress

WordPress shareable config for stylelint Note: Migrating to Gutenberg repo:

Home Page:https://github.com/WordPress/gutenberg/pull/22777

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm unmet dependancy?

orionrush opened this issue · comments

I've been looking at this project, but I've run into an issue where npm complains:

npm ERR! peer dep missing: stylelint@^9.5.0, required by stylelint-config-wordpress@13.1.0
npm ERR! peer dep missing: stylelint@^8.3.0 || ^9.0.0, required by stylelint-config-recommended-scss@3.2.0

I currently have "stylelint": "^10.0.1", required elsewhere.
How can I fix this?

I'll be publishing an update for this in the next couple of hours

I'm going to close this as the fix was committed in a78332e#diff-b9cfc7f2cdf78a7f4b91a753d10865a2

Hi - not sure if this is a caching issue, but as of right now (+11h from the last commit)
npm install stylelint-config-wordpress --save-dev still pulls stylelint-config-wordpress@13.1.0, which continues to throw the unmet dependency error.

However, explicitly installing stylelint-config-wordpress@^14 works.

Thanks @orionrush, I just tested this myself and its working fine now:

mkdir tmp
netweb@Stephens-MacBook-Pro ~/D/C/W/stylelint-config-wordpress> cd tmp/
netweb@Stephens-MacBook-Pro ~/D/C/W/s/tmp> npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (tmp)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to /Users/netweb/Developer/Code/WordPress/stylelint-config-wordpress/tmp/package.json:

{
  "name": "tmp",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this OK? (yes)
netweb@Stephens-MacBook-Pro ~/D/C/W/s/tmp>
netweb@Stephens-MacBook-Pro ~/D/C/W/s/tmp> ll
.rw-r--r-- 199 netweb 19 Apr 14:23 -N package.json
netweb@Stephens-MacBook-Pro ~/D/C/W/s/tmp> npm i stylelint-config-wordpress
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN stylelint-config-wordpress@14.0.0 requires a peer of stylelint@^9.5.0 || ^10.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN stylelint-config-recommended@2.2.0 requires a peer of stylelint@^8.3.0 || ^9.0.0 || ^10.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN stylelint-scss@3.6.0 requires a peer of stylelint@^8.0.0 || ^9.0.0 || ^10.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN stylelint-config-recommended-scss@3.2.0 requires a peer of stylelint@^8.3.0 || ^9.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN tmp@1.0.0 No description
npm WARN tmp@1.0.0 No repository field.

+ stylelint-config-wordpress@14.0.0
added 12 packages from 14 contributors and audited 13 packages in 3.457s
found 0 vulnerabilities

netweb@Stephens-MacBook-Pro ~/D/C/W/s/tmp>

@ntwb I'm working in Windows 10, and seem to be experiencing a similar issue. Specifically, when I install the package globally (with npm install stylelint-config-wordpress --save-dev -g), the output is:

npm WARN stylelint-config-wordpress@14.0.0 requires a peer of stylelint@^9.5.0 || ^10.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN stylelint-config-recommended-scss@3.3.0 requires a peer of stylelint@^8.3.0 || ^9.0.0 || ^10.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN stylelint-config-recommended@2.2.0 requires a peer of stylelint@^8.3.0 || ^9.0.0 || ^10.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN stylelint-scss@3.10.1 requires a peer of stylelint@^8.0.0 || ^9.0.0 || ^10.0.0 but none is installed. You must install peer dependencies yourself.

Prior to that, my full steps were:

  1. Install the stylelint extension in VSCode (by following the installation steps here).
  2. Confirm that stylelint does indeed report CSS infractions inside VSCode.
  3. Open my command line application (Git Bash) and Install stylelint-config-wordpress globally using pm install stylelint-config-wordpress --save-dev -g.
  4. Confirm that the package was installed to the local directory:
    C:/Users/snarl/AppData/Roaming/npm/node_modules/stylelint-config-wordpress.
  5. Open VSCode-->Settings-->stylelint configuration options-->config and add the line "extends": "C:/Users/snarl/AppData/Roaming/npm/node_modules/stylelint-config-wordpress",
  6. Restart VSCode.

As a test, In VSCode I opened a CSS file and inserted what should be a violation of WordPress CSS coding standards (0 values should not have units unless necessary, such as with transition-duration). I would expect stylelint to flag this a violation, but it did not.

Thoughts on that? Have I missed a step?

If you'd like me to create a new issue for this, I can.

@cagross My initial thoughts are that because you are installing stylelint-config-wordpress globally, you'll need to install those peer deps globally also.

Do you see them already installed at C:/Users/snarl/AppData/Roaming/npm/node_modules/?

@ntwb

My initial thoughts are that because you are installing stylelint-config-wordpress globally, you'll need to install those peer deps globally also.

Yes I thought that might be an issue.

Do you see them already installed at C:/Users/snarl/AppData/Roaming/npm/node_modules/?

No I do not. In that folder are the folders:

  • csslint
  • express-generator
  • foundation-cli
  • gulp-cli
  • jshint
  • npm
  • npm-windows-upgrade
  • stylelint-config-wordpress

In C:\Users\snarl.vscode\extensions\shinnn.stylelint-0.51.0\node_modules exist (among others):

  • stylelint
  • stylelint-vscode
  • stylelint-warning-to-vscode-diagnostic

Is this telling us that the stylelint folder is not installed globally? If so, what if I installed stylelint-config-wordpress in .vscode\extensions? Might that suitably resolve my issue?

Is this telling us that the stylelint folder is not installed globally? If so, what if I installed stylelint-config-wordpress in .vscode\extensions? Might that suitably resolve my issue?

That's worth a try for sure

I'd also take a peek in the C:/Users/snarl/AppData/Roaming/npm/node_modules/stylelint-config-wordpress folder to see if there is another node_modules folder in that folder and if those peer deps are already in that folder. (npm used to nest the deps in this type of tree structure)

I'd also take a peek in the C:/Users/snarl/AppData/Roaming/npm/node_modules/stylelint-config-wordpress folder to see if there is another node_modules folder in that folder and if those peer deps are already in that folder.

In that folder I see:

  • stylelint-config-recommended
  • stylelint-config-recommended-scss
  • stylelint-scss

Is this telling us that the stylelint folder is not installed globally? If so, what if I installed stylelint-config-wordpress in .vscode\extensions? Might that suitably resolve my issue?

That's worth a try for sure

OK. So to do that, can I simply cut the stylelint-config-wordpress folder out of C:/Users/snarl/AppData/Roaming/npm/node_modules/ and paste it into .vscode\extensions?

Yes, do that...

If there's still issues, try also copying the 3 folders under C:/Users/snarl/AppData/Roaming/npm/node_modules/stylelint-config-wordpress/node_modules under that also into .vscode\extensions

OK thanks for that. I moved stylelint-config-wordpress out of C:/Users/snarl/AppData/Roaming/npm/node_modules/ and into .vscode\extensions. It seems to have done something. Specifically, until now, when I ran npm list -g, at the end of the output it would complain about the missing peer deps. After I moved stylelint-config-wordpress, it no longer complains about the missing peer deps. But inside VSCode, I still don't see any stylelint WPCS rule violations. Thoughts? To test WPCS violations in VSCode, the exact violation I have added to my code is: 0 values should not have units unless necessary, such as with transition-duration.

Should I try moving the folders stylelint-config-recommended, stylelint-config-recommended-scss, and stylelint-scss out of C:/Users/snarl/AppData/Roaming/npm/node_modules/stylelint-config-wordpress and into .vscode\extensions?

Should I try moving the folders stylelint-config-recommended, stylelint-config-recommended-scss, and stylelint-scss out of C:/Users/snarl/AppData/Roaming/npm/node_modules/stylelint-config-wordpress and into .vscode\extensions?

Yes, try that

OK I tried that. But when I opened a CSS file in VSCode, those three folders were automatically moved out of .vscode\extensions and back into .vscode\extensions\stylelint-config-wordpress\node_modules

Thoughts? Isn't there a debugging console in VSCode? If so, might it contain debugging info?

@ntwb Any update to this issue? One possibly related issue I've noticed is that if I open VSCode-->Preferences-->Settings-->stylelint configuration options-->Config, I can see the extends line I added (per the installation instructions). That line is:

"extends": "C:/Users/snarl/.vscode/extensions/stylelint-config-wordpress",

But it is greyed out, as if disabled, or path not found (screenshot). That folder does indeed exist at that location (screenshot).
Thoughts on that? Could that be a clue?

FYI I resolved my issue about the extends line dimmer than the rest. Turns I out I had added the extends line to the wrong file. I added it to settings.json. That's why it was appearing dimmer than all other lines. Thanks for the help.