eslint-plugin-wordpress icon indicating copy to clipboard operation
eslint-plugin-wordpress copied to clipboard

Error: ENOENT: no such file or directory, scandir './rules'

Open grappler opened this issue 8 years ago • 11 comments

Package.json

  "eslintConfig": {
    "extends": "plugin:wordpress/recommended",
    "plugins": [
      "wordpress"
    ]
  },
  "eslintIgnore": [
    "js/**.min.js"
  ],

When I run the eslint js/** on _s I get the following error.

Error: ENOENT: no such file or directory, scandir './rules'
    at Error (native)
    at Object.fs.readdirSync (fs.js:951:18)
    at module.exports (/usr/local/lib/node_modules/eslint-plugin-wordpress/node_modules/requireindex/index.js:18:20)
    at Object.<anonymous> (/usr/local/lib/node_modules/eslint-plugin-wordpress/index.js:20:24)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)

Similar issue https://github.com/eslint/generator-eslint/pull/20

grappler avatar Jul 23 '17 14:07 grappler

@ntwb I figured out the issue. The issue is that the version on NPM has not been updated. https://www.npmjs.com/package/eslint-plugin-wordpress

I ended up installing it via npm i -g https://github.com/WordPress-Coding-Standards/eslint-plugin-wordpress

grappler avatar Jul 23 '17 16:07 grappler

If I understand this correctly eslint-config-wordpress is what I should be using and eslint-plugin-wordpress is where it the rules are managed.

Would that mean the Readme file should be updated to recommend people to use eslint-config-wordpress?

grappler avatar Jul 23 '17 21:07 grappler

If I understand this correctly eslint-config-wordpress is what I should be using and eslint-plugin-wordpress is where it the rules are managed.

Yes, you should really only use eslint-config-wordpress and as I just noted on the _s's PR I'll be releasing a new version of eslint-config-wordpress in the next couple of days with some pretty big changes, waiting a couple of days before refactoring any code to match these rules would be my recommendation :)

Would that mean the Readme file should be updated to recommend people to use eslint-config-wordpress?

Probably, yes :)

ntwb avatar Jul 24 '17 07:07 ntwb

I also just checked that the proposal for _s in https://github.com/Automattic/_s/pull/1159 uses eslint-config-wordpress 👍

ntwb avatar Jul 24 '17 07:07 ntwb

@ntwb Thanks, I did start looking at that but I got confused by the two repos as eslint-config-wordpress did not have all of the rules.

Are there different rulesets that we can use or does the WordPress ruleset include everything?

For example space-unary-ops is defined differently in stylistic-issues.js and jscs.js. Which one does get applied?

Or consistent-this in stylistic-issues.js. Why does it not create a warning for self = self.parentElement; in navigation.js#L72

grappler avatar Jul 24 '17 08:07 grappler

These are the updates that are coming in the next releases...

Up until (and currently including now) eslint-config-wordpress has been a standalone _shared config, with the release of 3.0.0ofeslint-config-wordpressit will extendeslint-plug-wordpress` which will then bring some parity to the both repos.

See also https://github.com/WordPress-Coding-Standards/eslint-config-wordpress/issues/8

ntwb avatar Jul 24 '17 08:07 ntwb

Me just experiencing same issue & noticed that it still v0.1.0 on npm?

image

I ended up installing it via npm i -g https://github.com/WordPress-Coding-Standards/eslint-plugin-wordpress

Is that's the only way to solve this issue? and when the latest version will available on npm?

Thanks

feryardiant avatar May 21 '18 20:05 feryardiant

@feryardiant Unless you have got a specific requirement to use this package, you should use https://github.com/WordPress-Coding-Standards/eslint-config-wordpress instead of this package here.

ntwb avatar May 22 '18 00:05 ntwb

@ntwb

Unless you have got a specific requirement to use this package

What's that mean? Is that mean you wanna say that "We don't have plan to publish latest version on npm for some reason" ??

Actually actually it's my first time trying to use all wordpress coding standards instead of just wpcs package but also eslint-config-wordress and stylelint-config-wordress. But I noticed some inconsistency and odd standards on the eslint-config-wordress package, somehow. For instance:

image

It's ask me to write

(function( document ) {
	// some codes
}( document ));

instead of

(function( document ) {
	// some codes
})( document );

Note: I'm not going to linting full project just yet.

Anyway, could you please explain further about the "specific requirement" means?

feryardiant avatar May 22 '18 11:05 feryardiant

Sure, @feryardiant, eslint-plugin-wordpress is currently undergoing lots of frequent changes and at the moment it also includes some bugs. There are no plans to publish any updates of this package to npmjs.com until some new coding standards changes are implemented upstream from WordPress Core and Gutenberg that fixes the bugs. Then we will look to releasing an update of eslint-plugin-wordpress to npmjs.com.

This is why I recommended using eslint-config-wordpress, seeing as though you have an issue with the wrap-iife rule you can turn that rule off in your local config. Also would you mind creating an issue at https://github.com/WordPress-Coding-Standards/eslint-config-wordpress/issues/new so we can investigate further if we should turn this rule off by default please.

ntwb avatar May 22 '18 11:05 ntwb

I see, thanks for the explanation @ntwb. Sure thing, will do.

feryardiant avatar May 22 '18 12:05 feryardiant