WordPress-Coding-Standards / eslint-config-wordpress

This package has been deprecated, please use @wordpress/eslint-plugin or @wordpress/scripts
https://www.npmjs.com/package/@wordpress/eslint-plugin
MIT License
45 stars 13 forks source link

Update dependencies for install #38

Closed swashata closed 6 years ago

swashata commented 6 years ago

I understand that eslint-config-wordpress is the only package I need to install for eslinting with WordPress standard and not the eslint-plugin-wordpress as the first should have the second as a dependency.

But I think, because the dependency is defined in devDependencies and not within dependencies the eslint-plugin-wordpress never gets installed.

I added eslint-config-wordpress like this (because the one in package repo is outdated.

{
  "name": "wesbos-js-es6",
  "version": "1.0.0",
  "main": "index.js",
  "repository": "git@wpquark.io:swashata/wesbos-js-es6.git",
  "author": "Swashata Ghosh <swashata@wpquark.com>",
  "license": "MIT",
  "private": true,
  "devDependencies": {
    "eslint": "^4.18.2",
    "eslint-config-wordpress": "git://github.com/WordPress-Coding-Standards/eslint-config-wordpress.git#936392374db7bb8403efb99bb8d454519b166947",
    "eslint-plugin-html": "^4.0.2",
    "eslint-plugin-react": "^7.7.0"
  }
}
yarn install --force

But this always complains

ESLint: ENOENT: no such file or directory, open '/Volumes/Development/vagrant/www/es6/public_html/wesbos-js-es6/node_modules/eslint-plugin-wordpress/index.js'. Please see the 'ESLint' output channel for details.

So I update the package.json and link the dependency manually by

{
  "name": "wesbos-js-es6",
  "version": "1.0.0",
  "main": "index.js",
  "repository": "git@wpquark.io:swashata/wesbos-js-es6.git",
  "author": "Swashata Ghosh <swashata@wpquark.com>",
  "license": "MIT",
  "private": true,
  "devDependencies": {
    "eslint": "^4.18.2",
    "eslint-config-wordpress": "git://github.com/WordPress-Coding-Standards/eslint-config-wordpress.git#936392374db7bb8403efb99bb8d454519b166947",
    "eslint-plugin-html": "^4.0.2",
    "eslint-plugin-react": "^7.7.0",
    "eslint-plugin-wordpress": "git://github.com/WordPress-Coding-Standards/eslint-plugin-wordpress.git#a5fdd5177c747562ddc3b03e069fcbf131632490"
  }
}

and now this works as expected.

Is it the intended behavior or is there something wrong?

ntwb commented 6 years ago

Thanks for the detailed issue @swashata, I think this is a Yarn specific issue to be honest (if it was also npm I'd have expected similar reported issues)

Currently eslint-plugin-wordpress is only used in devDependencies so that the codebase here in this eslint-config-wordpress repo can use some of the planned rule enhancements included in eslint-plugin-wordpress

There is also quite possibly some incompatibility between the versions you are using, the v2.0.0 release of eslint-config-wordpress is not outdated, it is the current and recommended version to use.

With all that said, later today I'll be releasing some new versions of both the packages in question which will resolve this issue anyway (I believe)

swashata commented 6 years ago

Great. I will be waiting for the release.

Just to clarify, if I use eslint-config-wordpress from npm,

"devDependencies": {
    "eslint": "^4.18.2",
    "eslint-config-wordpress": "^2.0.0",
    "eslint-plugin-html": "^4.0.2",
    "eslint-plugin-react": "^7.7.0"
  }

there was some other error, like ~/.rules not found. I don't remember the error exactly, but I think it was related to WordPress-Coding-Standards/eslint-plugin-wordpress#106

ntwb commented 6 years ago

Theoretically the release of eslint-config-wordpress will be version "2.1.0", so the semver range you have of "^2.0.0" will cover the release

swashata commented 6 years ago

Great...

swashata commented 6 years ago

@ntwb I just want to let you know that I was wrong with the ~/.rules not found error. I really messed up before while getting the error. Basically within the project, I had eslint-config-wordpress and within .eslintrc.js file, I had wordpress in the plugins directive. But I didn't install eslint-plugin-wordpress so it was yelling at me for (obviously) not finding the eslint-plugin-wordpress.

I understand why I was wrong. Now I have set things up with VSCode to automatically fix possible errors and formatting on save. Do you think I can send a PR with documentation for the same?

ntwb commented 6 years ago

Thanks for the update @swashata... It's pretty easy to do, I've got myself confused a couple of times in the past 24 hours 😏

A PR with those docs would be fanastic 😄

swashata commented 6 years ago

Alright. One last thing. Should the docs go into README or a separate folder like docs/vscode-setup.md docs/eslint-setup.md etc.

ntwb commented 6 years ago

This option docs/vscode-setup.md sounds good for now 👍